[edk2-devel] [PATCH v3] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.

Zhiguang Liu posted 1 patch 5 months, 1 week ago
Failed in applying to current master (apply log)
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 ++++++++++
1 file changed, 10 insertions(+)
[edk2-devel] [PATCH v3] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.
Posted by Zhiguang Liu 5 months, 1 week ago
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 in Non-SMM mode.
In S3 flow, the code is executed in Non-SMM BSP's first SMI, where the
gSmmCpuPrivate keeps the data from last boot.

V3:
Add more commit message explaining S3 flow.

Cc: 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>
---
 UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index 25d058c5b9..b279f5dfcc 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -1953,6 +1953,16 @@ InitializeMpSyncData (
       // Enable BSP election by setting BspIndex to -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;
-- 
2.31.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#111645): https://edk2.groups.io/g/devel/message/111645
Mute This Topic: https://groups.io/mt/102761712/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH v3] UefiCpuPkg/PiSmmCpuDxeSmm: Use NonSmm BSP as default SMM BSP.
Posted by Ni, Ray 5 months ago
Reviewed-by: Ray Ni <ray.ni@intel.com>

Thanks,
Ray
> -----Original Message-----
> From: Liu, Zhiguang <zhiguang.liu@intel.com>
> Sent: Thursday, November 23, 2023 11:23 AM
> To: devel@edk2.groups.io
> Cc: Liu, Zhiguang <zhiguang.liu@intel.com>; Ni, Ray <ray.ni@intel.com>;
> Kumar, Rahul R <rahul.r.kumar@intel.com>; Gerd Hoffmann
> <kraxel@redhat.com>; Laszlo Ersek <lersek@redhat.com>
> Subject: [PATCH v3] 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 in Non-SMM mode.
> In S3 flow, the code is executed in Non-SMM BSP's first SMI, where the
> gSmmCpuPrivate keeps the data from last boot.
> 
> V3:
> Add more commit message explaining S3 flow.
> 
> Cc: 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>
> ---
>  UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> index 25d058c5b9..b279f5dfcc 100644
> --- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> +++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
> @@ -1953,6 +1953,16 @@ InitializeMpSyncData (
>        // Enable BSP election by setting BspIndex to -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;
> --
> 2.31.1.windows.1



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