Skip to content

Commit

Permalink
Adding better TCG Logging messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Flickdm committed Feb 3, 2025
1 parent f288f79 commit 9c5ddfc
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
22 changes: 22 additions & 0 deletions SecurityPkg/Library/DxeTpm2MeasureBootLib/DxeTpm2MeasureBootLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,10 @@ Tcg2MeasureGptTable (
PartitionEntry = (EFI_PARTITION_ENTRY *)((UINT8 *)PartitionEntry + PrimaryHeader->SizeOfPartitionEntry);
}

// MU_CHANGE [BEGIN]
DEBUG ((DEBUG_INFO, "PCR[%x] MeasureGptTable\n",Tcg2Event->Header.PCRIndex));
// MU_CHANGE [END]

//
// Only one of TCG2_PROTOCOL or CC_MEASUREMENT_PROTOCOL is exposed.
// So Measure the GPT data with one of the protocol.
Expand Down Expand Up @@ -475,6 +479,24 @@ Tcg2MeasurePeImage (
CopyMem (ImageLoad->DevicePath, FilePath, FilePathSize);
}

// MU_CHANGE [END]
DEBUG_CODE_BEGIN ();

CHAR16 *ToText;
ToText = ConvertDevicePathToText (
ImageLoad->DevicePath,
FALSE,
TRUE
);
if (ToText != NULL) {
DEBUG ((DEBUG_INFO, "PCR[%x] MeasurePeImage (%s)\n",Tcg2Event->Header.PCRIndex, ToText));
FreePool (ToText);
} else {
DEBUG ((DEBUG_INFO, "PCR[%x] MeasurePeImage (N/A)\n",Tcg2Event->Header.PCRIndex));
}

DEBUG_CODE_END ();

//
// Log the PE data
//
Expand Down
17 changes: 12 additions & 5 deletions SecurityPkg/Tcg/Tcg2Dxe/Tcg2Dxe.c
Original file line number Diff line number Diff line change
Expand Up @@ -2009,6 +2009,9 @@ TcgMeasureAction (
TcgEvent.PCRIndex = PCRIndex;
TcgEvent.EventType = EV_EFI_ACTION;
TcgEvent.EventSize = (UINT32)AsciiStrLen (String);
// MU_CHANGE [BEGIN]
DEBUG ((DEBUG_INFO, "PCR[%x] MeasureAction: %a\n", PCRIndex, String));
// MU_CHANGE [END]
return TcgDxeHashLogExtendEvent (
0,
(UINT8 *)String,
Expand Down Expand Up @@ -2054,7 +2057,9 @@ MeasureHandoffTables (
HandoffTables.NumberOfTables = 1;
HandoffTables.TableEntry[0].VendorGuid = gEfiMpServiceProtocolGuid;
HandoffTables.TableEntry[0].VendorTable = ProcessorLocBuf;

// MU_CHANGE [BEGIN]
DEBUG ((DEBUG_INFO, "PCR[%x] MeasureHandoffTables\n", TcgEvent.PCRIndex));
// MU_CHANGE [END]
Status = TcgDxeHashLogExtendEvent (
0,
(UINT8 *)(UINTN)ProcessorLocBuf,
Expand Down Expand Up @@ -2087,8 +2092,9 @@ MeasureSeparatorEvent (
TCG_PCR_EVENT_HDR TcgEvent;
UINT32 EventData;

DEBUG ((DEBUG_INFO, "MeasureSeparatorEvent Pcr - %x\n", PCRIndex));

// MU_CHANGE [BEGIN]
DEBUG ((DEBUG_INFO, "PCR[%x] MeasureSeparatorEvent\n", PCRIndex));
// MU_CHANGE [END]
EventData = 0;
TcgEvent.PCRIndex = PCRIndex;
TcgEvent.EventType = EV_SEPARATOR;
Expand Down Expand Up @@ -2132,8 +2138,9 @@ MeasureVariable (
UINTN VarNameLength;
UEFI_VARIABLE_DATA *VarLog;

DEBUG ((DEBUG_INFO, "Tcg2Dxe: MeasureVariable (Pcr - %x, EventType - %x, ", (UINTN)PCRIndex, (UINTN)EventType));
DEBUG ((DEBUG_INFO, "VariableName - %s, VendorGuid - %g)\n", VarName, VendorGuid));
// MU_CHANGE [BEGIN]
DEBUG ((DEBUG_INFO, "PCR[%x] MeasureVariable (EventType(%x), VariableName(%g), VendorGuid(%g))\n", PCRIndex, EventType, VarName, VendorGuid));
// MU_CHANGE [END]

VarNameLength = StrLen (VarName);
TcgEvent.PCRIndex = PCRIndex;
Expand Down

0 comments on commit 9c5ddfc

Please sign in to comment.