OvmfPkg/PlatformPei: remove mPlatformInfoHob

Stop using the mPlatformInfoHob global variable.  Let
BuildPlatformInfoHob() allocate and return PlatformInfoHob instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
This commit is contained in:
Gerd Hoffmann
2022-12-02 14:10:05 +01:00
committed by mergify[bot]
parent 4bc2c74851
commit 862614e254
2 changed files with 39 additions and 36 deletions

View File

@@ -41,8 +41,6 @@
#include "Platform.h" #include "Platform.h"
EFI_HOB_PLATFORM_INFO mPlatformInfoHob = { 0 };
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = { EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
{ {
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@@ -305,12 +303,18 @@ MaxCpuCountInitialization (
/** /**
* @brief Builds PlatformInfo Hob * @brief Builds PlatformInfo Hob
*/ */
VOID EFI_HOB_PLATFORM_INFO *
BuildPlatformInfoHob ( BuildPlatformInfoHob (
VOID VOID
) )
{ {
BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &mPlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO)); 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);
} }
/** /**
@@ -329,69 +333,70 @@ InitializePlatform (
IN CONST EFI_PEI_SERVICES **PeiServices IN CONST EFI_PEI_SERVICES **PeiServices
) )
{ {
EFI_HOB_PLATFORM_INFO *PlatformInfoHob;
EFI_STATUS Status; EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n")); DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
PlatformInfoHob = BuildPlatformInfoHob ();
mPlatformInfoHob.SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire); PlatformInfoHob->SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);
mPlatformInfoHob.SevEsIsEnabled = MemEncryptSevEsIsEnabled (); PlatformInfoHob->SevEsIsEnabled = MemEncryptSevEsIsEnabled ();
mPlatformInfoHob.PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size); PlatformInfoHob->PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size);
mPlatformInfoHob.DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber); PlatformInfoHob->DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
PlatformDebugDumpCmos (); PlatformDebugDumpCmos ();
if (QemuFwCfgS3Enabled ()) { if (QemuFwCfgS3Enabled ()) {
DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n")); DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));
mPlatformInfoHob.S3Supported = TRUE; PlatformInfoHob->S3Supported = TRUE;
Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE); Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE);
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
} }
S3Verification (&mPlatformInfoHob); S3Verification (PlatformInfoHob);
BootModeInitialization (&mPlatformInfoHob); BootModeInitialization (PlatformInfoHob);
// //
// Query Host Bridge DID // Query Host Bridge DID
// //
mPlatformInfoHob.HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID); PlatformInfoHob->HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
AddressWidthInitialization (&mPlatformInfoHob); AddressWidthInitialization (PlatformInfoHob);
MaxCpuCountInitialization (&mPlatformInfoHob); MaxCpuCountInitialization (PlatformInfoHob);
if (mPlatformInfoHob.SmmSmramRequire) { if (PlatformInfoHob->SmmSmramRequire) {
Q35BoardVerification (&mPlatformInfoHob); Q35BoardVerification (PlatformInfoHob);
Q35TsegMbytesInitialization (&mPlatformInfoHob); Q35TsegMbytesInitialization (PlatformInfoHob);
Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob); Q35SmramAtDefaultSmbaseInitialization (PlatformInfoHob);
} }
PublishPeiMemory (&mPlatformInfoHob); PublishPeiMemory (PlatformInfoHob);
PlatformQemuUc32BaseInitialization (&mPlatformInfoHob); PlatformQemuUc32BaseInitialization (PlatformInfoHob);
InitializeRamRegions (&mPlatformInfoHob); InitializeRamRegions (PlatformInfoHob);
if (mPlatformInfoHob.BootMode != BOOT_ON_S3_RESUME) { if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
if (!mPlatformInfoHob.SmmSmramRequire) { if (!PlatformInfoHob->SmmSmramRequire) {
ReserveEmuVariableNvStore (); ReserveEmuVariableNvStore ();
} }
PeiFvInitialization (&mPlatformInfoHob); PeiFvInitialization (PlatformInfoHob);
MemTypeInfoInitialization (&mPlatformInfoHob); MemTypeInfoInitialization (PlatformInfoHob);
MemMapInitialization (&mPlatformInfoHob); MemMapInitialization (PlatformInfoHob);
NoexecDxeInitialization (&mPlatformInfoHob); NoexecDxeInitialization (PlatformInfoHob);
} }
InstallClearCacheCallback (); InstallClearCacheCallback ();
AmdSevInitialize (&mPlatformInfoHob); AmdSevInitialize (PlatformInfoHob);
if (mPlatformInfoHob.HostBridgeDevId == 0xffff) { if (PlatformInfoHob->HostBridgeDevId == 0xffff) {
MiscInitializationForMicrovm (&mPlatformInfoHob); MiscInitializationForMicrovm (PlatformInfoHob);
} else { } else {
MiscInitialization (&mPlatformInfoHob); MiscInitialization (PlatformInfoHob);
} }
IntelTdxInitialize (); IntelTdxInitialize ();
InstallFeatureControlCallback (); InstallFeatureControlCallback ();
BuildPlatformInfoHob ();
return EFI_SUCCESS; return EFI_SUCCESS;
} }

View File

@@ -13,8 +13,6 @@
#include <Library/PlatformInitLib.h> #include <Library/PlatformInitLib.h>
#include <IndustryStandard/IntelTdx.h> #include <IndustryStandard/IntelTdx.h>
extern EFI_HOB_PLATFORM_INFO mPlatformInfoHob;
VOID VOID
AddressWidthInitialization ( AddressWidthInitialization (
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
@@ -98,7 +96,7 @@ IntelTdxInitialize (
/** /**
* @brief Builds PlatformInfo Hob * @brief Builds PlatformInfo Hob
*/ */
VOID EFI_HOB_PLATFORM_INFO *
BuildPlatformInfoHob ( BuildPlatformInfoHob (
VOID VOID
); );