]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuS3DataDxe: Remove below 4G limitation.
authorEric Dong <eric.dong@intel.com>
Fri, 10 Aug 2018 02:53:45 +0000 (10:53 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 16 Aug 2018 00:42:01 +0000 (08:42 +0800)
Because PrepareApStartupVector() stores StackAddress to
"mExchangeInfo->StackStart" (which has type (VOID*)), and because
"UefiCpuPkg/PiSmmCpuDxeSmm/X64/MpFuncs.nasm" reads the latter with:

         add  edi, StackStartAddressLocation
         add  rax, qword [edi]
         mov  rsp, rax
         mov  qword [edi], rax

in long-mode code. So code can remove below 4G limitation.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Eric Dong <eric.dong@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
Tested-by: Laszlo Ersek <lersek@redhat.com>
UefiCpuPkg/CpuS3DataDxe/CpuS3Data.c

index 3e8c8b383c9d08f1ed1804ec1d9a9b80e2a723a1..ef9823984481d9166b03c4fa314ce4cfb011f343 100644 (file)
@@ -47,9 +47,7 @@ typedef struct {
 } ACPI_CPU_DATA_EX;\r
 \r
 /**\r
-  Allocate EfiACPIMemoryNVS below 4G memory address.\r
-\r
-  This function allocates EfiACPIMemoryNVS below 4G memory address.\r
+  Allocate EfiACPIMemoryNVS memory.\r
 \r
   @param[in] Size   Size of memory to allocate.\r
 \r
@@ -57,7 +55,7 @@ typedef struct {
 \r
 **/\r
 VOID *\r
-AllocateAcpiNvsMemoryBelow4G (\r
+AllocateAcpiNvsMemory (\r
   IN UINTN  Size\r
   )\r
 {\r
@@ -65,9 +63,8 @@ AllocateAcpiNvsMemoryBelow4G (
   EFI_STATUS            Status;\r
   VOID                  *Buffer;\r
 \r
-  Address = BASE_4GB - 1;\r
   Status  = gBS->AllocatePages (\r
-                   AllocateMaxAddress,\r
+                   AllocateAnyPages,\r
                    EfiACPIMemoryNVS,\r
                    EFI_SIZE_TO_PAGES (Size),\r
                    &Address\r
@@ -230,9 +227,13 @@ CpuS3DataInitialize (
   AcpiCpuData->MtrrTable    = (EFI_PHYSICAL_ADDRESS)(UINTN)&AcpiCpuDataEx->MtrrTable;\r
 \r
   //\r
-  // Allocate stack space for all CPUs\r
+  // Allocate stack space for all CPUs.\r
+  // Use ACPI NVS memory type because this data will be directly used by APs\r
+  // in S3 resume phase in long mode. Also during S3 resume, the stack buffer\r
+  // will only be used as scratch space. i.e. we won't read anything from it\r
+  // before we write to it, in PiSmmCpuDxeSmm.\r
   //\r
-  Stack = AllocateAcpiNvsMemoryBelow4G (NumberOfCpus * AcpiCpuData->StackSize);\r
+  Stack = AllocateAcpiNvsMemory (NumberOfCpus * AcpiCpuData->StackSize);\r
   ASSERT (Stack != NULL);\r
   AcpiCpuData->StackAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Stack;\r
 \r