mirror of
https://github.com/acidanthera/audk.git
synced 2025-04-08 17:05:09 +02:00
MdePkg/BaseRngLib: Remove global variable for RDRAND state update
As a BASE type library, some PEI drivers could link and use it. Tcg2Pei.inf is an example. On edk2-stable202408 version, PEI drivers that link the library include the global variable of mRdRandSupported. The previous commit (c3a8ca7) that refers to the global variable actually is found to influence the link status. Updating the global variable in PEI drivers could affect the following issues. PEI ROM Boot : Global variable is not updated PEI RAM Boot : PEI FV integration/security check is failed To address these issues, remove the global variable usage. Signed-off-by: Phil Noh <Phil.Noh@amd.com>
This commit is contained in:
parent
4d3cf37ff0
commit
edb312d5d0
@ -2,6 +2,7 @@
|
||||
Random number generator services that uses RdRand instruction access
|
||||
to provide high-quality random numbers.
|
||||
|
||||
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved.<BR>
|
||||
Copyright (c) 2023, Arm Limited. All rights reserved.<BR>
|
||||
Copyright (c) 2022, Pedro Falcato. All rights reserved.<BR>
|
||||
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
|
||||
@ -23,8 +24,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
//
|
||||
#define RDRAND_MASK BIT30
|
||||
|
||||
STATIC BOOLEAN mRdRandSupported;
|
||||
|
||||
//
|
||||
// Intel SDM says 10 tries is good enough for reliable RDRAND usage.
|
||||
//
|
||||
@ -124,20 +123,6 @@ BaseRngLibConstructor (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
UINT32 RegEcx;
|
||||
|
||||
//
|
||||
// Determine RDRAND support by examining bit 30 of the ECX register returned by
|
||||
// CPUID. A value of 1 indicates that processor support RDRAND instruction.
|
||||
//
|
||||
AsmCpuid (1, 0, 0, &RegEcx, 0);
|
||||
|
||||
mRdRandSupported = ((RegEcx & RDRAND_MASK) == RDRAND_MASK);
|
||||
|
||||
if (mRdRandSupported) {
|
||||
mRdRandSupported = TestRdRand ();
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
@ -156,7 +141,6 @@ ArchGetRandomNumber16 (
|
||||
OUT UINT16 *Rand
|
||||
)
|
||||
{
|
||||
ASSERT (mRdRandSupported);
|
||||
return AsmRdRand16 (Rand);
|
||||
}
|
||||
|
||||
@ -175,7 +159,6 @@ ArchGetRandomNumber32 (
|
||||
OUT UINT32 *Rand
|
||||
)
|
||||
{
|
||||
ASSERT (mRdRandSupported);
|
||||
return AsmRdRand32 (Rand);
|
||||
}
|
||||
|
||||
@ -194,7 +177,6 @@ ArchGetRandomNumber64 (
|
||||
OUT UINT64 *Rand
|
||||
)
|
||||
{
|
||||
ASSERT (mRdRandSupported);
|
||||
return AsmRdRand64 (Rand);
|
||||
}
|
||||
|
||||
@ -211,7 +193,22 @@ ArchIsRngSupported (
|
||||
VOID
|
||||
)
|
||||
{
|
||||
return mRdRandSupported;
|
||||
BOOLEAN RdRandSupported;
|
||||
UINT32 RegEcx;
|
||||
|
||||
//
|
||||
// Determine RDRAND support by examining bit 30 of the ECX register returned by
|
||||
// CPUID. A value of 1 indicates that processor support RDRAND instruction.
|
||||
//
|
||||
AsmCpuid (1, 0, 0, &RegEcx, 0);
|
||||
|
||||
RdRandSupported = ((RegEcx & RDRAND_MASK) == RDRAND_MASK);
|
||||
|
||||
if (RdRandSupported) {
|
||||
RdRandSupported = TestRdRand ();
|
||||
}
|
||||
|
||||
return RdRandSupported;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user