Skip to content

Commit

Permalink
OvmfPkg: Measure QemuCfg SystemStates in SEC
Browse files Browse the repository at this point in the history
  • Loading branch information
mxu9 committed Apr 15, 2021
1 parent a8648bb commit 75d6d78
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 3 deletions.
4 changes: 2 additions & 2 deletions OvmfPkg/Include/Library/TdvfPlatformLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include <Library/HobLib.h>

#define EFI_RESOURCE_ATTRIBUTE_ENCRYPTED 0x04000000

#pragma pack(1)
typedef struct {
///
EFI_HOB_GUID_TYPE GuidHeader;
Expand All @@ -17,7 +17,7 @@ typedef struct {
BOOLEAN SetNxForStack;
UINT8 SystemStates[6];
} EFI_HOB_PLATFORM_INFO;

#pragma pack()
VOID
EFIAPI
TdvfPlatformInitialize (
Expand Down
22 changes: 22 additions & 0 deletions OvmfPkg/Library/TdxStartupLib/Tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,25 @@ TdxMeasureFvImage (
return Status;
}

EFI_STATUS
MeasureQemuCfgSystemSts (
IN TCG_PCRINDEX PCRIndex,
IN UINT8 *HashData,
IN UINTN HashDataLength
)
{
EFI_STATUS Status;
CHAR8 *Item = "etc/system-states";

Status = CreateTdxExtendEvent (
PCRIndex, // PCRIndex
EV_PLATFORM_CONFIG_FLAGS, // EventType
(UINT8*)Item, // EventData
AsciiStrLen(Item), // EventSize
HashData, // HashData
HashDataLength // HashDataLen
);

return Status;
}

4 changes: 3 additions & 1 deletion OvmfPkg/Library/TdxStartupLib/TdxStartup.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ TdxStartup(
UINT32 DxeCodeBase;
UINT32 DxeCodeSize;
TD_RETURN_DATA TdReturnData;
UINT8 *PlatformInfoPtr;

Status = EFI_SUCCESS;
BootFv = NULL;
Expand Down Expand Up @@ -224,7 +225,8 @@ TdxStartup(

MeasureConfigurationVolume ((UINT64)(UINTN)PcdGet32 (PcdCfvBase));

BuildGuidDataHob (&gUefiOvmfPkgTdxPlatformGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));
PlatformInfoPtr = (UINT8*)BuildGuidDataHob (&gUefiOvmfPkgTdxPlatformGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));
MeasureQemuCfgSystemSts (1, PlatformInfoPtr + sizeof(EFI_HOB_PLATFORM_INFO) - 6, 6);

BuildStackHob ((UINTN)SecCoreData->StackBase, SecCoreData->StackSize <<=1 );

Expand Down
7 changes: 7 additions & 0 deletions OvmfPkg/Library/TdxStartupLib/TdxStartupInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,13 @@ CreateTdxExtendEvent (
IN UINTN HashDataLen
);

EFI_STATUS
MeasureQemuCfgSystemSts (
IN TCG_PCRINDEX PCRIndex,
IN UINT8 *HashData,
IN UINTN HashDataLength
);

VOID
EFIAPI
AsmGetRelocationMap (
Expand Down

0 comments on commit 75d6d78

Please sign in to comment.