diff mbox series

[v3,17/23] hw/misc/nrf51_rng: Use qemu_guest_getrandom_nofail

Message ID 20190315032629.21234-18-richard.henderson@linaro.org
State Superseded
Headers show
Series Add qemu_getrandom and ARMv8.5-RNG etc | expand

Commit Message

Richard Henderson March 15, 2019, 3:26 a.m. UTC
The random number is intended for use by the guest.  As such, we should
honor the -seed argument for reproducibility.  Use the *_nofail routine
instead of error_abort directly.

Cc: qemu-arm@nongnu.org
Cc: Joel Stanley <joel@jms.id.au>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

---
 hw/misc/nrf51_rng.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

-- 
2.17.2

Comments

Joel Stanley March 15, 2019, 3:52 a.m. UTC | #1
On Fri, 15 Mar 2019 at 03:26, Richard Henderson
<richard.henderson@linaro.org> wrote:
>

> The random number is intended for use by the guest.  As such, we should

> honor the -seed argument for reproducibility.  Use the *_nofail routine

> instead of error_abort directly.

>

> Cc: qemu-arm@nongnu.org

> Cc: Joel Stanley <joel@jms.id.au>

> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>


Reviewed-by: Joel Stanley <joel@jms.id.au>


> ---

>  hw/misc/nrf51_rng.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

>

> diff --git a/hw/misc/nrf51_rng.c b/hw/misc/nrf51_rng.c

> index d188f044f4..3400e90a9b 100644

> --- a/hw/misc/nrf51_rng.c

> +++ b/hw/misc/nrf51_rng.c

> @@ -14,7 +14,7 @@

>  #include "qapi/error.h"

>  #include "hw/arm/nrf51.h"

>  #include "hw/misc/nrf51_rng.h"

> -#include "crypto/random.h"

> +#include "qemu/guest-random.h"

>

>  static void update_irq(NRF51RNGState *s)

>  {

> @@ -145,7 +145,7 @@ static void nrf51_rng_timer_expire(void *opaque)

>  {

>      NRF51RNGState *s = NRF51_RNG(opaque);

>

> -    qcrypto_random_bytes(&s->value, 1, &error_abort);

> +    qemu_guest_getrandom_nofail(&s->value, 1);

>

>      s->event_valrdy = 1;

>      qemu_set_irq(s->eep_valrdy, 1);

> --

> 2.17.2

>
diff mbox series

Patch

diff --git a/hw/misc/nrf51_rng.c b/hw/misc/nrf51_rng.c
index d188f044f4..3400e90a9b 100644
--- a/hw/misc/nrf51_rng.c
+++ b/hw/misc/nrf51_rng.c
@@ -14,7 +14,7 @@ 
 #include "qapi/error.h"
 #include "hw/arm/nrf51.h"
 #include "hw/misc/nrf51_rng.h"
-#include "crypto/random.h"
+#include "qemu/guest-random.h"
 
 static void update_irq(NRF51RNGState *s)
 {
@@ -145,7 +145,7 @@  static void nrf51_rng_timer_expire(void *opaque)
 {
     NRF51RNGState *s = NRF51_RNG(opaque);
 
-    qcrypto_random_bytes(&s->value, 1, &error_abort);
+    qemu_guest_getrandom_nofail(&s->value, 1);
 
     s->event_valrdy = 1;
     qemu_set_irq(s->eep_valrdy, 1);