From: "Pedro Falcato" <pedro.falcato@gmail.com>
To: "Jason A. Donenfeld" <Jason@zx2c4.com>
Cc: devel@edk2.groups.io,
Michael D Kinney <michael.d.kinney@intel.com>,
Liming Gao <gaoliming@byosoft.com.cn>,
Zhiguang Liu <zhiguang.liu@intel.com>
Subject: Re: [PATCH v2 1/1] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID
Date: Tue, 22 Nov 2022 15:56:01 +0000 [thread overview]
Message-ID: <CAKbZUD0-yOhTPaxRjV=U8O0yTr7a-FaDdQSroXp4xL+oxA19=A@mail.gmail.com> (raw)
In-Reply-To: <CAHmME9po1XGhLa6thJ3S_mR0mUwgmP0gASbrEZaj_3Q_+wvmhg@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]
On Tue, Nov 22, 2022 at 3:39 PM Jason A. Donenfeld <Jason@zx2c4.com> wrote:
> On Tue, Nov 22, 2022 at 4:32 PM Pedro Falcato <pedro.falcato@gmail.com>
> wrote:
> > + // Testing algorithm inspired by linux's
> arch/x86/kernel/cpu/rdrand.c:x86_init_rdrand
> > + // as relicensed by the author, Jason Donenfeld, in the EDK2 mailing
> list.
> > + // As is, the algorithm samples rdrand $RDRAND_TEST_SAMPLES times and
> expects
> > + // a different result $RDRAND_MIN_CHANGE times for reliable RDRAND
> usage.
>
> You don't need to pepper my name all over the source. :)
>
I just wanted to properly credit you :) If you're not okay with it I can
remove it in a v3.
> + for (TestIteration = 0; TestIteration < RDRAND_TEST_SAMPLES;
> TestIteration++) {
> > + UINT32 Sample;
> > + //
> > + // Note: We use a retry loop for rdrand. Normal users get this in
> BaseRng.c
> > + // Any failure to get a random number will assume RDRAND does not
> work.
> > + //
> > + for (Idx = 0; Idx < RDRAND_RETRIES; Idx++) {
> > + if (AsmRdRand32 (&Sample)) {
>
> The linux code will use a 64bit value on 64bit machines. I suggest you
> do the same here -- use native word size. I think EFI calls this a
> "UINTN".
>
Hmm, do you reckon it makes a difference? I'm not intimately familiar with
HWRNG internals. Unfortunately there's no AsmRdRandUintn
so this would take some per-bitness #define's which... yeah, I'd rather not.
Pedro
[-- Attachment #2: Type: text/html, Size: 2135 bytes --]
next prev parent reply other threads:[~2022-11-22 15:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 15:32 [PATCH v2 1/1] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID Pedro Falcato
2022-11-22 15:38 ` Jason A. Donenfeld
2022-11-22 15:56 ` Pedro Falcato [this message]
2022-11-22 16:54 ` [edk2-devel] " Michael D Kinney
2022-11-22 17:11 ` Jason A. Donenfeld
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAKbZUD0-yOhTPaxRjV=U8O0yTr7a-FaDdQSroXp4xL+oxA19=A@mail.gmail.com' \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox