summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGerd Hoffmann <kraxel@redhat.com>2024-02-14 11:45:02 +0100
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-02-27 13:29:25 +0000
commit8757e648d11357b663331f6ed1cdb2ab017df178 (patch)
tree332fe7764c56b58296034925d80215bf69aad006
parent9d32a02a724c79215a00bb2d2563c7fd026b0726 (diff)
downloadedk2-8757e648d11357b663331f6ed1cdb2ab017df178.tar.gz
edk2-8757e648d11357b663331f6ed1cdb2ab017df178.tar.bz2
edk2-8757e648d11357b663331f6ed1cdb2ab017df178.zip
OvmfPkg/PlatformPei: consider AP stacks for pei memory cap
Needed to avoid running out of memory when booting with a large (~2048) number of vcpus. Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20240214104504.2931339-3-kraxel@redhat.com>
-rw-r--r--OvmfPkg/PlatformPei/MemDetect.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index e0ecca10b6..d6c46ffc89 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -187,6 +187,8 @@ GetPeiMemoryCap (
UINT32 Pml4Entries;
UINT32 PdpEntries;
UINTN TotalPages;
+ UINT64 ApStacks;
+ UINT64 MemoryCap;
//
// If DXE is 32-bit, then just return the traditional 64 MB cap.
@@ -235,11 +237,20 @@ GetPeiMemoryCap (
ASSERT (TotalPages <= 0x40201);
//
+ // With 32k stacks and 4096 vcpus this lands at 128 MB (far away
+ // from MAX_UINT32).
+ //
+ ApStacks = PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber * PcdGet32 (PcdCpuApStackSize);
+
+ //
// Add 64 MB for miscellaneous allocations. Note that for
- // PhysMemAddressWidth values close to 36, the cap will actually be
- // dominated by this increment.
+ // PhysMemAddressWidth values close to 36 and a small number of
+ // CPUs, the cap will actually be dominated by this increment.
//
- return (UINT32)(EFI_PAGES_TO_SIZE (TotalPages) + SIZE_64MB);
+ MemoryCap = EFI_PAGES_TO_SIZE (TotalPages) + ApStacks + SIZE_64MB;
+
+ ASSERT (MemoryCap <= MAX_UINT32);
+ return (UINT32)MemoryCap;
}
/**