Skip to content

Commit

Permalink
OvmfPkg: Measure firware configuration file data in SEC phase
Browse files Browse the repository at this point in the history
  • Loading branch information
mxu9 committed Apr 14, 2021
1 parent 4dc23f8 commit e66a6bf
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 2 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
34 changes: 34 additions & 0 deletions OvmfPkg/Library/TdxStartupLib/Tcg.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,3 +229,37 @@ TdxMeasureFvImage (
return Status;
}

/**
Measure SystemStates info.
Add it into RTMR[0] after the SystemStates info is measured successfully.
@param[in] Base Base address of SystemStates info.
@param[in] Length Length of SystemStates info.
@param[in] PcrIndex Index of PCR
@retval EFI_SUCCESS SystemStates info is measured successfully
or it has been already measured.
@retval EFI_OUT_OF_RESOURCES No enough memory to log the new event.
@retval EFI_DEVICE_ERROR The command was unsuccessful.
**/
EFI_STATUS
EFIAPI
TdxMeasureSystemStates (
IN EFI_PHYSICAL_ADDRESS Base,
IN UINTN Length,
IN UINT8 PcrIndex
)
{
EFI_STATUS Status;
CHAR8 *ConfigInfoTag = "etc/system-states";

Status = CreateTdxExtendEvent (
PcrIndex, // PCRIndex
EV_PLATFORM_CONFIG_FLAGS, // EventType
(VOID *) ConfigInfoTag, // EventData
sizeof (ConfigInfoTag), // EventSize
(UINT8*) (UINTN) Base, // HashData
(UINTN) Length // HashDataLen
);

return Status;
}

2 changes: 2 additions & 0 deletions OvmfPkg/Library/TdxStartupLib/TdxStartup.c
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,8 @@ TdxStartup(

BuildGuidDataHob (&gUefiOvmfPkgTdxPlatformGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));

TdxMeasureSystemStates ((EFI_PHYSICAL_ADDRESS) &PlatformInfoHob.SystemStates[0], 6, 1);

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

BuildResourceDescriptorHob (
Expand Down
8 changes: 8 additions & 0 deletions OvmfPkg/Library/TdxStartupLib/TdxStartupInternal.h
Original file line number Diff line number Diff line change
Expand Up @@ -194,4 +194,12 @@ AsmGetRelocationMap (
OUT MP_RELOCATION_MAP *AddressMap
);

EFI_STATUS
EFIAPI
TdxMeasureSystemStates (
IN EFI_PHYSICAL_ADDRESS Base,
IN UINT64 Length,
IN UINT8 PcrIndex
);

#endif

0 comments on commit e66a6bf

Please sign in to comment.