Skip to content

SecurityPkg: Introduce Dynamic TCG Log Scaling V2#1805

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

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

Conversation

@Raymond-MS

@Raymond-MS Raymond-MS commented May 22, 2026

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 ARM VIRT platform with TPM enabled. Confirmed the UnitTest results. All 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

mu-automation Bot commented May 22, 2026

Copy link
Copy Markdown
Contributor

❌ QEMU Validation Failed

Source Dependencies

Repository Commit
mu_basecore ec34e3d
mu_tiano_platforms 23cede4

Results

Platform Target Build Boot Overall Boot Time Build Logs Boot Logs
Q35 DEBUG ✅ success ❌ failure 5m 0s (timed out) Build Logs Boot Logs
SBSA DEBUG ⏩ skipped ⏩ skipped N/A N/A N/A

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

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

@codecov-commenter

codecov-commenter commented May 22, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c 0.00% 338 Missing ⚠️
SecurityPkg/Tcg/TcgLogTest/TcgLogTestApp.c 0.00% 287 Missing ⚠️
SecurityPkg/Tcg/TcgLogTest/TcgLogTestCommon.c 0.00% 180 Missing ⚠️
SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.c 0.00% 134 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.24%           
=================================================
  Files                     ?     1640           
  Lines                     ?   421324           
  Branches                  ?     5035           
=================================================
  Hits                      ?     9469           
  Misses                    ?   411773           
  Partials                  ?       82           
Flag Coverage Δ
FmpDevicePkg 9.53% <ø> (?)
MdeModulePkg 1.64% <ø> (?)
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 Harness.
📢 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.

Copilot AI left a comment

Copy link
Copy Markdown

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 Outdated
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 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
@Raymond-MS Raymond-MS requested a review from makubacki May 28, 2026 00:02

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.

Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c Outdated
Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.inf Outdated
Comment thread SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
Comment thread SecurityPkg/Tcg/TcgLogTest/TcgLogTestDxe.c
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.

The dynamic scaling functionality removes setting the LAML/LASA in the
ACPI 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 the V4 version of the Start Method specific parameters.

Added the Truncation event marker to the end of the FinalEventLog when it
becomes truncated. Added a event signal for when scaling occurs on the
normal event log. Consumers can trigger callbacks on this event; the test
app uses this to know when scaling occurs.

Signed-off-by: Raymond Diaz <raymonddiaz@microsoft.com>
@Raymond-MS Raymond-MS force-pushed the personal/rdiaz/DynamicTcgLogV2 branch from a48c475 to ec34e3d Compare June 12, 2026 21:52
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.

5 participants