Currently, if BSP election is not enabled, will use Core0 as SMM BSP, however, Core0 does not always have the highest performance core. So, we can used NonSmm BSP as default BSP.
Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Signed-off-by: Zhiguang Liu <zhiguang....@intel.com> --- UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 +++++ UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c | 48 +++++++++++----------- 2 files changed, 34 insertions(+), 24 deletions(-) diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c index 25d058c5b9..a4f83bb122 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c @@ -29,6 +29,8 @@ MM_COMPLETION mSmmStartupThisApToken; // UINT32 *mPackageFirstThreadIndex = NULL; +extern EFI_MP_SERVICES_PROTOCOL *mMpServices; + /** Performs an atomic compare exchange operation to get semaphore. The compare exchange operation must be performed using @@ -1953,6 +1955,14 @@ InitializeMpSyncData ( // Enable BSP election by setting BspIndex to -1 // mSmmMpSyncData->BspIndex = (UINT32)-1; + } else { + // + // Use NonSMM BSP as SMM BSP + // + ASSERT (mMpServices != NULL); + if (mMpServices != NULL) { + mMpServices->WhoAmI (mMpServices, (UINTN *)&mSmmMpSyncData->BspIndex); + } } mSmmMpSyncData->EffectiveSyncMode = mCpuSmmSyncMode; diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c index 1d022a7051..18c77c59e6 100644 --- a/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c @@ -128,7 +128,8 @@ SPIN_LOCK *mConfigSmmCodeAccessCheckLock = NULL; EFI_SMRAM_DESCRIPTOR *mSmmCpuSmramRanges; UINTN mSmmCpuSmramRangeCount; -UINT8 mPhysicalAddressBits; +UINT8 mPhysicalAddressBits; +EFI_MP_SERVICES_PROTOCOL *mMpServices; // // Control register contents saved for SMM S3 resume state initialization. @@ -603,26 +604,25 @@ PiCpuSmmEntry ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_STATUS Status; - EFI_MP_SERVICES_PROTOCOL *MpServices; - UINTN NumberOfEnabledProcessors; - UINTN Index; - VOID *Buffer; - UINTN BufferPages; - UINTN TileCodeSize; - UINTN TileDataSize; - UINTN TileSize; - UINT8 *Stacks; - VOID *Registration; - UINT32 RegEax; - UINT32 RegEbx; - UINT32 RegEcx; - UINT32 RegEdx; - UINTN FamilyId; - UINTN ModelId; - UINT32 Cr3; - EFI_HOB_GUID_TYPE *GuidHob; - SMM_BASE_HOB_DATA *SmmBaseHobData; + EFI_STATUS Status; + UINTN NumberOfEnabledProcessors; + UINTN Index; + VOID *Buffer; + UINTN BufferPages; + UINTN TileCodeSize; + UINTN TileDataSize; + UINTN TileSize; + UINT8 *Stacks; + VOID *Registration; + UINT32 RegEax; + UINT32 RegEbx; + UINT32 RegEcx; + UINT32 RegEdx; + UINTN FamilyId; + UINTN ModelId; + UINT32 Cr3; + EFI_HOB_GUID_TYPE *GuidHob; + SMM_BASE_HOB_DATA *SmmBaseHobData; GuidHob = NULL; SmmBaseHobData = NULL; @@ -656,13 +656,13 @@ PiCpuSmmEntry ( // // Get MP Services Protocol // - Status = SystemTable->BootServices->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&MpServices); + Status = SystemTable->BootServices->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **)&mMpServices); ASSERT_EFI_ERROR (Status); // // Use MP Services Protocol to retrieve the number of processors and number of enabled processors // - Status = MpServices->GetNumberOfProcessors (MpServices, &mNumberOfCpus, &NumberOfEnabledProcessors); + Status = mMpServices->GetNumberOfProcessors (mMpServices, &mNumberOfCpus, &NumberOfEnabledProcessors); ASSERT_EFI_ERROR (Status); ASSERT (mNumberOfCpus <= PcdGet32 (PcdCpuMaxLogicalProcessorNumber)); @@ -945,7 +945,7 @@ PiCpuSmmEntry ( gSmmCpuPrivate->Operation[Index] = SmmCpuNone; if (Index < mNumberOfCpus) { - Status = MpServices->GetProcessorInfo (MpServices, Index | CPU_V2_EXTENDED_TOPOLOGY, &gSmmCpuPrivate->ProcessorInfo[Index]); + Status = mMpServices->GetProcessorInfo (mMpServices, Index | CPU_V2_EXTENDED_TOPOLOGY, &gSmmCpuPrivate->ProcessorInfo[Index]); ASSERT_EFI_ERROR (Status); mCpuHotPlugData.ApicId[Index] = gSmmCpuPrivate->ProcessorInfo[Index].ProcessorId; -- 2.31.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111188): https://edk2.groups.io/g/devel/message/111188 Mute This Topic: https://groups.io/mt/102576442/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-