-
Notifications
You must be signed in to change notification settings - Fork 164
MdePkg: StandaloneMmDriverEntryPoint remove unnecessary dependency on MmServicesTableLib #1605
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: StandaloneMmDriverEntryPoint remove unnecessary dependency on MmServicesTableLib #1605
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release/202502 #1605 +/- ##
=================================================
Coverage ? 2.40%
=================================================
Files ? 1256
Lines ? 303812
Branches ? 2650
=================================================
Hits ? 7314
Misses ? 296442
Partials ? 56
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@Flickdm, global service tables accessed through service tables libraries is a common pattern. Is there more to this change? Afaict, the main issue with the previous code was that it used |
This is for OneCrypto, from a Sean request that I echoed. If the entry point lib doesn't use the services table lib, then the multiphase binary doesn't have to link in the services table lib. This helps to reduce the dependency chain; if something in the future that OneCrypto was relying on added a call to gMmst, we currently wouldn't catch it until it broke in runtime. If the library isn't linked in, we'd catch it at build time. |
os-d
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not everything (including INF) covered by MU_CHANGE tags and commenting out old lines instead of removing.
I can make that change real quick |
bc7905b to
2e0c743
Compare
Is that code allowed to call the same services from the |
In the MM part of the driver, yes. But that is only done when loaded by StMM Core (when it calls _ModuleEntryPoint() which calls the constructors). In the DXE side of the driver, definitely not, but that path doesn't exist because there is a custom entry point and so the library constructors aren't called. But that's the concern, that the DXE side should never accidentally call gMmst, which this change lets us enforce at build time. |
makubacki
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine to approve the change for the one crypto use case. A few points:
- This is unintuitive for the normal MM case.
MmServicesTableLibalready does exactly this and exposes the MM services table through a public symbol that is well established. This redundantly caches the same pointer in the same module when it is linked againstMmServicesTableLib(which is nearly all MM modules). - It is also unintuitive to say that a library class restricted to certain module types cannot use another library class of the same type for the purpose that the services exclusive to the module type cannot be used.
However, there is little practical downside to this change, and it is not a breaking change, I just want to raise those points that you'll likely encounter when pushing it more broadly.
| // | ||
| // Cached pointer to the MM System Table that is set during driver initialization. | ||
| // | ||
| EFI_MM_SYSTEM_TABLE *mCachedMmSystemTable = NULL; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: We don't normally include "cached" in the name of global pointer variables. I think mMmSystemTable is sufficient. But this is personal preference, feel free to keep this name if you like it.
Description
This pull request refactors how the MM System Table is accessed within the
StandaloneMmDriverEntryPoint.cfile. Instead of passing the system table pointer around, it introduces a cached global pointer, simplifying function calls and improving code clarity. The unnecessary dependency onMmServicesTableLibis also removed.Refactoring of MM System Table access:
mCachedMmSystemTableto cache the MM System Table pointer during driver initialization and replaced all usages of directMmSystemTableorgMmstwith this cached pointer throughout the file (StandaloneMmDriverEntryPoint.c). [1] [2] [3] [4]Dependency cleanup:
MmServicesTableLibfrom both the includes inStandaloneMmDriverEntryPoint.cand theLibraryClassessection in the INF file (StandaloneMmDriverEntryPoint.inf). [1] [2]How This Was Tested
QemuQ35
Integration Instructions
N/A