From: "Michael D Kinney" <michael.d.kinney@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
"pedro.falcato@gmail.com" <pedro.falcato@gmail.com>,
"Jason A. Donenfeld" <Jason@zx2c4.com>,
"Kinney, Michael D" <michael.d.kinney@intel.com>
Cc: "Gao, Liming" <gaoliming@byosoft.com.cn>,
"Liu, Zhiguang" <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID
Date: Tue, 22 Nov 2022 16:54:46 +0000 [thread overview]
Message-ID: <CO1PR11MB492947AAB542D2B8F04B0A85D20D9@CO1PR11MB4929.namprd11.prod.outlook.com> (raw)
In-Reply-To: <CAKbZUD0-yOhTPaxRjV=U8O0yTr7a-FaDdQSroXp4xL+oxA19=A@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 2049 bytes --]
Hi Pedro,
Pointers to external content that were used to create the code
change can be captured in the BZ and the commit message.
Thanks,
Mike
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Pedro Falcato
Sent: Tuesday, November 22, 2022 7:56 AM
To: Jason A. Donenfeld <Jason@zx2c4.com>
Cc: devel@edk2.groups.io; Kinney, Michael D <michael.d.kinney@intel.com>; Gao, Liming <gaoliming@byosoft.com.cn>; Liu, Zhiguang <zhiguang.liu@intel.com>
Subject: Re: [edk2-devel] [PATCH v2 1/1] MdePkg/BaseRngLib: Add a smoketest for RDRAND and check CPUID
On Tue, Nov 22, 2022 at 3:39 PM Jason A. Donenfeld <Jason@zx2c4.com<mailto:Jason@zx2c4.com>> wrote:
On Tue, Nov 22, 2022 at 4:32 PM Pedro Falcato <pedro.falcato@gmail.com<mailto: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: 42804 bytes --]
next prev parent reply other threads:[~2022-11-22 17:32 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
2022-11-22 16:54 ` Michael D Kinney [this message]
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=CO1PR11MB492947AAB542D2B8F04B0A85D20D9@CO1PR11MB4929.namprd11.prod.outlook.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