]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/MpInitLib: Reduce reset vector memory pressure
authorTom Lendacky <thomas.lendacky@amd.com>
Wed, 23 Sep 2020 18:04:00 +0000 (13:04 -0500)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Mon, 19 Oct 2020 21:47:21 +0000 (21:47 +0000)
The AP reset vector stack allocation is only required if running as an
SEV-ES guest. Since the reset vector allocation is below 1MB in memory,
eliminate the requirement for bare-metal systems and non SEV-ES guests
to allocate the extra stack area, which can be large if the
PcdCpuMaxLogicalProcessorNumber value is large, and also remove the
CPU_STACK_ALIGNMENT alignment.

Fixes: 7b7508ad784d ("UefiCpuPkg: Allow AP booting under SEV-ES")
Cc: Garrett Kirkendall <garrett.kirkendall@amd.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Message-Id: <21345cdbc906519558202b3851257ca07b9239ba.1600884239.git.thomas.lendacky@amd.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
[lersek@redhat.com: supply missing space character after "PcdGet32"]

UefiCpuPkg/Library/MpInitLib/MpLib.c

index 07426274f6396321ba136d588c5c1a92633a0f77..6d977d45bcddae12b352af5bbb31af9d679c24f3 100644 (file)
@@ -1141,20 +1141,6 @@ RestoreWakeupBuffer(
     );\r
 }\r
 \r
-/**\r
-  Calculate the size of the reset stack.\r
-\r
-  @return                 Total amount of memory required for stacks\r
-**/\r
-STATIC\r
-UINTN\r
-GetApResetStackSize (\r
-  VOID\r
-  )\r
-{\r
-  return AP_RESET_STACK_SIZE * PcdGet32(PcdCpuMaxLogicalProcessorNumber);\r
-}\r
-\r
 /**\r
   Calculate the size of the reset vector.\r
 \r
@@ -1170,11 +1156,23 @@ GetApResetVectorSize (
 {\r
   UINTN  Size;\r
 \r
-  Size = ALIGN_VALUE (AddressMap->RendezvousFunnelSize +\r
-                        AddressMap->SwitchToRealSize +\r
-                        sizeof (MP_CPU_EXCHANGE_INFO),\r
-                      CPU_STACK_ALIGNMENT);\r
-  Size += GetApResetStackSize ();\r
+  Size = AddressMap->RendezvousFunnelSize +\r
+           AddressMap->SwitchToRealSize +\r
+           sizeof (MP_CPU_EXCHANGE_INFO);\r
+\r
+  //\r
+  // The AP reset stack is only used by SEV-ES guests. Do not add to the\r
+  // allocation if SEV-ES is not enabled.\r
+  //\r
+  if (PcdGetBool (PcdSevEsIsEnabled)) {\r
+    //\r
+    // Stack location is based on APIC ID, so use the total number of\r
+    // processors for calculating the total stack area.\r
+    //\r
+    Size += AP_RESET_STACK_SIZE * PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
+\r
+    Size = ALIGN_VALUE (Size, CPU_STACK_ALIGNMENT);\r
+  }\r
 \r
   return Size;\r
 }\r