RELOCATE_AP_LOOP_ENTRY mReservedApLoop;\r
UINTN mReservedTopOfApStack;\r
volatile UINT32 mNumberToFinish = 0;\r
+UINTN mApPageTable;\r
\r
//\r
// Begin wakeup buffer allocation below 0x88000\r
mReservedApLoop.GenericEntry (\r
MwaitSupport,\r
CpuMpData->ApTargetCState,\r
- CpuMpData->PmCodeSegment,\r
StackStart - ProcessorNumber * AP_SAFE_STACK_SIZE,\r
(UINTN)&mNumberToFinish,\r
- CpuMpData->Pm16CodeSegment,\r
- CpuMpData->SevEsAPBuffer,\r
- CpuMpData->WakeupBuffer\r
+ mApPageTable\r
);\r
}\r
\r
EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;\r
UINTN StackBase;\r
CPU_INFO_IN_HOB *CpuInfoInHob;\r
+ MP_ASSEMBLY_ADDRESS_MAP *AddressMap;\r
+ UINT8 *ApLoopFunc;\r
+ UINTN ApLoopFuncSize;\r
UINTN StackPages;\r
UINTN FuncPages;\r
\r
}\r
}\r
\r
+ AddressMap = &CpuMpData->AddressMap;\r
+ if (CpuMpData->UseSevEsAPMethod) {\r
+ //\r
+ // 64-bit AMD processors with SEV-ES\r
+ //\r
+ Address = BASE_4GB - 1;\r
+ ApLoopFunc = AddressMap->RelocateApLoopFuncAddress;\r
+ ApLoopFuncSize = AddressMap->RelocateApLoopFuncSize;\r
+ } else {\r
+ //\r
+ // Intel processors (32-bit or 64-bit), 32-bit AMD processors, or 64-bit AMD processors without SEV-ES\r
+ //\r
+ Address = MAX_ADDRESS;\r
+ ApLoopFunc = AddressMap->RelocateApLoopFuncAddressGeneric;\r
+ ApLoopFuncSize = AddressMap->RelocateApLoopFuncSizeGeneric;\r
+ }\r
+\r
//\r
// Avoid APs access invalid buffer data which allocated by BootServices,\r
// so we will allocate reserved data for AP loop code. We also need to\r
//\r
\r
StackPages = EFI_SIZE_TO_PAGES (CpuMpData->CpuCount * AP_SAFE_STACK_SIZE);\r
- FuncPages = EFI_SIZE_TO_PAGES (CpuMpData->AddressMap.RelocateApLoopFuncSize);\r
-\r
- Address = BASE_4GB - 1;\r
- Status = gBS->AllocatePages (\r
- AllocateMaxAddress,\r
- EfiReservedMemoryType,\r
- StackPages + FuncPages,\r
- &Address\r
- );\r
- ASSERT_EFI_ERROR (Status);\r
+ FuncPages = EFI_SIZE_TO_PAGES (ApLoopFuncSize);\r
\r
- mReservedApLoop.Data = (VOID *)(UINTN)Address;\r
- ASSERT (mReservedApLoop.Data != NULL);\r
+ Status = gBS->AllocatePages (\r
+ AllocateMaxAddress,\r
+ EfiReservedMemoryType,\r
+ StackPages + FuncPages,\r
+ &Address\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
\r
//\r
// Make sure that the buffer memory is executable if NX protection is enabled\r
\r
mReservedTopOfApStack = (UINTN)Address + EFI_PAGES_TO_SIZE (StackPages+FuncPages);\r
ASSERT ((mReservedTopOfApStack & (UINTN)(CPU_STACK_ALIGNMENT - 1)) == 0);\r
- CopyMem (\r
- mReservedApLoop.Data,\r
- CpuMpData->AddressMap.RelocateApLoopFuncAddress,\r
- CpuMpData->AddressMap.RelocateApLoopFuncSize\r
- );\r
+ mReservedApLoop.Data = (VOID *)(UINTN)Address;\r
+ ASSERT (mReservedApLoop.Data != NULL);\r
+ CopyMem (mReservedApLoop.Data, ApLoopFunc, ApLoopFuncSize);\r
+ if (!CpuMpData->UseSevEsAPMethod) {\r
+ //\r
+ // processors without SEV-ES\r
+ //\r
+ mApPageTable = CreatePageTable (\r
+ (UINTN)Address,\r
+ EFI_PAGES_TO_SIZE (StackPages+FuncPages)\r
+ );\r
+ }\r
\r
Status = gBS->CreateEvent (\r
EVT_TIMER | EVT_NOTIFY_SIGNAL,\r