From: "Wu, Jiaxin" <jiaxin.wu@intel.com>
To: devel@edk2.groups.io
Cc: Ray Ni <ray.ni@intel.com>, Laszlo Ersek <lersek@redhat.com>,
Eric Dong <eric.dong@intel.com>, Zeng Star <star.zeng@intel.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Rahul Kumar <rahul1.kumar@intel.com>,
Kinney Michael D <michael.d.kinney@intel.com>
Subject: [edk2-devel] [PATCH v3 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid BspIndex typecasting
Date: Tue, 6 Feb 2024 15:58:03 +0800 [thread overview]
Message-ID: <20240206075804.15152-2-jiaxin.wu@intel.com> (raw)
In-Reply-To: <20240206075804.15152-1-jiaxin.wu@intel.com>
Use MAX_UINT32 directly instead of typecasting from signed
to unsigned value.
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Zeng Star <star.zeng@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Kinney Michael D <michael.d.kinney@intel.com>
Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
---
UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
index e988ce0542..71d6b0c6d8 100644
--- a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
+++ b/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c
@@ -694,14 +694,14 @@ BSPHandler (
// Reset the tokens buffer.
//
ResetTokens ();
//
- // Reset BspIndex to -1, meaning BSP has not been elected.
+ // Reset BspIndex to MAX_UINT32, meaning BSP has not been elected.
//
if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) {
- mSmmMpSyncData->BspIndex = (UINT32)-1;
+ mSmmMpSyncData->BspIndex = MAX_UINT32;
}
//
// Allow APs to check in from this point on
//
@@ -745,11 +745,11 @@ APHandler (
if (!(*mSmmMpSyncData->InsideSmm)) {
//
// BSP timeout in the first round
//
- if (mSmmMpSyncData->BspIndex != -1) {
+ if (mSmmMpSyncData->BspIndex != MAX_UINT32) {
//
// BSP Index is known
// Existing AP is in SMI now but BSP not in, so, try bring BSP in SMM.
//
BspIndex = mSmmMpSyncData->BspIndex;
@@ -1654,11 +1654,11 @@ SmiRendezvous (
//
// Platform hook fails to determine, use default BSP election method
//
InterlockedCompareExchange32 (
(UINT32 *)&mSmmMpSyncData->BspIndex,
- (UINT32)-1,
+ MAX_UINT32,
(UINT32)CpuIndex
);
}
}
}
@@ -1852,13 +1852,13 @@ InitializeMpSyncData (
ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize);
mSmmMpSyncData->CpuData = (SMM_CPU_DATA_BLOCK *)((UINT8 *)mSmmMpSyncData + sizeof (SMM_DISPATCHER_MP_SYNC_DATA));
mSmmMpSyncData->CandidateBsp = (BOOLEAN *)(mSmmMpSyncData->CpuData + gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus);
if (FeaturePcdGet (PcdCpuSmmEnableBspElection)) {
//
- // Enable BSP election by setting BspIndex to -1
+ // Enable BSP election by setting BspIndex to MAX_UINT32
//
- mSmmMpSyncData->BspIndex = (UINT32)-1;
+ mSmmMpSyncData->BspIndex = MAX_UINT32;
} else {
//
// Use NonSMM BSP as SMM BSP
//
for (CpuIndex = 0; CpuIndex < gSmmCpuPrivate->SmmCoreEntryContext.NumberOfCpus; CpuIndex++) {
--
2.16.2.windows.1
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#115150): https://edk2.groups.io/g/devel/message/115150
Mute This Topic: https://groups.io/mt/104194205/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-
next prev parent reply other threads:[~2024-02-06 7:58 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-06 7:58 [edk2-devel] [PATCH v3 0/2] SMM CPU Optimization Wu, Jiaxin
2024-02-06 7:58 ` Wu, Jiaxin [this message]
2024-02-06 8:56 ` [edk2-devel] [PATCH v3 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid BspIndex typecasting Ni, Ray
2024-02-06 14:33 ` Laszlo Ersek
2024-02-06 7:58 ` [edk2-devel] [PATCH v3 2/2] UefiCpuPkg/PiSmmCpuDxeSmm: Check BspIndex first before lock cmpxchg Wu, Jiaxin
2024-02-06 8:57 ` Ni, Ray
[not found] ` <03c101da659e$2ad5e530$8081af90$@byosoft.com.cn>
2024-02-23 0:47 ` [edk2-devel] [PATCH v3 0/2] SMM CPU Optimization Wu, Jiaxin
2024-02-23 5:36 ` Wu, Jiaxin
2024-02-23 5:52 ` 回复: " gaoliming via groups.io
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=20240206075804.15152-2-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