diff --git a/OvmfPkg/Library/PeilessStartupLib/PeilessStartup.c b/OvmfPkg/Library/PeilessStartupLib/PeilessStartup.c index 42db1a61cb..2b9566d0ee 100644 --- a/OvmfPkg/Library/PeilessStartupLib/PeilessStartup.c +++ b/OvmfPkg/Library/PeilessStartupLib/PeilessStartup.c @@ -7,6 +7,7 @@ **/ #include +#include #include #include #include @@ -116,6 +117,21 @@ InitializePlatform ( return EFI_SUCCESS; } +STATIC +EFI_HOB_PLATFORM_INFO * +BuildPlatformInfoHob ( + VOID + ) +{ + EFI_HOB_PLATFORM_INFO PlatformInfoHob; + EFI_HOB_GUID_TYPE *GuidHob; + + ZeroMem (&PlatformInfoHob, sizeof PlatformInfoHob); + BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO)); + GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid); + return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob); +} + /** * This function brings up the Tdx guest from SEC phase to DXE phase. * PEI phase is skipped because most of the components in PEI phase @@ -134,7 +150,7 @@ PeilessStartup ( EFI_SEC_PEI_HAND_OFF *SecCoreData; EFI_FIRMWARE_VOLUME_HEADER *BootFv; EFI_STATUS Status; - EFI_HOB_PLATFORM_INFO PlatformInfoHob; + EFI_HOB_PLATFORM_INFO *PlatformInfoHob; UINT32 DxeCodeBase; UINT32 DxeCodeSize; TD_RETURN_DATA TdReturnData; @@ -145,8 +161,6 @@ PeilessStartup ( VmmHobList = NULL; SecCoreData = (EFI_SEC_PEI_HAND_OFF *)Context; - ZeroMem (&PlatformInfoHob, sizeof (PlatformInfoHob)); - if (TdIsEnabled ()) { VmmHobList = (VOID *)(UINTN)FixedPcdGet32 (PcdOvmfSecGhcbBase); Status = TdCall (TDCALL_TDINFO, 0, 0, 0, &TdReturnData); @@ -184,17 +198,17 @@ PeilessStartup ( } } + PlatformInfoHob = BuildPlatformInfoHob (); + // // Initialize the Platform // - Status = InitializePlatform (&PlatformInfoHob); + Status = InitializePlatform (PlatformInfoHob); if (EFI_ERROR (Status)) { ASSERT (FALSE); CpuDeadLoop (); } - BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO)); - // // SecFV //