]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder
authorStar Zeng <star.zeng@intel.com>
Tue, 8 Dec 2020 10:38:44 +0000 (18:38 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 14 Dec 2020 05:49:50 +0000 (05:49 +0000)
The required buffer size for InitOrder will be 96K when NumberOfCpus=1024.
sizeof (CPU_FEATURES_INIT_ORDER) = 96
NumberOfCpus = 1024 = 1K
sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus = 96K

AllocateZeroPool() will call to PeiServicesAllocatePool() which will use
EFI_HOB_MEMORY_POOL to management memory pool.
EFI_HOB_MEMORY_POOL.Header.HobLength is UINT16 type, so there is no way
for AllocateZeroPool() to allocate > 64K memory.

So AllocateZeroPool() could not be used anymore for the case above or
even bigger required buffer size.

This patch updates the code to use AllocatePages() instead of
AllocateZeroPool() to allocate buffer for InitOrder.

Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c

index d4a576385f0fcb5653806e5b22d937e7af2ed202..ba052732a86c324ededa82610f817f3fa1b0b701 100644 (file)
@@ -126,8 +126,9 @@ CpuInitDataInitialize (
 \r
   GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);\r
 \r
-  CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);\r
+  CpuFeaturesData->InitOrder = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus));\r
   ASSERT (CpuFeaturesData->InitOrder != NULL);\r
+  ZeroMem (CpuFeaturesData->InitOrder, sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);\r
 \r
   //\r
   // Collect CPU Features information\r