[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: [PATCH 1/3] hw/misc: Introduce AMD/Xilix Versal TRNG device
From: |
Ho, Tong |
Subject: |
RE: [PATCH 1/3] hw/misc: Introduce AMD/Xilix Versal TRNG device |
Date: |
Fri, 8 Sep 2023 17:56:11 +0000 |
Hi Peter,
The Versal TRNG device is required to support both TRNG mode and PRNG mode, and
target/guest
software selects and changes the mode at will during runtime.
I do agree that, in the TRNG mode, the model using qemu_guest_getrandom() will
work without any issues.
When software selects the PRNG mode, the Versal TRNG device is expected to
output a reproducible
and deterministic sequence of values for a given seed. This is part of the
hardware spec.
I fail to see how qemu_guest_getrandom() can be used to model such requirement
correctly.
Regards,
Tong Ho
-----Original Message-----
From: Peter Maydell <peter.maydell@linaro.org>
Sent: Friday, September 8, 2023 6:50 AM
To: Ho, Tong <tong.ho@amd.com>
Cc: Richard Henderson <richard.henderson@linaro.org>; qemu-arm@nongnu.org;
qemu-devel@nongnu.org; alistair@alistair23.me; edgar.iglesias@gmail.com
Subject: Re: [PATCH 1/3] hw/misc: Introduce AMD/Xilix Versal TRNG device
On Fri, 1 Sept 2023 at 05:16, Ho, Tong <tong.ho@amd.com> wrote:
>
> Hi Richard,
>
> Thanks for your input.
>
> I have questions regarding using qemu/guest-random.h for QEMU device models.
>
> Using qemu/guest-random.h, how can this TRNG model ensure its
> independence from other uses of the same qemu_guest_getrandom() and
> qemu_guest_random_seed_*()?
>
> By "other uses", I mean components and/or devices using qemu/guest-random.h
> but unrelated to this Xilinx Versal TRNG device.
>
> By "independent", I mean the Xilinx Versal TRNG device is:
>
> 1. Not impacted by other uses that may or may not need to set the
> '-seed' option, and
>
> 2. Not impacting other uses just because a Xilinx Versal machine user decides
> to use deterministic mode *only" for this TRNG device.
>
> Also, I am at a loss in how unrelated QEMU devices can remain independent
> when:
>
> 3. qemu/guest-random.h uses '__thread' variable for GRand context, but
>
> 4. QEMU devices run mostly as co-routines and not as separate threads.
You shouldn't need to care about any of this. Just assume you can get decent
quality random numbers from qemu_guest_getrandom() or
qemu_guest_getrandom_nofail(). The -seed option is for the entire simulation,
not specific to individual RNG devices.
> I suppose the Versal TRNG implementation could use g_rand_*()
> directly, having a GRand object in the device state and seeding through
> g_rand_set_seed_array().
Don't do something non-standard. Write this RNG device the same way we do all
other RNG devices in QEMU.
thanks
-- PMM