]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/CpuS3DataDxe: do not allocate useless register tables
authorLaszlo Ersek <lersek@redhat.com>
Tue, 19 Jan 2021 15:54:40 +0000 (16:54 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 20 Jan 2021 18:20:14 +0000 (18:20 +0000)
CpuS3DataDxe allocates the "RegisterTable" and "PreSmmInitRegisterTable"
arrays in ACPI_CPU_DATA just so every processor in the system can have its
own empty register table, matched by APIC ID. This has never been useful
in practice.

Given commit e992cc3f4859 ("UefiCpuPkg PiSmmCpuDxeSmm: Reduce SMRAM
consumption in CpuS3.c", 2021-01-11), simply leave both
"AcpiCpuData->RegisterTable" and "AcpiCpuData->PreSmmInitRegisterTable"
initialized to the zero address. This simplifies the driver, and saves
both normal RAM (boot services data type memory) and -- in PiSmmCpuDxeSmm
-- SMRAM.

(This simplification backs out a good chunk of commit 1158fc8e2c7b
("OvmfPkg/CpuS3DataDxe: enable S3 resume after CPU hotplug", 2020-03-04).
But CpuS3DataDxe still differs between UefiCpuPkg and OvmfPkg, due to the
latter supporting CPU hotplug; thus, we can't remove OvmfPkg/CpuS3DataDxe
altogether.)

Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3159
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com>
Message-Id: <20210119155440.2262-5-lersek@redhat.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
OvmfPkg/CpuS3DataDxe/CpuS3Data.c
OvmfPkg/CpuS3DataDxe/CpuS3DataDxe.inf

index bac7285aa2f350ec37edc27e7f06d11f283f60c9..5ffe1f3cd74e49f6e052bc2d6d628f0ae409db03 100644 (file)
@@ -23,7 +23,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Library/BaseLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
 #include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/MtrrLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
@@ -31,9 +30,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 #include <Protocol/MpService.h>\r
 #include <Guid/EventGroup.h>\r
 \r
-#include <IndustryStandard/Q35MchIch9.h>\r
-#include <IndustryStandard/QemuCpuHotplug.h>\r
-\r
 //\r
 // Data structure used to allocate ACPI_CPU_DATA and its supporting structures\r
 //\r
@@ -168,17 +164,12 @@ CpuS3DataInitialize (
   EFI_MP_SERVICES_PROTOCOL   *MpServices;\r
   UINTN                      NumberOfCpus;\r
   VOID                       *Stack;\r
-  UINTN                      TableSize;\r
-  CPU_REGISTER_TABLE         *RegisterTable;\r
-  UINTN                      Index;\r
-  EFI_PROCESSOR_INFORMATION  ProcessorInfoBuffer;\r
   UINTN                      GdtSize;\r
   UINTN                      IdtSize;\r
   VOID                       *Gdt;\r
   VOID                       *Idt;\r
   EFI_EVENT                  Event;\r
   ACPI_CPU_DATA              *OldAcpiCpuData;\r
-  BOOLEAN                    FetchPossibleApicIds;\r
 \r
   if (!PcdGetBool (PcdAcpiS3Enable)) {\r
     return EFI_UNSUPPORTED;\r
@@ -193,13 +184,7 @@ CpuS3DataInitialize (
   ASSERT (AcpiCpuDataEx != NULL);\r
   AcpiCpuData = &AcpiCpuDataEx->AcpiCpuData;\r
 \r
-  //\r
-  // The "SMRAM at default SMBASE" feature guarantees that\r
-  // QEMU_CPUHP_CMD_GET_ARCH_ID too is available.\r
-  //\r
-  FetchPossibleApicIds = PcdGetBool (PcdQ35SmramAtDefaultSmbase);\r
-\r
-  if (FetchPossibleApicIds) {\r
+  if (PcdGetBool (PcdQ35SmramAtDefaultSmbase)) {\r
     NumberOfCpus = PcdGet32 (PcdCpuMaxLogicalProcessorNumber);\r
   } else {\r
     UINTN NumberOfEnabledProcessors;\r
@@ -271,59 +256,6 @@ CpuS3DataInitialize (
     AcpiCpuData->PreSmmInitRegisterTable = OldAcpiCpuData->PreSmmInitRegisterTable;\r
     AcpiCpuData->ApLocation              = OldAcpiCpuData->ApLocation;\r
     CopyMem (&AcpiCpuData->CpuStatus, &OldAcpiCpuData->CpuStatus, sizeof (CPU_STATUS_INFORMATION));\r
-  } else {\r
-    //\r
-    // Allocate buffer for empty RegisterTable and PreSmmInitRegisterTable for all CPUs\r
-    //\r
-    TableSize = 2 * NumberOfCpus * sizeof (CPU_REGISTER_TABLE);\r
-    RegisterTable = (CPU_REGISTER_TABLE *)AllocateZeroPages (TableSize);\r
-    ASSERT (RegisterTable != NULL);\r
-\r
-    if (FetchPossibleApicIds) {\r
-      //\r
-      // Write a valid selector so that other hotplug registers can be\r
-      // accessed.\r
-      //\r
-      IoWrite32 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CPU_SEL, 0);\r
-      //\r
-      // We'll be fetching the APIC IDs.\r
-      //\r
-      IoWrite8 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CMD,\r
-        QEMU_CPUHP_CMD_GET_ARCH_ID);\r
-    }\r
-    for (Index = 0; Index < NumberOfCpus; Index++) {\r
-      UINT32 InitialApicId;\r
-\r
-      if (FetchPossibleApicIds) {\r
-        IoWrite32 (ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_W_CPU_SEL,\r
-          (UINT32)Index);\r
-        InitialApicId = IoRead32 (\r
-                          ICH9_CPU_HOTPLUG_BASE + QEMU_CPUHP_RW_CMD_DATA);\r
-      } else {\r
-        Status = MpServices->GetProcessorInfo (\r
-                             MpServices,\r
-                             Index,\r
-                             &ProcessorInfoBuffer\r
-                             );\r
-        ASSERT_EFI_ERROR (Status);\r
-        InitialApicId = (UINT32)ProcessorInfoBuffer.ProcessorId;\r
-      }\r
-\r
-      DEBUG ((DEBUG_VERBOSE, "%a: Index=%05Lu ApicId=0x%08x\n", __FUNCTION__,\r
-        (UINT64)Index, InitialApicId));\r
-\r
-      RegisterTable[Index].InitialApicId      = InitialApicId;\r
-      RegisterTable[Index].TableLength        = 0;\r
-      RegisterTable[Index].AllocatedSize      = 0;\r
-      RegisterTable[Index].RegisterTableEntry = 0;\r
-\r
-      RegisterTable[NumberOfCpus + Index].InitialApicId      = InitialApicId;\r
-      RegisterTable[NumberOfCpus + Index].TableLength        = 0;\r
-      RegisterTable[NumberOfCpus + Index].AllocatedSize      = 0;\r
-      RegisterTable[NumberOfCpus + Index].RegisterTableEntry = 0;\r
-    }\r
-    AcpiCpuData->RegisterTable           = (EFI_PHYSICAL_ADDRESS)(UINTN)RegisterTable;\r
-    AcpiCpuData->PreSmmInitRegisterTable = (EFI_PHYSICAL_ADDRESS)(UINTN)(RegisterTable + NumberOfCpus);\r
   }\r
 \r
   //\r
index ceae1d4078c79793f65f8d9a7657ddc798eb87ef..228d5ae1b260f8932eeb8f048b89599c8317c294 100644 (file)
@@ -42,7 +42,6 @@
   BaseLib\r
   BaseMemoryLib\r
   DebugLib\r
-  IoLib\r
   MemoryAllocationLib\r
   MtrrLib\r
   UefiBootServicesTableLib\r