UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.

Currently, if BSP election is not enabled, will use Core0 as SMM BSP.
However, Core0 does not always have the highest performance.
So, we can used NonSmm BSP as default BSP.
This will take effect in normal SMM init flow and S3 boot flow.
In normal SMM flow, the code is executed before first SMI.
In S3 flow, the code is executed in Non-SMM BSP's first SMI, where the
gSmmCpuPrivate keeps the data from last boot.

Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
This commit is contained in:
Zhiguang Liu 2023-11-19 20:28:48 +08:00 committed by mergify[bot]
parent 88580a79d4
commit 68d506e0d1
1 changed files with 10 additions and 0 deletions

View File

@ -1953,6 +1953,16 @@ InitializeMpSyncData (
// Enable BSP election by setting BspIndex to -1 // Enable BSP election by setting BspIndex to -1
// //
mSmmMpSyncData->BspIndex = (UINT32)-1; mSmmMpSyncData->BspIndex = (UINT32)-1;
} else {
//
// Use NonSMM BSP as SMM BSP
//
for (CpuIndex = 0; CpuIndex < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex++) {
if (GetApicId () == gSmmCpuPrivate->ProcessorInfo[CpuIndex].ProcessorId) {
mSmmMpSyncData->BspIndex = (UINT32)CpuIndex;
break;
}
}
} }
mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode; mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode;