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: <20190506173353.32206-1-richard.hender...@linaro.org> > Signed-off-by: Laurent Vivier <lviv...@redhat.com> > --- > 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 <richard.hender...@linaro.org> > +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~