]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MpInitLib: Allocate code buffer for PEI phase
authorRay Ni <ray.ni@intel.com>
Sat, 7 May 2022 09:10:49 +0000 (17:10 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Fri, 10 Jun 2022 12:15:49 +0000 (12:15 +0000)
Today's implementation assumes PEI phase runs at 32bit so
the execution-disable feature is not applicable.
It's not always TRUE.
The patch allocates 32bit&64bit code buffer for PEI phase as well.

Signed-off-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Eric Dong <eric.dong@intel.com>
UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.c
UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/Library/MpInitLib/PeiMpLib.c

index 60d14a5a0e101e7c71c368903bc3c9390f110833..78cc3e2b93fdf6934aee1539e0cd127ed7990eff 100644 (file)
@@ -162,7 +162,7 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.\r
 **/\r
 UINTN\r
-GetModeTransitionBuffer (\r
+AllocateCodeBuffer (\r
   IN UINTN  BufferSize\r
   )\r
 {\r
index 4a73787ee43a649548e05964f6b04f24b059c83f..d761bdc4878f5187cb776de53d0883794289662f 100644 (file)
@@ -1056,7 +1056,7 @@ AllocateResetVector (
                                    (CpuMpData->WakeupBuffer +\r
                                     CpuMpData->AddressMap.RendezvousFunnelSize +\r
                                     CpuMpData->AddressMap.SwitchToRealSize);\r
-    CpuMpData->WakeupBufferHigh = GetModeTransitionBuffer (\r
+    CpuMpData->WakeupBufferHigh = AllocateCodeBuffer (\r
                                     CpuMpData->AddressMap.RendezvousFunnelSize +\r
                                     CpuMpData->AddressMap.SwitchToRealSize -\r
                                     CpuMpData->AddressMap.ModeTransitionOffset\r
index f8c52426dd5f090535b701cb29775987f68d2e22..59ab96089759e80e9867eefb2f446c22e0a4acdf 100644 (file)
@@ -442,7 +442,7 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.\r
 **/\r
 UINTN\r
-GetModeTransitionBuffer (\r
+AllocateCodeBuffer (\r
   IN UINTN  BufferSize\r
   );\r
 \r
index efce5747277a2b6d507ebcad5d1d4f002b4e7701..65400b95a237de7944c8edf3451c51a4591151c9 100644 (file)
@@ -299,14 +299,19 @@ GetWakeupBuffer (
   @retval 0       Cannot find free memory below 4GB.\r
 **/\r
 UINTN\r
-GetModeTransitionBuffer (\r
+AllocateCodeBuffer (\r
   IN UINTN  BufferSize\r
   )\r
 {\r
-  //\r
-  // PEI phase doesn't need to do such transition. So simply return 0.\r
-  //\r
-  return 0;\r
+  EFI_STATUS            Status;\r
+  EFI_PHYSICAL_ADDRESS  Address;\r
+\r
+  Status = PeiServicesAllocatePages (EfiBootServicesCode, EFI_SIZE_TO_PAGES (BufferSize), &Address);\r
+  if (EFI_ERROR (Status)) {\r
+    Address = 0;\r
+  }\r
+\r
+  return (UINTN)Address;\r
 }\r
 \r
 /**\r