UefiCpuPkg: Put APs in 64 bit mode before handoff to OS.

Add the 'AsmRelocateApLoopStartGeneric' for X64 processors except 64-bit
 AMD processors with SEV-ES.

Remove the unused arguments of AsmRelocateApLoopStartGeneric, updated
the stack offset.

Create PageTable for the allocated reserved memory.

Only keep 4GB limitation of memory allocation for the case APs still
need to be transferred to 32-bit mode before OS.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Cc: James Lu <james.lu@intel.com>
Cc: Gua Guo <gua.guo@intel.com>
Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
This commit is contained in:
Xie, Yuanhao
2023-03-01 14:09:52 +08:00
committed by mergify[bot]
parent 6bc74286e7
commit facf52aeb8
8 changed files with 272 additions and 48 deletions

View File

@@ -177,6 +177,8 @@ typedef struct {
UINT8 *RendezvousFunnelAddress;
UINTN ModeEntryOffset;
UINTN RendezvousFunnelSize;
UINT8 *RelocateApLoopFuncAddressGeneric;
UINTN RelocateApLoopFuncSizeGeneric;
UINT8 *RelocateApLoopFuncAddress;
UINTN RelocateApLoopFuncSize;
UINTN ModeTransitionOffset;
@@ -361,6 +363,29 @@ extern EFI_GUID mCpuInitMpLibHobGuid;
@param[in] ApTargetCState Target C-State value.
@param[in] PmCodeSegment Protected mode code segment value.
**/
typedef
VOID
(EFIAPI *ASM_RELOCATE_AP_LOOP_GENERIC)(
IN BOOLEAN MwaitSupport,
IN UINTN ApTargetCState,
IN UINTN TopOfApStack,
IN UINTN NumberToFinish,
IN UINTN Cr3
);
/**
Assembly code to place AP into safe loop mode for Amd processors
with Sev enabled.
Place AP into targeted C-State if MONITOR is supported, otherwise
place AP into hlt state.
Place AP in protected mode if the current is long mode. Due to AP maybe
wakeup by some hardware event. It could avoid accessing page table that
may not available during booting to OS.
@param[in] MwaitSupport TRUE indicates MONITOR is supported.
FALSE indicates MONITOR is not supported.
@param[in] ApTargetCState Target C-State value.
@param[in] PmCodeSegment Protected mode code segment value.
**/
typedef
VOID
(EFIAPI *ASM_RELOCATE_AP_LOOP)(
@@ -403,9 +428,9 @@ AsmExchangeRole (
);
typedef union {
VOID *Data;
ASM_RELOCATE_AP_LOOP AmdSevEntry; // 64-bit AMD Sev processors
ASM_RELOCATE_AP_LOOP GenericEntry; // Intel processors (32-bit or 64-bit), 32-bit AMD processors, or AMD non-Sev processors
VOID *Data;
ASM_RELOCATE_AP_LOOP AmdSevEntry; // 64-bit AMD Sev processors
ASM_RELOCATE_AP_LOOP_GENERIC GenericEntry; // Intel processors (32-bit or 64-bit), 32-bit AMD processors, or AMD non-Sev processors
} RELOCATE_AP_LOOP_ENTRY;
/**
@@ -471,6 +496,18 @@ GetSevEsAPMemory (
VOID
);
/**
Create 1:1 mapping page table in reserved memory to map the specified address range.
@param[in] LinearAddress The start of the linear address range.
@param[in] Length The length of the linear address range.
@return The page table to be created.
**/
UINTN
CreatePageTable (
IN UINTN Address,
IN UINTN Length
);
/**
This function will be called by BSP to wakeup AP.