From nobody Fri Dec 19 20:36:11 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+104192+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104192+1787277+3901457@groups.io ARC-Seal: i=1; a=rsa-sha256; t=1683393862; cv=none; d=zohomail.com; s=zohoarc; b=OI4BPj9uABPpskQDzMn5YORdeXliMThtevasmDpX0eqpkjyk5QN5lR1+mHnbLls6IO8Md8GOruOIqWbIjrlEq1EcZFsy3KxnntUKpDsJQ1vFsBLdxRjbeiNqygTa5pHKR/W8rJLeM4o66St/JRDBN4mtSoVXIBPpGb31MAttjd8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1683393862; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=8+KX5njHH+rxCk7y8Qd3YzvRtMP6R6K5NuPRjig+eTE=; b=R2Gb6J3Tl5t/vKciKoD3VGV31tddHUcwJhGAeewod4sqrrBGi9o1vrpQRdu1j3nCsNzCXRNxlxPf/ebXINzxXpC0JtcPIa9cA6NgEnMiLZhY1RM4aoCDp/dbPiVbHECbGAfHb9qVjXRiJOYIFr0R4rEu+Y/a1j3QxSObGB/mSVA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+104192+1787277+3901457@groups.io Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1683393862575435.38137066525167; Sat, 6 May 2023 10:24:22 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id 6xgZYY1788612xATaF3DAoQp; Sat, 06 May 2023 10:24:22 -0700 X-Received: from out3-smtp.messagingengine.com (out3-smtp.messagingengine.com [66.111.4.27]) by mx.groups.io with SMTP id smtpd.web11.38492.1683393861585270438 for ; Sat, 06 May 2023 10:24:21 -0700 X-Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id EDE6B5C0253; Sat, 6 May 2023 13:24:20 -0400 (EDT) X-Received: from mailfrontend1 ([10.202.2.162]) by compute4.internal (MEProxy); Sat, 06 May 2023 13:24:20 -0400 X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrfeefgedgledtucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhephffvvefufffkofgjfhgggfestdekredtredttdenucfhrhhomheptfgvsggv tggtrgcuvehrrghnuceorhgvsggvtggtrgessghsughiohdrtghomheqnecuggftrfgrth htvghrnhepveegudefjeevkeeuffffgeefgfeghfeuveetgeeuieevvdekudfhhfeivddv ueelnecuffhomhgrihhnpehtihgrnhhotghorhgvrdhorhhgpdgrshhmshihnhgthhhroh hnihiirghtihhonhdrshgsnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehm rghilhhfrhhomheprhgvsggvtggtrgessghsughiohdrtghomh X-ME-Proxy: Feedback-ID: i5b994698:Fastmail X-Received: by mail.messagingengine.com (Postfix) with ESMTPA; Sat, 6 May 2023 13:24:19 -0400 (EDT) From: "Rebecca Cran" To: devel@edk2.groups.io, Andrew Fish , Leif Lindholm , Michael D Kinney , Liming Gao , Bob Feng , Yuwei Chen Cc: Dongyan Qian , Zhiguang Liu , Chao Li Subject: [edk2-devel] [PATCH v2 1/7] BaseSynchronizationLib: Fix LoongArch64 synchronization functions Date: Sat, 6 May 2023 11:23:56 -0600 Message-Id: <20230506172402.116-2-rebecca@bsdio.com> In-Reply-To: <20230506172402.116-1-rebecca@bsdio.com> References: <20230506172402.116-1-rebecca@bsdio.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: 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,rebecca@bsdio.com X-Gm-Message-State: S4DFjCyMTx2sXUqQrq0TQgFVx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1683393862; bh=c32fahza2/VCa1r3rwrAVT3Rzdr9m2x0a5XT1iMv9+g=; h=Cc:Date:From:Reply-To:Subject:To; b=rnG9fxN82QziVhkg7x3LAafgI58v83BroZJ++7WNhQixv6HXqAwaJsyoa6kLvvdbKP3 zjBFRSSvOMtKN9iEp5jLC41aaE2/5rcEER3tDB1qJEica9I0yNuaTRG6NjAugGsGURO6E tEdF7W3lfZLLRHACeeStYAEb/A2VetxfmDs= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1683393863123100002 Content-Type: text/plain; charset="utf-8" From: Dongyan Qian REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4432 There is a return value bug: The sc.w/sc.d instruction will destroy the reg_t0, use reg_t1 to avoid context reg_t0 being corrupted. Adjust Check that ptr align is UINT16. Optimize function SyncIncrement and SyncDecrement. Cc: Michael D Kinney Cc: Liming Gao Cc: Zhiguang Liu Cc: Chao Li Signed-off-by: Dongyan Qian Reviewed-by: Chao Li --- MdePkg/Library/BaseSynchronizationLib/LoongArch64/AsmSynchronization.S | 3= 0 ++++++++------------ MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c | = 2 +- 2 files changed, 13 insertions(+), 19 deletions(-) diff --git a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/AsmSynchroni= zation.S b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/AsmSynchroniza= tion.S index fdd50c54b5f3..03865bf2c966 100644 --- a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/AsmSynchronization.S +++ b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/AsmSynchronization.S @@ -53,9 +53,9 @@ ASM_PFX(AsmInternalSyncCompareExchange32): 1: ll.w $t0, $a0, 0x0 bne $t0, $a1, 2f - move $t0, $a2 - sc.w $t0, $a0, 0x0 - beqz $t0, 1b + move $t1, $a2 + sc.w $t1, $a0, 0x0 + beqz $t1, 1b b 3f 2: dbar 0 @@ -76,9 +76,9 @@ ASM_PFX(AsmInternalSyncCompareExchange64): 1: ll.d $t0, $a0, 0x0 bne $t0, $a1, 2f - move $t0, $a2 - sc.d $t0, $a0, 0x0 - beqz $t0, 1b + move $t1, $a2 + sc.d $t1, $a0, 0x0 + beqz $t1, 1b b 3f 2: dbar 0 @@ -94,13 +94,10 @@ AsmInternalSyncIncrement ( ) **/ ASM_PFX(AsmInternalSyncIncrement): - move $t0, $a0 - dbar 0 - ld.w $t1, $t0, 0x0 - li.w $t2, 1 - amadd.w $t1, $t2, $t0 + li.w $t0, 1 + amadd.w $zero, $t0, $a0 =20 - ld.w $a0, $t0, 0x0 + ld.w $a0, $a0, 0 jirl $zero, $ra, 0 =20 /** @@ -111,12 +108,9 @@ AsmInternalSyncDecrement ( ) **/ ASM_PFX(AsmInternalSyncDecrement): - move $t0, $a0 - dbar 0 - ld.w $t1, $t0, 0x0 - li.w $t2, -1 - amadd.w $t1, $t2, $t0 + li.w $t0, -1 + amadd.w $zero, $t0, $a0 =20 - ld.w $a0, $t0, 0x0 + ld.w $a0, $a0, 0 jirl $zero, $ra, 0 .end diff --git a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronizat= ion.c b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c index d696c8ce102f..6baf841c9b09 100644 --- a/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c +++ b/MdePkg/Library/BaseSynchronizationLib/LoongArch64/Synchronization.c @@ -81,7 +81,7 @@ InternalSyncCompareExchange16 ( volatile UINT32 *Ptr32; =20 /* Check that ptr is naturally aligned */ - ASSERT (!((UINT64)Value & (sizeof (Value) - 1))); + ASSERT (!((UINT64)Value & (sizeof (UINT16) - 1))); =20 /* Mask inputs to the correct size. */ Mask =3D (((~0UL) - (1UL << (0)) + 1) & (~0UL >> (64 - 1 -= ((sizeof (UINT16) * 8) - 1)))); --=20 2.40.0.windows.1 -=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 (#104192): https://edk2.groups.io/g/devel/message/104192 Mute This Topic: https://groups.io/mt/98728625/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-