qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [RFC] rng-builtin: add an RNG backend that uses qemu_gu


From: Richard Henderson
Subject: Re: [Qemu-devel] [RFC] rng-builtin: add an RNG backend that uses qemu_guest_getrandom()
Date: Thu, 9 May 2019 09:59:03 -0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1

On 5/9/19 7:23 AM, Laurent Vivier wrote:
> Add a new RNG backend using QEMU builtin getrandom function.
> 
> It can be created with "-object rng-builtin".
> 
> This patch applies on top of
> "[PATCH v4 00/24] Add qemu_getrandom and ARMv8.5-RNG etc"
> Based-on: <address@hidden>
> Signed-off-by: Laurent Vivier <address@hidden>
> ---
>  backends/Makefile.objs |  2 +-
>  backends/rng-builtin.c | 56 ++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 57 insertions(+), 1 deletion(-)
>  create mode 100644 backends/rng-builtin.c

Looks good.  Thanks for picking this up.

Reviewed-by: Richard Henderson <address@hidden>

> +static void rng_builtin_request_entropy(RngBackend *b, RngRequest *req)
> +{
> +    RngBuiltin *s = RNG_BUILTIN(b);
> +
> +    while (!QSIMPLEQ_EMPTY(&s->parent.requests)) {
> +        RngRequest *req = QSIMPLEQ_FIRST(&s->parent.requests);
> +
> +        qemu_guest_getrandom_nofail(req->data, req->size);
> +
> +        req->receive_entropy(req->opaque, req->data, req->size);
> +
> +        rng_backend_finalize_request(&s->parent, req);
> +    }
> +}

As an aside, with all of the callbacks involved, does anyone know if this gets
processed on the same thread as issued the cpu that issued the i/o operation?

The question is only relevant to debugging mode (w/ -seed), in that if we're
processing this from an i/o worker thread we won't have completely
deterministic results, as we may compete with other cpus for the same RNG.

There's probably not much that can reasonably be done if this does cross
threads, and certainly it would not affect normal usage, but I just wondered.


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]