]> git.proxmox.com Git - mirror_edk2.git/blobdiff - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
UefiCpuPkg/MpInitLib: Allocate a separate SEV-ES AP reset stack area
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / DxeMpLib.c
index 7839c249760ec13c102619a3a10d698cffeae4c5..93fc63bf93e3070d5e3ddffae14158d72aacc74c 100644 (file)
@@ -29,6 +29,11 @@ VOID             *mReservedApLoopFunc = NULL;
 UINTN            mReservedTopOfApStack;\r
 volatile UINT32  mNumberToFinish = 0;\r
 \r
+//\r
+// Begin wakeup buffer allocation below 0x88000\r
+//\r
+STATIC EFI_PHYSICAL_ADDRESS mSevEsDxeWakeupBuffer = 0x88000;\r
+\r
 /**\r
   Enable Debug Agent to support source debugging on AP function.\r
 \r
@@ -102,7 +107,14 @@ GetWakeupBuffer (
   // LagacyBios driver depends on CPU Arch protocol which guarantees below\r
   // allocation runs earlier than LegacyBios driver.\r
   //\r
-  StartAddress = 0x88000;\r
+  if (PcdGetBool (PcdSevEsIsEnabled)) {\r
+    //\r
+    // SEV-ES Wakeup buffer should be under 0x88000 and under any previous one\r
+    //\r
+    StartAddress = mSevEsDxeWakeupBuffer;\r
+  } else {\r
+    StartAddress = 0x88000;\r
+  }\r
   Status = gBS->AllocatePages (\r
                   AllocateMaxAddress,\r
                   MemoryType,\r
@@ -112,6 +124,11 @@ GetWakeupBuffer (
   ASSERT_EFI_ERROR (Status);\r
   if (EFI_ERROR (Status)) {\r
     StartAddress = (EFI_PHYSICAL_ADDRESS) -1;\r
+  } else if (PcdGetBool (PcdSevEsIsEnabled)) {\r
+    //\r
+    // Next SEV-ES wakeup buffer allocation must be below this allocation\r
+    //\r
+    mSevEsDxeWakeupBuffer = StartAddress;\r
   }\r
 \r
   DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r