summaryrefslogtreecommitdiffstats
path: root/UefiCpuPkg/Library/MpInitLib/MpLib.h
diff options
context:
space:
mode:
authorXie, Yuanhao <yuanhao.xie@intel.com>2023-03-01 14:09:52 +0800
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2023-03-07 08:14:59 +0000
commitfacf52aeb8accb312acfd34b60266d4ea866afbb (patch)
tree45874e3cb7bfd3cb2a1723b9b1a02f622bdf0b86 /UefiCpuPkg/Library/MpInitLib/MpLib.h
parent6bc74286e7f57d6c7bd29a7b5e4eb8026c5a8012 (diff)
downloadedk2-facf52aeb8accb312acfd34b60266d4ea866afbb.tar.gz
edk2-facf52aeb8accb312acfd34b60266d4ea866afbb.tar.bz2
edk2-facf52aeb8accb312acfd34b60266d4ea866afbb.zip
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>
Diffstat (limited to 'UefiCpuPkg/Library/MpInitLib/MpLib.h')
-rw-r--r--UefiCpuPkg/Library/MpInitLib/MpLib.h43
1 files changed, 40 insertions, 3 deletions
diff --git a/UefiCpuPkg/Library/MpInitLib/MpLib.h b/UefiCpuPkg/Library/MpInitLib/MpLib.h
index 81a95733fc..e137545fc6 100644
--- a/UefiCpuPkg/Library/MpInitLib/MpLib.h
+++ b/UefiCpuPkg/Library/MpInitLib/MpLib.h
@@ -177,6 +177,8 @@ typedef struct {
UINT8 *RendezvousFunnelAddress;
UINTN ModeEntryOffset;
UINTN RendezvousFunnelSize;
+ UINT8 *RelocateApLoopFuncAddressGeneric;
+ UINTN RelocateApLoopFuncSizeGeneric;
UINT8 *RelocateApLoopFuncAddress;
UINTN RelocateApLoopFuncSize;
UINTN ModeTransitionOffset;
@@ -363,6 +365,29 @@ extern EFI_GUID mCpuInitMpLibHobGuid;
**/
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)(
IN BOOLEAN MwaitSupport,
IN UINTN ApTargetCState,
@@ -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;
/**
@@ -472,6 +497,18 @@ GetSevEsAPMemory (
);
/**
+ 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.
@param[in] CpuMpData Pointer to CPU MP Data