[edk2-devel] [PATCH v3 0/5] Simplify SMM Relocation Process

Wu, Jiaxin posted 5 patches 1 year, 3 months ago
Failed in applying to current master (apply log)
There is a newer version of this series
.../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c  |  37 ++++-
.../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf        |   4 +
UefiCpuPkg/Include/Guid/SmmBaseHob.h               |  46 ++++++
.../Library/SmmCpuFeaturesLib/CpuFeaturesLib.h     |   2 +
.../SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c     |  23 ++-
.../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf        |   4 +
.../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf     |   1 +
UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c      |   1 -
.../StandaloneMmCpuFeaturesLib.inf                 |   4 +
UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c                  |  29 +++-
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c              |  23 +++
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c         | 184 ++++++++++++++++-----
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h         |  24 +++
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf       |   1 +
UefiCpuPkg/UefiCpuPkg.dec                          |   3 +
15 files changed, 329 insertions(+), 57 deletions(-)
create mode 100644 UefiCpuPkg/Include/Guid/SmmBaseHob.h
[edk2-devel] [PATCH v3 0/5] Simplify SMM Relocation Process
Posted by Wu, Jiaxin 1 year, 3 months ago
The default SMBASE for the x86 processor is 0x30000. When
SMI happens, CPU runs the SMI handler at SMBASE+0x8000.
Also, the SMM save state area is within SMBASE+0x10000.

One of the SMM initialization from CPU perspective is to relocate
and program the new SMBASE (in TSEG range) for each CPU thread. When
the SMBASE relocation happens in a PEI module, the PEI module shall
produce the SMM_BASE_HOB in HOB database which tells the
PiSmmCpuDxeSmm driver (runs at a later phase) about the new SMBASE
for each CPU thread. PiSmmCpuDxeSmm driver installs the SMI handler
at the SMM_BASE_HOB.SmBase[Index]+0x8000 for CPU thread Index. When
the HOB doesn't exist, PiSmmCpuDxeSmm driver shall relocate and
program the new SMBASE itself.

Those patches add the SMM Base HOB, which can be produced
by any PEI module to do the SmBase relocation ahead of
PiSmmCpuDxeSmm driver and store the relocated SmBase
address in array for reach Processors. PiSmmCpuDxeSmm
and SmmCpuFeaturesLib will consume the HOB to simplify
SMM relocation process.

With SMM Base Hob, PiSmmCpuDxeSmm does not need the RSM
instruction to reload the SMBASE register with the new allocated
SMBASE each time when it exits SMM. SMBASE Register for each
processors have already been programmed and all SMBASE address
have recorded in SMM Base Hob. So the same default SMBASE Address
(0x30000) will not be used, thus the CPUs over-writing each
other's SMM Save State Area will not happen in PiSmmCpuDxeSmm
driver. This way makes the first SMI init can be executed in
parallel and save boot time on multi-core system.

Jiaxin Wu (5):
  UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data
  UefiCpuPkg/PiSmmCpuDxeSmm: Fix invalid InitializeMpSyncData call
  UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info
  UefiCpuPkg/SmmCpuFeaturesLib: Skip SMBASE configuration
  OvmfPkg/SmmCpuFeaturesLib: Skip SMBASE configuration

 .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c  |  37 ++++-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf        |   4 +
 UefiCpuPkg/Include/Guid/SmmBaseHob.h               |  46 ++++++
 .../Library/SmmCpuFeaturesLib/CpuFeaturesLib.h     |   2 +
 .../SmmCpuFeaturesLib/IntelSmmCpuFeaturesLib.c     |  23 ++-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf        |   4 +
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLibStm.inf     |   1 +
 UefiCpuPkg/Library/SmmCpuFeaturesLib/SmmStm.c      |   1 -
 .../StandaloneMmCpuFeaturesLib.inf                 |   4 +
 UefiCpuPkg/PiSmmCpuDxeSmm/CpuS3.c                  |  29 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c              |  23 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c         | 184 ++++++++++++++++-----
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h         |  24 +++
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf       |   1 +
 UefiCpuPkg/UefiCpuPkg.dec                          |   3 +
 15 files changed, 329 insertions(+), 57 deletions(-)
 create mode 100644 UefiCpuPkg/Include/Guid/SmmBaseHob.h

-- 
2.16.2.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#98787): https://edk2.groups.io/g/devel/message/98787
Mute This Topic: https://groups.io/mt/96350759/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-