Hey
This PR seems just a workaround.

I don't feel it is right solution to hardcode BIT30.
What if the host platform does not have such capability? You will get failure 
later.

To fix this function, can we call real CPUID instruction to return real value?


UINT32
EFIAPI
UnitTestHostBaseLibAsmCpuid (
  IN      UINT32  Index,
  OUT     UINT32  *Eax   OPTIONAL,
  OUT     UINT32  *Ebx   OPTIONAL,
  OUT     UINT32  *Ecx   OPTIONAL,
  OUT     UINT32  *Edx   OPTIONAL
  )
{
  UINT32  RetEcx;

  RetEcx = 0;
  switch (Index) {
    case 1:
      RetEcx |= BIT30; /* RdRand */
      break;
  }

  if (Eax != NULL) {
    *Eax = 0;
  }
  if (Ebx != NULL) {
    *Ebx = 0;
  }

  if (Ecx != NULL) {
    *Ecx = RetEcx;
  }

  if (Edx != NULL) {
    *Edx = 0;
  }
  return Index;
}

> -----Original Message-----
> From: Li, Yi1 <yi1...@intel.com>
> Sent: Friday, June 14, 2024 9:32 PM
> To: Gerd Hoffmann <kra...@redhat.com>; devel@edk2.groups.io
> Cc: Hou, Wenxing <wenxing....@intel.com>; Yao, Jiewen
> <jiewen....@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>;
> Pedro Falcato <pedro.falc...@gmail.com>; Ard Biesheuvel
> <ardb+tianoc...@kernel.org>
> Subject: RE: [edk2-devel] CryptoPkg host test broken due to smoketest for
> RDRAND
> 
> Approved, appreciate your quick response.
> 
> Thanks,
> Yi
> 
> -----Original Message-----
> From: Gerd Hoffmann <kra...@redhat.com>
> Sent: Friday, June 14, 2024 6:41 PM
> To: devel@edk2.groups.io; Li, Yi1 <yi1...@intel.com>
> Cc: Hou, Wenxing <wenxing....@intel.com>; Yao, Jiewen
> <jiewen....@intel.com>; Kinney, Michael D <michael.d.kin...@intel.com>;
> Pedro Falcato <pedro.falc...@gmail.com>; Ard Biesheuvel
> <ardb+tianoc...@kernel.org>
> Subject: Re: [edk2-devel] CryptoPkg host test broken due to smoketest for
> RDRAND
> 
> On Fri, Jun 14, 2024 at 07:07:41AM GMT, Li, Yi wrote:
> > All crypto host tests which consumed randlib broken due to:
> > https://github.com/tianocore/edk2/pull/5714
> > Not sure why this issue not reported  by CI when merge this PR.
> >
> > The reason is that the ```BaseRngLibConstructor``` of rnglib is not called 
> > in host
> test, so ```mRdRandSupported``` is not enabled.
> > Then the Crypto API calls ```GetRandomNumber*``` will fail.
> > GetRandomNumber64 (
> >   OUT     UINT64  *Rand
> >   )
> > {
> >   ......
> >   if (!ArchIsRngSupported ()) {
> >     return FALSE;
> >   }
> >
> > Is there a way to let unit test host to call the constructors correctly?
> 
> https://github.com/tianocore/edk2/pull/5775
> 
> take care,
>   Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#119574): https://edk2.groups.io/g/devel/message/119574
Mute This Topic: https://groups.io/mt/106666288/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to