audk/UefiCpuPkg
Jiaxin Wu 58d9463939 UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync
After BSP returned from SmmCoreEntry, there are several rounds BSP
and AP sync in BSP handler:

1 .ReleaseAllAPs();  /// Notify all APs to exit.
if (SmmCpuFeaturesNeedConfigureMtrrs()) {
  2. SmmCpuSyncWaitForAPs(); /// Wait for all APs to program MTRRs.
  3. ReleaseAllAPs(); /// Signal APs to restore MTRRs.
}

4. SmmCpuSyncWaitForAPs(); /// Wait for all APs to complete pending
                               tasks including MTRR.
5. ReleaseAllAPs(); /// Signal APs to Reset states.

6. SmmCpuSyncWaitForAPs(); /// Gather APs to exit SMM synchronously.

Before step 6 and after step 5, BSP performs below items:
A. InitializeDebugAgent() /// Stop source level debug.
B. SmmCpuUpdate() /// Perform pending operations for hot-plug.
C. Present = FALSE; /// Clear the Present flag of BSP.

For InitializeDebugAgent(), BSP needs to wait all APs complete
pending tasks and then notify all APs to stop source level debug.
So, above step 4 & step 5 are required for InitializeDebugAgent().

For SmmCpuUpdate(), it's to perform pending operations for
hot-plug CPUs take effect in next SMI. Existing APs in SMI do not
reply on the CPU switch & hot-add & hot-remove operations. So, no
need step 4 and step 5 for additional one round BSP & AP sync.
Step 6 can make sure all APs are ready to exit SMM, then hot-plug
operation can take effect in next SMI.

For BSP "Present" flag, AP does not reply on it. No need step 4
and step 5 for additional one round BSP & AP sync.

Based on above analysis, step 4 and step 5 are only required if
need configure MTRR and support SMM source level debug. So, we can
reduce one round BSP and AP sync if both are unsupported. With
this change, SMI performance can be improved.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@Intel.com>
2023-12-26 07:18:26 +00:00
..
Application/Cpuid UefiCpuPkg: Calculate DisplayFamily correctly 2023-03-07 10:42:38 +00:00
CpuDxe UefiCpuPkg/CpuDxe: Eliminate the unused variable. 2023-10-12 07:30:46 +00:00
CpuDxeRiscV64 UefiCpuPkg: RISC-V: Support MMU with SV39/48/57 mode 2023-07-15 14:10:18 +00:00
CpuFeatures UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuIo2Dxe UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuIo2Smm UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuIoPei UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
CpuMpPei UefiCpuPkg: Cache core type in MpInfo2 HOB 2023-12-12 01:37:41 +00:00
CpuS3DataDxe UefiCpuPkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00
CpuTimerDxeRiscV64 UefiCpuPkg: CpuTimerDxeRiscV64: Fix timer event not working correctly 2023-07-02 10:33:11 +00:00
Include UefiCpuPkg: Adds SmmCpuSyncLib library class 2023-12-20 02:30:56 +00:00
Library UefiCpuPkg: Implements SmmCpuSyncLib library instance 2023-12-20 02:30:56 +00:00
MicrocodeMeasurementDxe UefiCpuPkg/MicrocodeMeasurementDxe: Fix exception 2023-03-10 07:13:14 +00:00
PiSmmCommunication UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
PiSmmCpuDxeSmm UefiCpuPkg/PiSmmCpuDxeSmm: Reduce one round BSP & AP sync 2023-12-26 07:18:26 +00:00
ResetVector UefiCpuPkg/ResetVector: Remove AP waking vector from ResetVector 2023-09-18 02:39:25 +00:00
SecCore UefiCpuPkg/SecCore: Remove AP waking Vector logic in SecCore 2023-09-18 02:39:25 +00:00
SecMigrationPei UefiCpuPkg: Apply uncrustify changes 2021-12-07 17:24:28 +00:00
Test UefiCpuPkg: Update code to be more C11 compliant by using __func__ 2023-04-10 14:19:57 +00:00
Universal/Acpi/S3Resume2Pei UefiCpuPkg/S3Resume2Pei: assert for invalid excution mode combo 2023-09-08 06:19:34 +00:00
UefiCpuPkg.ci.yaml UefiCpuPkg/UefiCpuPkg.ci.yaml: Ignore RISC-V file 2023-02-16 05:53:28 +00:00
UefiCpuPkg.dec UefiCpuPkg: Adds SmmCpuSyncLib library class 2023-12-20 02:30:56 +00:00
UefiCpuPkg.dsc UefiCpuPkg: Implements SmmCpuSyncLib library instance 2023-12-20 02:30:56 +00:00
UefiCpuPkg.uni UefiCpuPkg: Add PCD to control SMRR enable & SmmFeatureControl support 2022-08-31 04:23:55 +00:00
UefiCpuPkgExtra.uni UefiCpuPkg: Replace BSD License with BSD+Patent License 2019-04-09 10:58:28 -07:00