edk2/0027-OvmfPkg-PlatformPei-remove-mPlatformInfoHob.patch

178 lines
6.2 KiB
Diff
Raw Normal View History

From 0aa971e9b02ff1b380c5363a5a543bc4e2b9532f Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Fri, 2 Dec 2022 14:10:05 +0100
Subject: [PATCH 27/32] 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>
(cherry picked from commit 862614e2544997c848fab7388733774ae0ea92d8)
---
OvmfPkg/PlatformPei/Platform.h | 4 +-
OvmfPkg/PlatformPei/Platform.c | 71 ++++++++++++++++++----------------
2 files changed, 39 insertions(+), 36 deletions(-)
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 0c0558f0626c..86f603ff649c 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -13,8 +13,6 @@
#include <Library/PlatformInitLib.h>
#include <IndustryStandard/IntelTdx.h>
-extern EFI_HOB_PLATFORM_INFO mPlatformInfoHob;
-
VOID
AddressWidthInitialization (
IN OUT EFI_HOB_PLATFORM_INFO *PlatformInfoHob
@@ -98,7 +96,7 @@ IntelTdxInitialize (
/**
* @brief Builds PlatformInfo Hob
*/
-VOID
+EFI_HOB_PLATFORM_INFO *
BuildPlatformInfoHob (
VOID
);
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 6e31c5fc1f41..ee72b4ef24aa 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -53,8 +53,6 @@
} \
} while (0)
-EFI_HOB_PLATFORM_INFO mPlatformInfoHob = { 0 };
-
EFI_PEI_PPI_DESCRIPTOR mPpiBootMode[] = {
{
EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
@@ -317,12 +315,18 @@ MaxCpuCountInitialization (
/**
* @brief Builds PlatformInfo Hob
*/
-VOID
+EFI_HOB_PLATFORM_INFO *
BuildPlatformInfoHob (
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);
}
/**
@@ -341,70 +345,71 @@ InitializePlatform (
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
- EFI_STATUS Status;
+ EFI_HOB_PLATFORM_INFO *PlatformInfoHob;
+ EFI_STATUS Status;
DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));
+ PlatformInfoHob = BuildPlatformInfoHob ();
- mPlatformInfoHob.SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);
- mPlatformInfoHob.SevEsIsEnabled = MemEncryptSevEsIsEnabled ();
- mPlatformInfoHob.PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size);
- mPlatformInfoHob.DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
+ PlatformInfoHob->SmmSmramRequire = FeaturePcdGet (PcdSmmSmramRequire);
+ PlatformInfoHob->SevEsIsEnabled = MemEncryptSevEsIsEnabled ();
+ PlatformInfoHob->PcdPciMmio64Size = PcdGet64 (PcdPciMmio64Size);
+ PlatformInfoHob->DefaultMaxCpuNumber = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);
PlatformDebugDumpCmos ();
if (QemuFwCfgS3Enabled ()) {
DEBUG ((DEBUG_INFO, "S3 support was detected on QEMU\n"));
- mPlatformInfoHob.S3Supported = TRUE;
+ PlatformInfoHob->S3Supported = TRUE;
Status = PcdSetBoolS (PcdAcpiS3Enable, TRUE);
ASSERT_EFI_ERROR (Status);
}
- S3Verification (&mPlatformInfoHob);
- BootModeInitialization (&mPlatformInfoHob);
+ S3Verification (PlatformInfoHob);
+ BootModeInitialization (PlatformInfoHob);
//
// Query Host Bridge DID
//
- mPlatformInfoHob.HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
- AddressWidthInitialization (&mPlatformInfoHob);
+ PlatformInfoHob->HostBridgeDevId = PciRead16 (OVMF_HOSTBRIDGE_DID);
+ AddressWidthInitialization (PlatformInfoHob);
- MaxCpuCountInitialization (&mPlatformInfoHob);
+ MaxCpuCountInitialization (PlatformInfoHob);
- if (mPlatformInfoHob.SmmSmramRequire) {
- Q35BoardVerification (&mPlatformInfoHob);
- Q35TsegMbytesInitialization (&mPlatformInfoHob);
- Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);
+ if (PlatformInfoHob->SmmSmramRequire) {
+ Q35BoardVerification (PlatformInfoHob);
+ Q35TsegMbytesInitialization (PlatformInfoHob);
+ Q35SmramAtDefaultSmbaseInitialization (PlatformInfoHob);
}
- PublishPeiMemory (&mPlatformInfoHob);
+ PublishPeiMemory (PlatformInfoHob);
- PlatformQemuUc32BaseInitialization (&mPlatformInfoHob);
+ PlatformQemuUc32BaseInitialization (PlatformInfoHob);
- InitializeRamRegions (&mPlatformInfoHob);
+ InitializeRamRegions (PlatformInfoHob);
- if (mPlatformInfoHob.BootMode != BOOT_ON_S3_RESUME) {
- if (!mPlatformInfoHob.SmmSmramRequire) {
+ if (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME) {
+ if (!PlatformInfoHob->SmmSmramRequire) {
ReserveEmuVariableNvStore ();
}
- PeiFvInitialization (&mPlatformInfoHob);
- MemTypeInfoInitialization (&mPlatformInfoHob);
- MemMapInitialization (&mPlatformInfoHob);
- NoexecDxeInitialization (&mPlatformInfoHob);
+ PeiFvInitialization (PlatformInfoHob);
+ MemTypeInfoInitialization (PlatformInfoHob);
+ MemMapInitialization (PlatformInfoHob);
+ NoexecDxeInitialization (PlatformInfoHob);
UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm);
}
InstallClearCacheCallback ();
- AmdSevInitialize (&mPlatformInfoHob);
- if (mPlatformInfoHob.HostBridgeDevId == 0xffff) {
- MiscInitializationForMicrovm (&mPlatformInfoHob);
+ AmdSevInitialize (PlatformInfoHob);
+ if (PlatformInfoHob->HostBridgeDevId == 0xffff) {
+ MiscInitializationForMicrovm (PlatformInfoHob);
} else {
- MiscInitialization (&mPlatformInfoHob);
+ MiscInitialization (PlatformInfoHob);
}
IntelTdxInitialize ();
InstallFeatureControlCallback ();
- BuildPlatformInfoHob ();
return EFI_SUCCESS;
}
--
2.38.1