aboutsummaryrefslogtreecommitdiff
path: root/hw/misc
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2019-03-14 16:12:04 -0700
committerRichard Henderson <richard.henderson@linaro.org>2019-05-22 12:38:54 -0400
commite8196d2111d2eb060a42feadef119de3aadae4f6 (patch)
tree22da24b03b3c382382a706dc649baf58479e2b2e /hw/misc
parent3090c980ed06e666a4b394fdb46284f220e091d1 (diff)
hw/misc/exynos4210_rng: Use qemu_guest_getrandom
The random number is intended for use by the guest. As such, we should honor the -seed argument for reproducibility. Reviewed-by: Laurent Vivier <lvivier@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
Diffstat (limited to 'hw/misc')
-rw-r--r--hw/misc/exynos4210_rng.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/hw/misc/exynos4210_rng.c b/hw/misc/exynos4210_rng.c
index 4ecbebd2d7..0e70ffb404 100644
--- a/hw/misc/exynos4210_rng.c
+++ b/hw/misc/exynos4210_rng.c
@@ -18,10 +18,10 @@
*/
#include "qemu/osdep.h"
-#include "crypto/random.h"
#include "hw/sysbus.h"
#include "qapi/error.h"
#include "qemu/log.h"
+#include "qemu/guest-random.h"
#define DEBUG_EXYNOS_RNG 0
@@ -109,7 +109,6 @@ static void exynos4210_rng_set_seed(Exynos4210RngState *s, unsigned int i,
static void exynos4210_rng_run_engine(Exynos4210RngState *s)
{
Error *err = NULL;
- int ret;
/* Seed set? */
if ((s->reg_status & EXYNOS4210_RNG_STATUS_SEED_SETTING_DONE) == 0) {
@@ -127,13 +126,11 @@ static void exynos4210_rng_run_engine(Exynos4210RngState *s)
}
/* Get randoms */
- ret = qcrypto_random_bytes((uint8_t *)s->randr_value,
- sizeof(s->randr_value), &err);
- if (!ret) {
+ if (qemu_guest_getrandom(s->randr_value, sizeof(s->randr_value), &err)) {
+ error_report_err(err);
+ } else {
/* Notify that PRNG is ready */
s->reg_status |= EXYNOS4210_RNG_STATUS_PRNG_DONE;
- } else {
- error_report_err(err);
}
out: