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 122027803E5 for ; Tue, 6 Feb 2024 14:33:50 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=yDQoYF5GNbzcx1Rf5gNtgd9+dtXBBGqNp6PuyommGig=; c=relaxed/simple; d=groups.io; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From:In-Reply-To:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Language:Content-Type:Content-Transfer-Encoding; s=20140610; t=1707230029; v=1; b=Ru6ragXD74Dr8dFd14CyUJbgPOmmzhikos1KdHoSmdBwSo5u1YLShvcDWGkFs7sZd+9J+CEw wUvrEN7Q9/bPrnq7av++M+U+fmT+y6kn4CXh7XBbRYL9DhGBjN4p5mO4Gr1fnbRzqTHPYMn/OX7 CRNGPFNkOFEHr9uhXdAAFWVA= X-Received: by 127.0.0.2 with SMTP id 2W6BYY7687511xhnceZzF34a; Tue, 06 Feb 2024 06:33:49 -0800 X-Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.groups.io with SMTP id smtpd.web11.22710.1707230029092421353 for ; Tue, 06 Feb 2024 06:33:49 -0800 X-Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-35-WLw42PubMdGh6TTJAwQW1g-1; Tue, 06 Feb 2024 09:33:46 -0500 X-MC-Unique: WLw42PubMdGh6TTJAwQW1g-1 X-Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5042F29ABA1A; Tue, 6 Feb 2024 14:33:46 +0000 (UTC) X-Received: from [10.39.195.129] (unknown [10.39.195.129]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC131AC1A; Tue, 6 Feb 2024 14:33:44 +0000 (UTC) Message-ID: Date: Tue, 6 Feb 2024 15:33:43 +0100 MIME-Version: 1.0 Subject: Re: [edk2-devel] [PATCH v3 1/2] UefiCpuPkg/PiSmmCpuDxeSmm: Avoid BspIndex typecasting To: Jiaxin Wu , devel@edk2.groups.io Cc: Ray Ni , Eric Dong , Zeng Star , Gerd Hoffmann , Rahul Kumar , Kinney Michael D References: <20240206075804.15152-1-jiaxin.wu@intel.com> <20240206075804.15152-2-jiaxin.wu@intel.com> From: "Laszlo Ersek" In-Reply-To: <20240206075804.15152-2-jiaxin.wu@intel.com> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.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,lersek@redhat.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: j1llZVL2AIZijLCjxyIsszx5x7686176AA= Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=Ru6ragXD; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=redhat.com (policy=none); spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io On 2/6/24 08:58, Jiaxin Wu wrote: > Use MAX_UINT32 directly instead of typecasting from signed > to unsigned value. >=20 > 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(-) >=20 > diff --git a/UefiCpuPkg/PiSmmCpuDxeSmm/MpService.c b/UefiCpuPkg/PiSmmCpuD= xeSmm/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 (); > =20 > // > - // 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 =3D (UINT32)-1; > + mSmmMpSyncData->BspIndex =3D MAX_UINT32; > } > =20 > // > // Allow APs to check in from this point on > // > @@ -745,11 +745,11 @@ APHandler ( > =20 > if (!(*mSmmMpSyncData->InsideSmm)) { > // > // BSP timeout in the first round > // > - if (mSmmMpSyncData->BspIndex !=3D -1) { > + if (mSmmMpSyncData->BspIndex !=3D MAX_UINT32) { > // > // BSP Index is known > // Existing AP is in SMI now but BSP not in, so, try bring BSP in = SMM. > // > BspIndex =3D mSmmMpSyncData->BspIndex; > @@ -1654,11 +1654,11 @@ SmiRendezvous ( > // > // Platform hook fails to determine, use default BSP electio= n method > // > InterlockedCompareExchange32 ( > (UINT32 *)&mSmmMpSyncData->BspIndex, > - (UINT32)-1, > + MAX_UINT32, > (UINT32)CpuIndex > ); > } > } > } > @@ -1852,13 +1852,13 @@ InitializeMpSyncData ( > ZeroMem (mSmmMpSyncData, mSmmMpSyncDataSize); > mSmmMpSyncData->CpuData =3D (SMM_CPU_DATA_BLOCK *)((UINT8 *)mSm= mMpSyncData + sizeof (SMM_DISPATCHER_MP_SYNC_DATA)); > mSmmMpSyncData->CandidateBsp =3D (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 =3D (UINT32)-1; > + mSmmMpSyncData->BspIndex =3D MAX_UINT32; > } else { > // > // Use NonSMM BSP as SMM BSP > // > for (CpuIndex =3D 0; CpuIndex < gSmmCpuPrivate->SmmCoreEntryContex= t.NumberOfCpus; CpuIndex++) { Reviewed-by: Laszlo Ersek -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#115166): https://edk2.groups.io/g/devel/message/115166 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] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-