mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-08 02:03:56 -06:00
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>
This commit is contained in:
parent
3090c980ed
commit
e8196d2111
1 changed files with 4 additions and 7 deletions
|
@ -18,10 +18,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "qemu/osdep.h"
|
#include "qemu/osdep.h"
|
||||||
#include "crypto/random.h"
|
|
||||||
#include "hw/sysbus.h"
|
#include "hw/sysbus.h"
|
||||||
#include "qapi/error.h"
|
#include "qapi/error.h"
|
||||||
#include "qemu/log.h"
|
#include "qemu/log.h"
|
||||||
|
#include "qemu/guest-random.h"
|
||||||
|
|
||||||
#define DEBUG_EXYNOS_RNG 0
|
#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)
|
static void exynos4210_rng_run_engine(Exynos4210RngState *s)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
int ret;
|
|
||||||
|
|
||||||
/* Seed set? */
|
/* Seed set? */
|
||||||
if ((s->reg_status & EXYNOS4210_RNG_STATUS_SEED_SETTING_DONE) == 0) {
|
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 */
|
/* Get randoms */
|
||||||
ret = qcrypto_random_bytes((uint8_t *)s->randr_value,
|
if (qemu_guest_getrandom(s->randr_value, sizeof(s->randr_value), &err)) {
|
||||||
sizeof(s->randr_value), &err);
|
error_report_err(err);
|
||||||
if (!ret) {
|
} else {
|
||||||
/* Notify that PRNG is ready */
|
/* Notify that PRNG is ready */
|
||||||
s->reg_status |= EXYNOS4210_RNG_STATUS_PRNG_DONE;
|
s->reg_status |= EXYNOS4210_RNG_STATUS_PRNG_DONE;
|
||||||
} else {
|
|
||||||
error_report_err(err);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
out:
|
out:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue