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
// 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
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
EFI_PHYSICAL_ADDRESS StartAddress;\r
MSR_SEV_ES_GHCB_REGISTER Msr;\r
GHCB *Ghcb;\r
+ BOOLEAN InterruptState;\r
\r
//\r
// Allocate 1 page for AP jump table page\r
Msr.GhcbPhysicalAddress = AsmReadMsr64 (MSR_SEV_ES_GHCB);\r
Ghcb = Msr.Ghcb;\r
\r
- VmgInit (Ghcb);\r
+ VmgInit (Ghcb, &InterruptState);\r
VmgExit (Ghcb, SVM_EXIT_AP_JUMP_TABLE, 0, (UINT64) (UINTN) StartAddress);\r
- VmgDone (Ghcb);\r
+ VmgDone (Ghcb, InterruptState);\r
\r
return (UINTN) StartAddress;\r
}\r