This field is a pointer to an array of CPU_REGISTER_TABLE objects; one
object per logical processor. Each table carries a variable number of
CPU_REGISTER_TABLE_ENTRY objects; each entry prescribes a specific
register setting for the CPU whose CPU_REGISTER_TABLE the entry is in.

Such entries are added to tables with the following CpuConfigLib
functions:
- WriteRegisterTableEx(): internal helper,
- WriteRegisterTable(): public function for RegisterTable,
- WritePreSmmInitRegisterTable(): public function for
  PreSmmInitRegisterTable.

The driver

  Quark_EDKII_v1.1.0/IA32FamilyCpuBasePkg/CpuMpDxe/

allocates the array of CPU_REGISTER_TABLEs in AcpiNVS for
ACPI_CPU_DATA.PreSmmInitRegisterTable, and sets the InitialApicID field of
each table object. (This is then later used by PiSmmCpuDxeSmm to match a
table against a logical CPU.)

However, CpuMpDxe never adds any register entries to any processor's table
in the PreSmmInitRegisterTable, either with
WritePreSmmInitRegisterTable(), or manually. Therefore, rather than trying
to replicate the super complex logic of CpuMpDxe in our CpuS3DataDxe,
let's just remove ACPI_CPU_DATA.PreSmmInitRegisterTable altogether, along
with its processing in PiSmmCpuDxeSmm.

WARNING: this patch actually fixes a security bug. Namely, the processing
being removed from PiSmmCpuDxeSmm happens on the S3 resume path, and it
works directly off AcpiNVS memory, which the runtime OS may have tampered
with. Unlike other AcpiNVS data pointed to by ACPI_CPU_DATA pointers, the
PreSmmInitRegisterTable array has *not* been stashed into SMRAM from
AcpiNVS, in the SmmReadyToLockEventNotify() function.

The issue has been reported to <[email protected]> and <[email protected]>
on 13 May 2015, Message-Id: <[email protected]>.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <[email protected]>
---
 OvmfPkg/QuarkPort/Include/AcpiCpuData.h  |  1 -
 OvmfPkg/QuarkPort/PiSmmCpuDxeSmm/CpuS3.c | 28 --------------------
 2 files changed, 29 deletions(-)

diff --git a/OvmfPkg/QuarkPort/Include/AcpiCpuData.h 
b/OvmfPkg/QuarkPort/Include/AcpiCpuData.h
index dbecc1a..429c611 100644
--- a/OvmfPkg/QuarkPort/Include/AcpiCpuData.h
+++ b/OvmfPkg/QuarkPort/Include/AcpiCpuData.h
@@ -42,7 +42,6 @@ typedef struct {
   UINT32                StackSize;
   UINT32                NumberOfCpus;
   EFI_PHYSICAL_ADDRESS  MtrrTable;
-  EFI_PHYSICAL_ADDRESS  PreSmmInitRegisterTable;
   EFI_PHYSICAL_ADDRESS  RegisterTable;
   EFI_PHYSICAL_ADDRESS  ApMachineCheckHandlerBase;
   UINT32                ApMachineCheckHandlerSize;
diff --git a/OvmfPkg/QuarkPort/PiSmmCpuDxeSmm/CpuS3.c 
b/OvmfPkg/QuarkPort/PiSmmCpuDxeSmm/CpuS3.c
index 75eba6b..2072f1c 100644
--- a/OvmfPkg/QuarkPort/PiSmmCpuDxeSmm/CpuS3.c
+++ b/OvmfPkg/QuarkPort/PiSmmCpuDxeSmm/CpuS3.c
@@ -239,25 +239,9 @@ EarlyMPRendezvousProcedure (
   VOID
   )
 {
-  CPU_REGISTER_TABLE         *RegisterTableList;
-  UINT32                     InitApicId;
-  UINTN                      Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
   //
-  // Find processor number for this CPU.
-  //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-    if (RegisterTableList[Index].InitialApicId == InitApicId) {
-      SetProcessorRegister (&RegisterTableList[Index]);
-      break;
-    }
-  } 
-
-  //
   // Count down the number with lock mechanism.
   //
   InterlockedDecrement (&mNumberToFinish);
@@ -363,23 +347,11 @@ EarlyInitializeCpu (
   VOID
   )
 {
-  CPU_REGISTER_TABLE         *RegisterTableList;
-  UINT32                     InitApicId;
-  UINTN                      Index;
-
   LoadMtrrData (mAcpiCpuData.MtrrTable);
 
   //
   // Find processor number for this CPU.
   //
-  RegisterTableList = (CPU_REGISTER_TABLE *) (UINTN) 
mAcpiCpuData.PreSmmInitRegisterTable;
-  InitApicId = GetInitialApicId ();
-  for (Index = 0; Index < mAcpiCpuData.NumberOfCpus; Index++) {
-    if (RegisterTableList[Index].InitialApicId == InitApicId) {
-      SetProcessorRegister (&RegisterTableList[Index]);
-      break;
-    }
-  } 
 
   ProgramVirtualWireMode ();
 
-- 
1.8.3.1


_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to