Skip to content

SecurityPkg: Introduce Dynamic TCG Log Scaling V2#1805

Open
Raymond-MS wants to merge 12 commits into
microsoft:release/202511from
Raymond-MS:personal/rdiaz/DynamicTcgLogV2
Open

SecurityPkg: Introduce Dynamic TCG Log Scaling V2#1805
Raymond-MS wants to merge 12 commits into
microsoft:release/202511from
Raymond-MS:personal/rdiaz/DynamicTcgLogV2

Conversation

@Raymond-MS
Copy link
Copy Markdown
Contributor

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.

  • Impacts functionality?
  • Impacts security?
  • Breaking change?
  • Includes tests?
  • Includes documentation?

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.

@mu-automation
Copy link
Copy Markdown
Contributor

mu-automation Bot commented May 22, 2026

✅ QEMU Validation Passed

Source Dependencies

Repository Commit
mu_basecore b365e48
mu_tiano_platforms 274d484

Results

Platform Target Build Boot Overall Boot Time Build Logs Boot Logs
Q35 DEBUG ✅ success ✅ success 0m 17s Build Logs Boot Logs
SBSA DEBUG ✅ success ✅ success 0m 33s Build Logs Boot Logs

Workflow run: https://github.com/microsoft/mu_basecore/actions/runs/26318779952

This comment was automatically generated by the Mu QEMU PR Validation workflow.

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 22, 2026

Codecov Report

❌ Patch coverage is 0% with 741 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release/202511@cd8fb3a). Learn more about missing BASE report.

Files with missing lines Patch % Lines
SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c 0.00% 285 Missing ⚠️
SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 0.00% 188 Missing ⚠️
SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.c 0.00% 142 Missing ⚠️
SecurityPkg/Tcg/TcgLogTest/TcgLogTestApp.c 0.00% 104 Missing ⚠️
SecurityPkg/Tcg/Tcg2Acpi/Tcg2Acpi.c 0.00% 11 Missing ⚠️
SecurityPkg/Tcg/Tcg2AcpiFfa/Tcg2AcpiFfa.c 0.00% 11 Missing ⚠️
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           
Flag Coverage Δ
FmpDevicePkg 9.53% <ø> (?)
MdeModulePkg 1.58% <ø> (?)
MdePkg 5.44% <ø> (?)
NetworkPkg 0.55% <ø> (?)
PolicyServicePkg 30.42% <ø> (?)
SecurityPkg 1.56% <0.00%> (?)
UefiCpuPkg 4.78% <ø> (?)
UnitTestFrameworkPkg 11.70% <ø> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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/Tcg2Dxe and allocate the normal log from EfiBootServicesData.
  • 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.

Comment thread SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.c
Comment thread SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c
Comment thread SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c
Comment thread SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c Outdated
Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c Outdated
Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
Comment thread SecurityPkg/Tcg/Tcg2Acpi/Tcg2Acpi.c
Comment thread SecurityPkg/Tcg/Tcg2Acpi/Tcg2Acpi.c
Comment thread SecurityPkg/Tcg/Tcg2AcpiFfa/Tcg2AcpiFfa.c
Comment thread SecurityPkg/Tcg/Tcg2Dxe/README.md Outdated
Raymond-MS added 10 commits May 22, 2026 19:40
…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.
…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.
@Raymond-MS Raymond-MS force-pushed the personal/rdiaz/DynamicTcgLogV2 branch from e95cd15 to 632c81d Compare May 22, 2026 19:40
Comment thread MdePkg/Include/IndustryStandard/Tpm2Acpi.h Outdated
Comment thread MdePkg/Include/IndustryStandard/Tpm2Acpi.h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants