From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id 07457D811BC for ; Tue, 6 Feb 2024 07:58:12 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=/dSsXblvabKDsPWIjdasGgjQnvjFsBO+lQsXgnDUJHA=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe; s=20140610; t=1707206291; v=1; b=sPxDE4FdosczS15mF/bHeQ9sjWXLXl0jiWUSXuMChjdH8xI5QDCLmGa1cghn7owt/iR9FhrB D8VBeXM1P7n6oHVv2MLH2YtlnSAgqDpdxL+7LMt4jp6zGOhhiVVKUpTxbFnDsg8dzn2SoNAc40T d/4H6JoM6sU4lrY1I2ARcniM= X-Received: by 127.0.0.2 with SMTP id 9YbcYY7687511xi5v9Mc2vzq; Mon, 05 Feb 2024 23:58:11 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.18]) by mx.groups.io with SMTP id smtpd.web10.17030.1707206288775720019 for ; Mon, 05 Feb 2024 23:58:11 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10975"; a="575546" X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="575546" X-Received: from fmviesa004.fm.intel.com ([10.60.135.144]) by fmvoesa112.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 05 Feb 2024 23:58:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.05,246,1701158400"; d="scan'208";a="5571326" X-Received: from sh1gapp1009.ccr.corp.intel.com ([10.239.189.219]) by fmviesa004.fm.intel.com with ESMTP; 05 Feb 2024 23:58:08 -0800 From: "Wu, Jiaxin" To: devel@edk2.groups.io Cc: Ray Ni , Laszlo Ersek , Eric Dong , Zeng Star , Gerd Hoffmann , Rahul Kumar , Kinney Michael D Subject: [edk2-devel] [PATCH v3 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid BspIndex typecasting Date: Tue, 6 Feb 2024 15:58:03 +0800 Message-Id: <20240206075804.15152-2-jiaxin.wu@intel.com> In-Reply-To: <20240206075804.15152-1-jiaxin.wu@intel.com> References: <20240206075804.15152-1-jiaxin.wu@intel.com> Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,jiaxin.wu@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: ad4aOoJZmaRSEnwE4gr1MEW2x7686176AA= X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=sPxDE4Fd; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) Use MAX_UINT32 directly instead of typecasting from signed to unsigned value. Cc: Ray Ni Cc: Laszlo Ersek Cc: Eric Dong Cc: Zeng Star Cc: Gerd Hoffmann Cc: Rahul Kumar Cc: Kinney Michael D Signed-off-by: Jiaxin Wu --- 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] -=-=-=-=-=-=-=-=-=-=-=-