Skip to content

Commit

Permalink
SecurityPkg: Adding better TCG Logging messages for PCR4
Browse files Browse the repository at this point in the history
This will help with debugging and understanding the flow of the code.
  • Loading branch information
Flickdm committed Feb 4, 2025
1 parent fdafc04 commit cbffb18
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 @@ -2013,6 +2013,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 @@ -2058,7 +2061,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 @@ -2091,8 +2096,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 @@ -2136,8 +2142,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 cbffb18

Please sign in to comment.