From e03b0d06726c0a2c3fa4a6aff43a8c584172767b Mon Sep 17 00:00:00 2001 From: Sebastien Boeuf Date: Thu, 15 Dec 2022 23:10:02 +0800 Subject: [PATCH] OvmfPkg/PlatformInitLib: Differentiate TDX case for Cloud Hypervisor Rely on the CcProbe() function to identify when running on TDX. This allows the firmware to follow a different codepath for Cloud Hypervisor, which means it doesn't rely on PVH to find out about memory below 4GiB. instead it falls back onto the CMOS to retrieve that information. Signed-off-by: Sebastien Boeuf Reviewed-by: Min Xu Reviewed-by: Jiewen Yao --- OvmfPkg/Library/PlatformInitLib/MemDetect.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index b8feae4309..6dbdbf9306 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -26,6 +26,7 @@ Module Name: // #include #include +#include #include #include #include @@ -312,7 +313,9 @@ PlatformGetSystemMemorySizeBelow4gb ( UINT8 Cmos0x34; UINT8 Cmos0x35; - if (PlatformInfoHob->HostBridgeDevId == CLOUDHV_DEVICE_ID) { + if ((PlatformInfoHob->HostBridgeDevId == CLOUDHV_DEVICE_ID) && + (CcProbe () != CcGuestTypeIntelTdx)) + { // Get the information from PVH memmap return (UINT32)GetHighestSystemMemoryAddressFromPvhMemmap (TRUE); }