diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index 78a8e0de34..886d236226 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -42,6 +42,17 @@ UINT8 mPhysMemAddressWidth; STATIC UINT32 mS3AcpiReservedMemoryBase; STATIC UINT32 mS3AcpiReservedMemorySize; +STATIC UINT16 mQ35TsegMbytes; + +VOID +Q35TsegMbytesInitialization ( + VOID + ) +{ + mQ35TsegMbytes = PcdGet16 (PcdQ35TsegMbytes); +} + + UINT32 GetSystemMemorySizeBelow4gb ( VOID @@ -348,7 +359,7 @@ PublishPeiMemory ( // // TSEG is chipped from the end of low RAM // - LowerMemorySize -= FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB; + LowerMemorySize -= mQ35TsegMbytes * SIZE_1MB; } // @@ -456,7 +467,7 @@ QemuInitializeRam ( if (FeaturePcdGet (PcdSmmSmramRequire)) { UINT32 TsegSize; - TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB; + TsegSize = mQ35TsegMbytes * SIZE_1MB; AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize); AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize, TRUE); @@ -605,7 +616,7 @@ InitializeRamRegions ( // Make sure the TSEG area that we reported as a reserved memory resource // cannot be used for reserved memory allocations. // - TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB; + TsegSize = mQ35TsegMbytes * SIZE_1MB; BuildMemoryAllocationHob ( GetSystemMemorySizeBelow4gb() - TsegSize, TsegSize, diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 3e9fda7c7a..b8a28450d6 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -645,6 +645,10 @@ InitializePlatform ( AddressWidthInitialization (); MaxCpuCountInitialization (); + if (FeaturePcdGet (PcdSmmSmramRequire)) { + Q35TsegMbytesInitialization (); + } + PublishPeiMemory (); InitializeRamRegions (); diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 18f42c3f0e..d2d627b221 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -53,6 +53,11 @@ AddressWidthInitialization ( VOID ); +VOID +Q35TsegMbytesInitialization ( + VOID + ); + EFI_STATUS PublishPeiMemory ( VOID