-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MdePkg/BaseRngLib: Remove global variable for RDRAND state update #6417
Conversation
This change updates the default value from FALSE to TRUE. Is this the purpose? |
Right. Currently mRdRandSupported is not initialized. On our platform, the value is checked as 0 (FALSE). As the library is base type, it would be best to support a way not to use/update the global variable. Setting the default value (expected state) is a solution for platforms that didn't have a problem with the library version before the commit. |
Use of a non-const global variable in a lib of type BASE seems like a bug. |
I have same opinion. To fix the variable usage, I think that moving all code in BaseRngLibConstructor() into ArchIsRngSupported() could be good to remove mRdRandSupported when considering GetRandomNumberxx() is not a high frequency call. For example, I tried to evaluate the update on our platform that uses edk2-stable202408. Then checked that AsmCpuid() and TestRdRand() in ArchIsRngSupported() don't take much time (e.g. TestRdRand () spent 8~9(μs)), and a side effect is not found. Based on that, let me discuss this idea with maintainers. If it is accepted, I would be able to update the PR for it. |
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>
The PR has been updated to support the proposal. It is based on the feedback (agreed) from one of maintainers. |
@ardbiesheuvel , do you think this change is OK? |
Agree with @mdkinney's point that BASE libraries must not have non-const global variables, so I agree with the patch. |
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.
How This Was Tested
The update was verified on some AMD platforms (edk2-stable202408 base) that had the issue.
Integration Instructions
N/A