]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg: Duplicated AsmRelocateApLoop as AsmRelocateApLoopAmd
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
index a84e9e33bafab03cefbd6fdc6883f0b22873a53c..445e0853d2fb4b90339b05fcf8a88240221c62f2 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   MP initialize support functions for DXE phase.\r
 \r
-  Copyright (c) 2016 - 2020, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2016 - 2022, Intel Corporation. All rights reserved.<BR>\r
   SPDX-License-Identifier: BSD-2-Clause-Patent\r
 \r
 **/\r
@@ -378,32 +378,44 @@ RelocateApLoop (
   IN OUT VOID  *Buffer\r
   )\r
 {\r
-  CPU_MP_DATA           *CpuMpData;\r
-  BOOLEAN               MwaitSupport;\r
-  ASM_RELOCATE_AP_LOOP  AsmRelocateApLoopFunc;\r
-  UINTN                 ProcessorNumber;\r
-  UINTN                 StackStart;\r
+  CPU_MP_DATA               *CpuMpData;\r
+  BOOLEAN                   MwaitSupport;\r
+  ASM_RELOCATE_AP_LOOP      AsmRelocateApLoopFunc;\r
+  ASM_RELOCATE_AP_LOOP_AMD  AsmRelocateApLoopFuncAmd;\r
+  UINTN                     ProcessorNumber;\r
+  UINTN                     StackStart;\r
 \r
   MpInitLibWhoAmI (&ProcessorNumber);\r
   CpuMpData    = GetCpuMpData ();\r
   MwaitSupport = IsMwaitSupport ();\r
-  if (CpuMpData->UseSevEsAPMethod) {\r
-    StackStart = CpuMpData->SevEsAPResetStackStart;\r
+  if (StandardSignatureIsAuthenticAMD ()) {\r
+    StackStart               = CpuMpData->UseSevEsAPMethod ? CpuMpData->SevEsAPResetStackStart : mReservedTopOfApStack;\r
+    AsmRelocateApLoopFuncAmd = (ASM_RELOCATE_AP_LOOP_AMD)(UINTN)mReservedApLoopFunc;\r
+    AsmRelocateApLoopFuncAmd (\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
+      );\r
   } else {\r
-    StackStart = mReservedTopOfApStack;\r
+    StackStart            = mReservedTopOfApStack;\r
+    AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc;\r
+    AsmRelocateApLoopFunc (\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
+      );\r
   }\r
 \r
-  AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP)(UINTN)mReservedApLoopFunc;\r
-  AsmRelocateApLoopFunc (\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
-    );\r
   //\r
   // It should never reach here\r
   //\r