-
Notifications
You must be signed in to change notification settings - Fork 104
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
[Bug]: AdvancedLoggerHdwPortLib should not check PCD for header versions greater than 2 #309
Comments
There is a case here where we could not have LoggerInfo, in the SEC instance: mu_plus/AdvLoggerPkg/Library/AdvancedLoggerLib/AdvancedLoggerCommon.c Lines 141 to 153 in a3d53ef
So, either we need the HdwPortLib to check the PCD and the upper lib not to, or the SEC instance needs to be reworked or have a separate code path. The smaller delta here is having the HdwPortLib check the PCD and being unconditionally called, so I'll put up a PR for that and we can discuss if a different approach is better. The other consideration here, though, is who will be implementing HdwPortLib. If this is intended to only use the mu_plus version, great, we can drop the upper layer's checking of the PCD. If a platform may implement HdwPortLib, then the core relies on the platform to check the PCD to only log what fields are set, which is a platform level decision, but may or may not be the intention of the AdvLogger flow. |
Looking again, if we unconditionally log in SEC, which seems reasonable, we can drop this double checking. |
There were different use cases for the bitmask vs. PCD. The bitmask was added for inheriting the level set by its loader (i.e. PEI core, when DXE is loaded, etc.). But the PCD was left alone to keep the functionality where the print level for each module can be changed on demand. |
## Description The DebugLevel is checked twice in the hot path on serial path writes and the HdwPortWrite call is made even if the upper layer knows that the message being logged does not meet the DebugLevel criteria. Closes #309. In order to maintain backwards compatibility, if the LoggerInfo block is found to have a version less than the hardware logging level version, the PCD is checked to decide whether to call HdwPortWrite or not. In SEC, because we may not have the LoggerInfo structure, we check the PCD to see if the message should be logged at this DebugLevel. For each item, place an "x" in between `[` and `]` if true. Example: `[x]`. _(you can also check items in the GitHub UI)_ - [x] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [ ] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [ ] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested Build tested. ## Integration Instructions If a bespoke AdvLoggerHdwPortLib is used, AdvLoggerHdwPortWrite should not check DebugLevel, but simply write the message to the hardware port. Co-authored-by: kuqin12 <[email protected]>
Is there an existing issue for this?
Current Behavior
wasted execution time on a hot path comparing the debug level against the PCD at both levels.
mu_plus/AdvLoggerPkg/Library/AdvancedLoggerHdwPortLib/AdvancedLoggerHdwPortLib.c
Line 64 in a3d53ef
Why does calling code just mask the bits rather than avoid the function call?
mu_plus/AdvLoggerPkg/Library/AdvancedLoggerLib/AdvancedLoggerCommon.c
Line 148 in a3d53ef
Expected Behavior
Expected to be as efficient as possible and require minimal code in lower layers.
Steps To Reproduce
Look at code
Build Environment
Version Information
Urgency
Medium
Are you going to fix this?
Someone else needs to fix it
Do you need maintainer feedback?
No maintainer feedback needed
Anything else?
May have impact on downstream/out-of-tree projects and their implementations.
The text was updated successfully, but these errors were encountered: