]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuMp: Fix hang when StackGuard is enabled in 16-core cpu
authorRay Ni <ray.ni@intel.com>
Fri, 22 Jan 2021 02:45:02 +0000 (10:45 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 22 Jan 2021 03:23:53 +0000 (03:23 +0000)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3167

When StackGuard is enabled, the CpuMp driver allocates
known good stacks for all CPUs for DF# and PF# exceptions.
It uses AllocatePool to do so.

The size needed equals to 64KB
= StackSize (2K) * ExceptionNumber (2) * NumberOfProcessors (16)

However, AllocatePool max allocation size is less than 64K.
To fix the issue, AllocatePages() is used.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
UefiCpuPkg/CpuMpPei/CpuMpPei.c
UefiCpuPkg/CpuMpPei/CpuMpPei.h
UefiCpuPkg/CpuMpPei/CpuMpPei.inf

index d07540cf747126b6ae32e32a15021135ac1146c0..40729a09b9eec651c7ea2c2632ec9f0e34e4917a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU PEI Module installs CPU Multiple Processor PPI.\r
 \r
-  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -532,13 +532,9 @@ InitializeMpExceptionStackSwitchHandlers (
   ExceptionNumber = FixedPcdGetSize (PcdCpuStackSwitchExceptionList);\r
   NewStackSize = FixedPcdGet32 (PcdCpuKnownGoodStackSize) * ExceptionNumber;\r
 \r
-  Status = PeiServicesAllocatePool (\r
-             NewStackSize * NumberOfProcessors,\r
-             (VOID **)&StackTop\r
-             );\r
+  StackTop = AllocatePages (EFI_SIZE_TO_PAGES (NewStackSize * NumberOfProcessors));\r
   ASSERT(StackTop != NULL);\r
-  if (EFI_ERROR (Status)) {\r
-    ASSERT_EFI_ERROR (Status);\r
+  if (StackTop == NULL) {\r
     return;\r
   }\r
   StackTop += NewStackSize  * NumberOfProcessors;\r
index 6a481a84dcc7dbb20bd35392f5679695bda66827..c6870656ca645117b29478c82b9de76fab23c9d1 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definitions to install Multiple Processor PPI.\r
 \r
-  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -27,6 +27,7 @@
 #include <Library/CpuExceptionHandlerLib.h>\r
 #include <Library/MpInitLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 extern EFI_PEI_PPI_DESCRIPTOR   mPeiCpuMpPpiDesc;\r
 \r
index 7e511325d8b8bed18413759dbe5cd4dabe46edcd..ba829d816ee47c2b107f4b6ab659c41a036066b3 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  CPU driver installs CPU PI Multi-processor PPI.\r
 #\r
-#  Copyright (c) 2015 - 2019, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2015 - 2021, Intel Corporation. All rights reserved.<BR>\r
 #  SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 ##\r
@@ -45,6 +45,7 @@
   MpInitLib\r
   BaseMemoryLib\r
   CpuLib\r
+  MemoryAllocationLib\r
 \r
 [Guids]\r
   gEdkiiMigratedFvInfoGuid                                             ## SOMETIMES_CONSUMES     ## HOB\r