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>
@retval 0 Cannot find free memory below 4GB.\r
**/\r
UINTN\r
-GetModeTransitionBuffer (\r
+AllocateCodeBuffer (\r
IN UINTN BufferSize\r
)\r
{\r
(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
@retval 0 Cannot find free memory below 4GB.\r
**/\r
UINTN\r
-GetModeTransitionBuffer (\r
+AllocateCodeBuffer (\r
IN UINTN BufferSize\r
);\r
\r
@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