]> git.proxmox.com Git - mirror_edk2.git/commitdiff
UefiCpuPkg/CpuS3DataDxe: Change Memory Type and address limitation.
authorEric Dong <eric.dong@intel.com>
Fri, 10 Aug 2018 02:41:04 +0000 (10:41 +0800)
committerEric Dong <eric.dong@intel.com>
Thu, 16 Aug 2018 00:42:01 +0000 (08:42 +0800)
Because CpuS3Data memory will be copy to smram at SmmReadyToLock point,
the memory type no need to be ACPI NVS type, also the address not
limit to below 4G.

This change remove the limit of ACPI NVS memory type and below 4G.

Pass OS boot and resume from S3 test.

Cc: Marvin Häuser <Marvin.Haeuser@outlook.com>
Cc: Fan Jeff <vanjeff_919@hotmail.com>
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
UefiCpuPkg/CpuS3DataDxe/CpuS3DataDxe.inf

index dccb406b8d2cde5470500a0c84219fa428669628..3e8c8b383c9d08f1ed1804ec1d9a9b80e2a723a1 100644 (file)
@@ -31,6 +31,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/MtrrLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
 \r
 #include <Protocol/MpService.h>\r
 #include <Guid/EventGroup.h>\r
@@ -81,6 +82,28 @@ AllocateAcpiNvsMemoryBelow4G (
   return Buffer;\r
 }\r
 \r
+/**\r
+  Allocate memory and clean it with zero.\r
+\r
+  @param[in] Size   Size of memory to allocate.\r
+\r
+  @return       Allocated address for output.\r
+\r
+**/\r
+VOID *\r
+AllocateZeroPages (\r
+  IN UINTN  Size\r
+  )\r
+{\r
+  VOID                  *Buffer;\r
+\r
+  Buffer = AllocatePages (EFI_SIZE_TO_PAGES (Size));\r
+  if (Buffer != NULL) {\r
+    ZeroMem (Buffer, Size);\r
+  }\r
+\r
+  return Buffer;\r
+}\r
 /**\r
   Callback function executed when the EndOfDxe event group is signaled.\r
 \r
@@ -171,10 +194,7 @@ CpuS3DataInitialize (
   //\r
   OldAcpiCpuData = (ACPI_CPU_DATA *) (UINTN) PcdGet64 (PcdCpuS3DataAddress);\r
 \r
-  //\r
-  // Allocate ACPI NVS memory below 4G memory for use on ACPI S3 resume.\r
-  //\r
-  AcpiCpuDataEx = AllocateAcpiNvsMemoryBelow4G (sizeof (ACPI_CPU_DATA_EX));\r
+  AcpiCpuDataEx = AllocateZeroPages (sizeof (ACPI_CPU_DATA_EX));\r
   ASSERT (AcpiCpuDataEx != NULL);\r
   AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData;\r
 \r
@@ -223,11 +243,11 @@ CpuS3DataInitialize (
   AsmReadIdtr (&AcpiCpuDataEx->IdtrProfile);\r
 \r
   //\r
-  // Allocate GDT and IDT in ACPI NVS and copy current GDT and IDT contents\r
+  // Allocate GDT and IDT and copy current GDT and IDT contents\r
   //\r
   GdtSize = AcpiCpuDataEx->GdtrProfile.Limit + 1;\r
   IdtSize = AcpiCpuDataEx->IdtrProfile.Limit + 1;\r
-  Gdt = AllocateAcpiNvsMemoryBelow4G (GdtSize + IdtSize);\r
+  Gdt = AllocateZeroPages (GdtSize + IdtSize);\r
   ASSERT (Gdt != NULL);\r
   Idt = (VOID *)((UINTN)Gdt + GdtSize);\r
   CopyMem (Gdt, (VOID *)AcpiCpuDataEx->GdtrProfile.Base, GdtSize);\r
@@ -243,7 +263,7 @@ CpuS3DataInitialize (
     // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
     //\r
     TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
-    RegisterTable = (CPU_REGISTER_TABLE *)AllocateAcpiNvsMemoryBelow4G (TableSize);\r
+    RegisterTable = (CPU_REGISTER_TABLE *)AllocateZeroPages (TableSize);\r
     ASSERT (RegisterTable != NULL);\r
 \r
     for (Index = 0; Index < NumberOfCpus; Index++) {\r
index 480c98ebcd32b81456ef9ea9660fcebae8af6a75..c16731529c3033d5019c681012901c71b6a0277a 100644 (file)
@@ -51,6 +51,7 @@
   DebugLib\r
   BaseLib\r
   MtrrLib\r
+  MemoryAllocationLib\r
 \r
 [Guids]\r
   gEfiEndOfDxeEventGroupGuid         ## CONSUMES   ## Event\r