OvmfPkg/PlatformPei: Move global variables to PlatformInfoHob
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 The intention of PlatformInitLib is to extract the common function used in OvmfPkg/PlatformPei. This lib will be used not only in PEI phase but also in SEC phase. SEC phase cannot use global variables between different functions. So PlatformInfoHob is created to hold the informations shared between functions. For example, HostBridgeDevId corespond to mHostBridgeDevId in PlatformPei. In this patch we will first move below global variables to PlatformInfoHob. - mBootMode - mS3Supported - mPhysMemAddressWidth - mMaxCpuCount - mHostBridgeDevId - mQ35SmramAtDefaultSmbase - mQemuUc32Base - mS3AcpiReservedMemorySize - mS3AcpiReservedMemoryBase PlatformInfoHob also holds other information, for example, PciIoBase / PciIoSize. This is because in SEC phase, PcdSetxxx doesn't work. So we will restruct the functions which set PCDs into two, one for PlatformInfoLib, one for PlatformPei. So in this patch we first move global variables and PCDs to PlatformInfoHob. All the changes are in OvmfPkg/PlatformPei. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Brijesh Singh <brijesh.singh@amd.com> Cc: Erdem Aktas <erdemaktas@google.com> Cc: James Bottomley <jejb@linux.ibm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Tom Lendacky <thomas.lendacky@amd.com> Cc: Gerd Hoffmann <kraxel@redhat.com> Cc: Sebastien Boeuf <sebastien.boeuf@intel.com> Acked-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Min Xu <min.m.xu@intel.com>
This commit is contained in:
@@ -228,7 +228,7 @@ AmdSevEsInitialize (
|
||||
// Since the pages must survive across the UEFI to OS transition
|
||||
// make them reserved.
|
||||
//
|
||||
GhcbPageCount = mMaxCpuCount * 2;
|
||||
GhcbPageCount = mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber * 2;
|
||||
GhcbBase = AllocateReservedPages (GhcbPageCount);
|
||||
ASSERT (GhcbBase != NULL);
|
||||
|
||||
@@ -266,7 +266,7 @@ AmdSevEsInitialize (
|
||||
// Allocate #VC recursion backup pages. The number of backup pages needed is
|
||||
// one less than the maximum VC count.
|
||||
//
|
||||
GhcbBackupPageCount = mMaxCpuCount * (VMGEXIT_MAXIMUM_VC_COUNT - 1);
|
||||
GhcbBackupPageCount = mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber * (VMGEXIT_MAXIMUM_VC_COUNT - 1);
|
||||
GhcbBackupBase = AllocatePages (GhcbBackupPageCount);
|
||||
ASSERT (GhcbBackupBase != NULL);
|
||||
|
||||
@@ -367,7 +367,7 @@ AmdSevInitialize (
|
||||
// until after re-encryption, in order to prevent an information leak to the
|
||||
// hypervisor.
|
||||
//
|
||||
if (FeaturePcdGet (PcdSmmSmramRequire) && (mBootMode != BOOT_ON_S3_RESUME)) {
|
||||
if (mPlatformInfoHob.SmmSmramRequire && (mPlatformInfoHob.BootMode != BOOT_ON_S3_RESUME)) {
|
||||
RETURN_STATUS LocateMapStatus;
|
||||
UINTN MapPagesBase;
|
||||
UINTN MapPagesCount;
|
||||
@@ -378,7 +378,7 @@ AmdSevInitialize (
|
||||
);
|
||||
ASSERT_RETURN_ERROR (LocateMapStatus);
|
||||
|
||||
if (mQ35SmramAtDefaultSmbase) {
|
||||
if (mPlatformInfoHob.Q35SmramAtDefaultSmbase) {
|
||||
//
|
||||
// The initial SMRAM Save State Map has been covered as part of a larger
|
||||
// reserved memory allocation in InitializeRamRegions().
|
||||
|
Reference in New Issue
Block a user