diff --git a/OvmfPkg/Library/PlatformInitLib/MemDetect.c b/OvmfPkg/Library/PlatformInitLib/MemDetect.c index 44b2e0d24f..17eaff3160 100644 --- a/OvmfPkg/Library/PlatformInitLib/MemDetect.c +++ b/OvmfPkg/Library/PlatformInitLib/MemDetect.c @@ -1504,6 +1504,20 @@ PlatformQemuInitializeRamForS3 ( ); } + if (FixedPcdGet32 (PcdOvmfEarlyMemDebugLogSize) != 0) { + // + // Reserve the Early Memory Debug Log buffer + // + // Since this memory range will be used on S3 resume, it must be + // reserved as ACPI NVS. + // + BuildMemoryAllocationHob ( + (EFI_PHYSICAL_ADDRESS)(UINTN)FixedPcdGet32 (PcdOvmfEarlyMemDebugLogBase), + (UINT64)(UINTN)FixedPcdGet32 (PcdOvmfEarlyMemDebugLogSize), + PlatformInfoHob->S3Supported ? EfiACPIMemoryNVS : EfiBootServicesData + ); + } + #endif } } diff --git a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf index c79b2ee106..fe46dc0717 100644 --- a/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf +++ b/OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf @@ -107,5 +107,8 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogSize + [FeaturePcd] gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c index 04409b28ba..19137df7fb 100644 --- a/OvmfPkg/PlatformPei/MemDetect.c +++ b/OvmfPkg/PlatformPei/MemDetect.c @@ -29,6 +29,7 @@ Module Name: #include #include #include +#include #include #include #include @@ -250,6 +251,11 @@ GetPeiMemoryCap ( ASSERT (TotalPages <= 0x404); } + // + // Add Memory Debug Log Buffer Pages (which can large) + // + TotalPages += MemDebugLogPages (); + // // With 32k stacks and 4096 vcpus this lands at 128 MB (far away // from MAX_UINT32). diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf index 1b2af6f3e6..1f1616c569 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -72,6 +72,7 @@ PlatformInitLib SmmRelocationLib TdxHelperLib + MemDebugLogLib [Pcd] gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase