public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: devel@edk2.groups.io
Subject: [PATCH v2 0/4] Simplify SMM Relocated Process
Date: Fri, 13 Jan 2023 23:30:41 +0800	[thread overview]
Message-ID: <20230113153045.13060-1-jiaxin.wu@intel.com> (raw)

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
program the new SMBASE (in TSEG range) for each CPU thread.
When the SMBASE relocated happens in one PEI module ahead
of the PiSmmCpuDxeSmm, the PEI module shall produce the
SMM_BASE_HOB in HOB database which tells the PiSmmCpuDxeSmm
driver which runs at a later phase about the new SMBASE for
each CPU thread. PiSmmCpuDxeSmm driver shall install the
SMI handler at the SMM_BASE_HOB.SmBase[Index]+0x8000 for
CPU thread Index. When the HOB doesn't exist,
PiSmmCpuDxeSmm driver shall 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. This way makes
the first SMI init can be executed in parallel and save boot
time on multi-core system.

Jiaxin Wu (4):
  UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data
  UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info
  UefiCpuPkg/SmmCpuFeaturesLib: Skip to configure SMBASE
  OvmfPkg/SmmCpuFeaturesLib: Skip to configure SMBASE

 .../Library/SmmCpuFeaturesLib/SmmCpuFeaturesLib.c  |  37 ++++-
 .../SmmCpuFeaturesLib/SmmCpuFeaturesLib.inf        |   4 +
 UefiCpuPkg/Include/Guid/SmmBaseHob.h               |  49 ++++++
 .../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                  |  21 ++-
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c              |  29 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c         | 185 ++++++++++++++++-----
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h         |  31 +++-
 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf       |   1 +
 UefiCpuPkg/UefiCpuPkg.dec                          |   3 +
 15 files changed, 332 insertions(+), 63 deletions(-)
 create mode 100644 UefiCpuPkg/Include/Guid/SmmBaseHob.h

-- 
2.16.2.windows.1


             reply	other threads:[~2023-01-13 15:30 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 15:30 Wu, Jiaxin [this message]
2023-01-13 15:30 ` [PATCH v2 1/4] UefiCpuPkg/SmmBaseHob.h: Add SMM Base HOB Data Wu, Jiaxin
2023-01-16  1:39   ` Ni, Ray
2023-01-13 15:30 ` [PATCH v2 2/4] UefiCpuPkg/PiSmmCpuDxeSmm: Consume SMM Base Hob for SmBase info Wu, Jiaxin
2023-01-16  5:21   ` Ni, Ray
2023-01-16  5:52     ` Wu, Jiaxin
2023-01-13 15:30 ` [PATCH v2 3/4] UefiCpuPkg/SmmCpuFeaturesLib: Skip to configure SMBASE Wu, Jiaxin
2023-01-16  5:23   ` [edk2-devel] " Chang, Abner
2023-01-16  5:38     ` Ni, Ray
2023-01-16  5:46       ` Chang, Abner
2023-01-13 15:30 ` [PATCH v2 4/4] OvmfPkg/SmmCpuFeaturesLib: " Wu, Jiaxin
2023-01-16  8:12   ` Gerd Hoffmann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230113153045.13060-1-jiaxin.wu@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox