OvmfPkg: Add OVMF Mem Debug Log buffer to PEI mem cap/reserve early buffer

Add the memory debug log buffer size (pages) to
TotalPages in PlatformPei:GetPeiMemoryCap() help
ensure we don't run out of memory.

Also Reserve the "early" memory debug log buffer.

Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Aaron Young <aaron.young@oracle.com>
This commit is contained in:
Aaron Young
2025-04-28 09:53:39 -07:00
committed by mergify[bot]
parent b3bc195490
commit 44831e815c
4 changed files with 24 additions and 0 deletions

View File

@@ -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
}
}

View File

@@ -107,5 +107,8 @@
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase
gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogBase
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfEarlyMemDebugLogSize
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdDxeIplSwitchToLongMode

View File

@@ -29,6 +29,7 @@ Module Name:
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
#include <Library/MemDebugLogLib.h>
#include <Library/MemEncryptSevLib.h>
#include <Library/PcdLib.h>
#include <Library/PciLib.h>
@@ -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).

View File

@@ -72,6 +72,7 @@
PlatformInitLib
SmmRelocationLib
TdxHelperLib
MemDebugLogLib
[Pcd]
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase