]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: For SEV-ES guest, set stack based on processor number
authorTom Lendacky <thomas.lendacky@amd.com>
Fri, 6 Nov 2020 17:53:13 +0000 (11:53 -0600)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Tue, 10 Nov 2020 19:07:55 +0000 (19:07 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3008

Set the SEV-ES reset stack address for an AP based on the processor number
instead of the APIC ID in case the APIC IDs are not zero-based and densely
packed/enumerated. This will ensure an AP reset stack address does not get
set outside of the AP reset stack memory allocation.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Acked-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Message-Id: <24866de07d2a954dec71df70972f1851273020d8.1604685192.git.thomas.lendacky@amd.com>

UefiCpuPkg/Library/MpInitLib/MpLib.c

index 1f47ff3f73b51ddff4a18588703459bf1ee7d50e..681fa79b4cffff6165d2442905714ddb6cbb8d4c 100644 (file)
@@ -680,11 +680,16 @@ MpInitLibSevEsAPReset (
   IN CPU_MP_DATA                  *CpuMpData\r
   )\r
 {\r
+  EFI_STATUS       Status;\r
+  UINTN            ProcessorNumber;\r
   UINT16           Code16, Code32;\r
   AP_RESET         *APResetFn;\r
   UINTN            BufferStart;\r
   UINTN            StackStart;\r
 \r
+  Status = GetProcessorNumber (CpuMpData, &ProcessorNumber);\r
+  ASSERT_EFI_ERROR (Status);\r
+\r
   Code16 = GetProtectedMode16CS ();\r
   Code32 = GetProtectedMode32CS ();\r
 \r
@@ -696,7 +701,7 @@ MpInitLibSevEsAPReset (
 \r
   BufferStart = CpuMpData->MpCpuExchangeInfo->BufferStart;\r
   StackStart = CpuMpData->SevEsAPResetStackStart -\r
-                 (AP_RESET_STACK_SIZE * GetApicId ());\r
+                 (AP_RESET_STACK_SIZE * ProcessorNumber);\r
 \r
   //\r
   // This call never returns.\r