* [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder
@ 2020-12-09 11:27 Zeng, Star
2020-12-11 10:37 ` Ni, Ray
0 siblings, 1 reply; 2+ messages in thread
From: Zeng, Star @ 2020-12-09 11:27 UTC (permalink / raw)
To: devel; +Cc: Star Zeng, Ray Ni, Eric Dong, Laszlo Ersek
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>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
---
.../Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
index d4a576385f0f..ba052732a86c 100644
--- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
+++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
@@ -126,8 +126,9 @@ CpuInitDataInitialize (
GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);
- CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);
+ CpuFeaturesData->InitOrder = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus));
ASSERT (CpuFeaturesData->InitOrder != NULL);
+ ZeroMem (CpuFeaturesData->InitOrder, sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);
//
// Collect CPU Features information
--
2.21.0.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder
2020-12-09 11:27 [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder Zeng, Star
@ 2020-12-11 10:37 ` Ni, Ray
0 siblings, 0 replies; 2+ messages in thread
From: Ni, Ray @ 2020-12-11 10:37 UTC (permalink / raw)
To: Zeng, Star, devel@edk2.groups.io; +Cc: Dong, Eric, Laszlo Ersek
Reviewed-by: Ray Ni <ray.ni@intel.com>
> -----Original Message-----
> From: Zeng, Star <star.zeng@intel.com>
> Sent: Wednesday, December 9, 2020 7:28 PM
> To: devel@edk2.groups.io
> Cc: Zeng, Star <star.zeng@intel.com>; Ni, Ray <ray.ni@intel.com>; Dong, Eric <eric.dong@intel.com>; Laszlo Ersek
> <lersek@redhat.com>
> Subject: [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder
>
> 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>
> Cc: Ray Ni <ray.ni@intel.com>
> Cc: Eric Dong <eric.dong@intel.com>
> Cc: Laszlo Ersek <lersek@redhat.com>
> ---
> .../Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> index d4a576385f0f..ba052732a86c 100644
> --- a/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> +++ b/UefiCpuPkg/Library/RegisterCpuFeaturesLib/CpuFeaturesInitialize.c
> @@ -126,8 +126,9 @@ CpuInitDataInitialize (
>
> GetNumberOfProcessor (&NumberOfCpus, &NumberOfEnabledProcessors);
>
> - CpuFeaturesData->InitOrder = AllocateZeroPool (sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);
> + CpuFeaturesData->InitOrder = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (CPU_FEATURES_INIT_ORDER) *
> NumberOfCpus));
> ASSERT (CpuFeaturesData->InitOrder != NULL);
> + ZeroMem (CpuFeaturesData->InitOrder, sizeof (CPU_FEATURES_INIT_ORDER) * NumberOfCpus);
>
> //
> // Collect CPU Features information
> --
> 2.21.0.windows.1
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-12-11 10:37 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-09 11:27 [PATCH] UefiCpuPkg RegisterCpuFeaturesLib: Use AllocatePages() for InitOrder Zeng, Star
2020-12-11 10:37 ` Ni, Ray
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox