SecurityPkg: Introduce Dynamic TCG Log Scaling V2#1805
Conversation
✅ QEMU Validation PassedSource Dependencies
Results
Workflow run: https://github.com/microsoft/mu_basecore/actions/runs/26318779952 This comment was automatically generated by the Mu QEMU PR Validation workflow. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release/202511 #1805 +/- ##
=================================================
Coverage ? 2.21%
=================================================
Files ? 1637
Lines ? 420710
Branches ? 4949
=================================================
Hits ? 9308
Misses ? 411327
Partials ? 75
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:
|
There was a problem hiding this comment.
Pull request overview
This PR adds dynamic scaling of the TCG2 “normal” event log in Tcg2Dxe (doubling the allocation when the log would otherwise truncate), adjusts TPM2 ACPI table construction to treat LAML/LASA as optional by omitting them when unset, and introduces a multi-boot test (DXE + Shell UnitTest app) plus documentation for the new behavior.
Changes:
- Implement dynamic event log scaling in
SecurityPkg/Tcg/Tcg2Dxeand allocate the normal log fromEfiBootServicesData. - Update TPM2 ACPI table producers (
Tcg2Acpi,Tcg2AcpiFfa) to conditionally remove LAML/LASA from table length when unset; update shared TPM2 ACPI header types. - Add
TcgLogTest(DXE driver + UnitTest shell app) and README documentation to validate scaling pre- and post-ReadyToBoot.
Reviewed changes
Copilot reviewed 17 out of 17 changed files in this pull request and generated 10 comments.
Show a summary per file
| File | Description |
|---|---|
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.inf | New DXE test driver module definition. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.c | Implements pre-ReadyToBoot scaling test + protocol for log retrieval/enable. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.h | Shared test helpers declarations. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c | Shared event-log walking, “log until scaled”, and dump logic. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestApp.inf | New UnitTest shell application module definition. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTestApp.c | Post-ReadyToBoot scaling UnitTest + multi-boot coordination. |
| SecurityPkg/Tcg/TcgLogTest/TcgLogTest.h | Defines the TcgLogTest protocol and enable NV variable name. |
| SecurityPkg/Tcg/TcgLogTest/README.md | Documents the three-boot test flow and integration steps. |
| SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf | Updates protocol/PCD declarations related to ACPI log fields. |
| SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c | Adds dynamic scaling logic + ReadyToBoot tracking + allocation change. |
| SecurityPkg/Tcg/Tcg2Dxe/README.md | New documentation for scaling behavior and log types. |
| SecurityPkg/Tcg/Tcg2AcpiFfa/Tcg2AcpiFfa.inf | Adds new PCD consumption for skipping ACPI measurements. |
| SecurityPkg/Tcg/Tcg2AcpiFfa/Tcg2AcpiFfa.c | Refactors TPM2 ACPI table template handling and optional LAML/LASA logic. |
| SecurityPkg/Tcg/Tcg2Acpi/Tcg2Acpi.c | Refactors TPM2 ACPI table template handling and optional LAML/LASA logic. |
| SecurityPkg/SecurityPkg.dsc | Adds the new TcgLogTest modules to the package DSC. |
| SecurityPkg/SecurityPkg.dec | Publishes the new gTcgLogTestProtocolGuid. |
| MdePkg/Include/IndustryStandard/Tpm2Acpi.h | Introduces common-field macro and revisioned TPM2 table struct types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…come truncated it instead now dynamically scales doubling the size each time. An ERROR log is reported that an increase to your base log size should occur such that scaling is not necessary. This is a precaution against platforms that log a lot and the addition of new hashing algorithms for PQC. The log is allocated in BootServices memory. The ACPI log is created on ReadyToBoot with logs being added to both until they would need to scale. In this instance a truncation event is added to the ACPI log to indicate that the log is no longer valid and/or may not contain the entirety of the log. This ACPI table is allocated in NVS memory. If the ACPI table was already allocated at the time of the ACPI log creation, it is uninstalled and reinstalled with the updated LAML and LASA PCDs. Tests were added via TcgLogTest which includes a DXE driver and a UEFI shelld UnitTest app. The DXE driver handles pre-ReadyToBoot tests while the TestApp handles post-ReadyToBoot tests as well as gathering the test results from the DXE driver. Markdown documents were created to detail the changes.
…cause possible loss of data.
…used dynamic scaling to occur. Scaling the log now makes sure the LastEvent pointer is always valid.
…LASA thus removing the need to have the ACPI event log. If there is no log region reported in the ACPI table then no table need exist as there would be no other way to access it. This simplifies the dynamic scaling code as well as removes a bunch of features such as the truncation event and needing to reinstall the table. Updated the ACPI code to fix an issue where the template was outdated and the revision was reporting V5 but the template was still using an the V4 version of the Start Method specific parameters.
e95cd15 to
632c81d
Compare
Description
Implemented dynamic TCG log scaling in Tcg2Dxe. When the log would become truncated it instead now dynamically scales doubling the size each time. An ERROR log is reported that an increase to your base log size should occur such that scaling is not necessary. This is a precaution against platforms that log a lot and the addition of new hashing algorithms for PQC. The log is allocated in BootServices memory. Tests were added via TcgLogTest which includes a DXE driver and a UEFI shell UnitTest app. The DXE driver handles pre-ReadyToBoot tests while the TestApp handles post-ReadyToBoot tests as well as gathering the test results from the DXE driver. Markdown documents were created to detail the changes.
This version of dynamic scaling never sets the ACPI table LAML/LASA which means the table is never published with the log information. As such the only way to access the event log is through the Tcg2Protocol published by Tcg2Dxe. The LAML/LASA fields are OPTIONAL and when not set are removed from the table.
For details on how to complete these options and their meaning refer to CONTRIBUTING.md.
How This Was Tested
Tested via TcgLogTest included in the reference QEMU SBSA platform with TPM enabled. Confirmed the UnitTest results. Both tests report PASS.
Integration Instructions
Include the TcgLogTest .inf's to your platform .dsc and .fdf files. You will need to include both the TcgLogTestDxe and TcgLogTestApp for full functionality.