From: Min M Xu <[email protected]> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4181
With the introduce of PcdAcceptMemoryEndAddress, TDVF may accept less memory than LowerMemorySizse. So it should be adjusted in PublishPeiMemory(). Cc: Erdem Aktas <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: James Bottomley <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Tom Lendacky <[email protected]> Signed-off-by: Min Xu <[email protected]> --- OvmfPkg/PlatformPei/MemDetect.c | 13 +++++++++++++ OvmfPkg/PlatformPei/PlatformPei.inf | 1 + 2 files changed, 14 insertions(+) diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index 3d8375320dcb..12a1ad46f1ca 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -270,8 +270,21 @@ PublishPeiMemory ( UINT32 PeiMemoryCap; UINT32 S3AcpiReservedMemoryBase; UINT32 S3AcpiReservedMemorySize; + UINT64 AcceptMemoryEndAddress; LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob); + + // + // In Tdx guest there may be less memory accepted than LowerMemorySize. + // So LowerMemorySize need to be adjusted accordingly. + // + if (TdIsEnabled ()) { + AcceptMemoryEndAddress = FixedPcdGet64 (PcdAcceptMemoryEndAddress); + if ((AcceptMemoryEndAddress < SIZE_4GB) && (LowerMemorySize > (UINT32)(UINTN)AcceptMemoryEndAddress)) { + LowerMemorySize = (UINT32)(UINTN)AcceptMemoryEndAddress; + } + } + if (PlatformInfoHob->SmmSmramRequire) { // // TSEG is chipped from the end of low RAM diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 1fadadeb5565..c87d2fa25c08 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -130,6 +130,7 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsBase gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSnpSecretsSize + gUefiOvmfPkgTokenSpaceGuid.PcdAcceptMemoryEndAddress [FeaturePcd] gUefiOvmfPkgTokenSpaceGuid.PcdCsmEnable -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#97753): https://edk2.groups.io/g/devel/message/97753 Mute This Topic: https://groups.io/mt/95882250/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
