public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Jason A. Donenfeld" <Jason@zx2c4.com>
To: Pedro Falcato <pedro.falcato@gmail.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 18:11:12 +0100	[thread overview]
Message-ID: <CAHmME9rnbQLwoLT2K7KA0pzZ34CHm-jpCmecMRSWtnEh45_s_Q@mail.gmail.com> (raw)
In-Reply-To: <CAKbZUD0-yOhTPaxRjV=U8O0yTr7a-FaDdQSroXp4xL+oxA19=A@mail.gmail.com>

On Tue, Nov 22, 2022 at 4:56 PM Pedro Falcato <pedro.falcato@gmail.com> wrote:
>
> 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.

Yes, please remove.

 >> > +  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?

Yes, it does. Please account for this. Use an ifdef or something if
you need. It's not very hard.

Jason

      parent reply	other threads:[~2022-11-22 17:11 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     ` [edk2-devel] " Michael D Kinney
2022-11-22 17:11     ` Jason A. Donenfeld [this message]

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=CAHmME9rnbQLwoLT2K7KA0pzZ34CHm-jpCmecMRSWtnEh45_s_Q@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