From nobody Wed Apr 9 04:40:26 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=flygoat.com ARC-Seal: i=1; a=rsa-sha256; t=1735248026; cv=none; d=zohomail.com; s=zohoarc; b=Pml17m0xUz0HqB1YyNIdIy0PW1x+utxOsGlxMLp9zo0XJ+wQ84hJDE0SR93gh1cdZi7OigcpuV3l0mZLDv7W9o9KLzs0qUOub09OPvbXh1wsO9fOfo3oVZNbzDHmGZdxlc89EXKdqttWtjL4hF29WrNCJp2Im9rsqfzihr3/8R8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1735248026; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=HzRGBpSsuGYsqp1nebQkdwxhC9+0p8sAf3ZNP4r9fJ8=; b=cshO0FbADKjyM5IdnS1wUZ1utV3zJH2dd/Pcr5awzbwo8x8dFLCQzjxTxkROghyGUnt0j5uMmQA0xYletR/0UF+wq5k0lub3VT1Yn28d55QfJNFon1w7aEc8nQLKlo2wtx2Mr8xLqDdfXlPa+O6s5SSjwxexU7p7I/kWe6jBfEA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1735248025947601.7330204037129; Thu, 26 Dec 2024 13:20:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1tQvGp-0003de-UV; Thu, 26 Dec 2024 16:19:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQvGo-0003dI-6G for qemu-devel@nongnu.org; Thu, 26 Dec 2024 16:19:50 -0500 Received: from fhigh-a4-smtp.messagingengine.com ([103.168.172.155]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1tQvGm-0002w8-AQ for qemu-devel@nongnu.org; Thu, 26 Dec 2024 16:19:49 -0500 Received: from phl-compute-05.internal (phl-compute-05.phl.internal [10.202.2.45]) by mailfhigh.phl.internal (Postfix) with ESMTP id AE62B1140114; Thu, 26 Dec 2024 16:19:47 -0500 (EST) Received: from phl-mailfrontend-01 ([10.202.2.162]) by phl-compute-05.internal (MEProxy); Thu, 26 Dec 2024 16:19:47 -0500 Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 26 Dec 2024 16:19:45 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:content-type:date :date:from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to; s=fm3; t=1735247987; x=1735334387; bh=HzRGBpSsuGYsqp1nebQkdwxhC9+0p8sAf3ZNP4r9fJ8=; b= HlSqOc/RYxOZROJoNPzXNZPzoGV3Rv3dMvP4Wm/Oq/qDDQoQEnMs/iEudIYq3JQW fkj0D1yn1sfwmJztwo8xPPzQGWgrv3qlb/ykP1tJa/yYCmsjUZjIS3tfcEYjwgs6 9QOznPXQC5gaFxaB3GZf80wyRAVV1qQDhYITSRv3k05IFU/lRCMDyENyAH2RC344 +nu6oy9Yb/S5UZLWt4qnr3+gCAQ4pYuW8EvFLV6+8qGvXeE3tUI/CgaTTHh2nuVR T5AbUdmeJw2SGu4PzNKSUDxZemZ4ZKPMaCErhQ62z1yv4c0sAEQKwHusP1M/K80Y 07DdpsbLgtpAW6cl+BcHGg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:content-type:date:date:feedback-id:feedback-id :from:from:in-reply-to:in-reply-to:message-id:mime-version :references:reply-to:subject:subject:to:to:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; t=1735247987; x= 1735334387; bh=HzRGBpSsuGYsqp1nebQkdwxhC9+0p8sAf3ZNP4r9fJ8=; b=Z 0HpOQO4e8Litvp47IYfxq5AIqMs9NC2gBAzKcEIzCN0ffNf87KWpbTnBt+JBHj45 kbdbi81fX3Rf7R4YonIJfdSiWmXxz7qig5fr8azx8znq2i8brzzIHYXf7nremc+L 7heF7N/uMXwUaGMduP0dshkAS7rHe9B3klkh1PyUTMW+1bayPWbCxlu55qaBg6cX e4ymMKYwOqyl2nuBr13JCKMFBls5lflVH4Yfiqez8O9nBYpRdotKt7S5IHwQ0IGt /4suikVVltoTgMyb1bYhnYOp7K5RIljeq96AlG81w/kk00yk49PnFObD8kQaFqrg 54InmLhwyjihX/AtjYufg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeefuddruddukedgudegjecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpggftfghnshhusghstghrihgsvgdp uffrtefokffrpgfnqfghnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivg hnthhsucdlqddutddtmdenucfjughrpefhfffugggtgffkfhgjvfevofesthejredtredt jeenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhgsehflh ihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpedvkeeihfefveekueevteefleff keegudeghfdtuddugefhueevgeffgedukeejleenucevlhhushhtvghrufhiiigvpedune curfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihghhorght rdgtohhmpdhnsggprhgtphhtthhopeduvddpmhhouggvpehsmhhtphhouhhtpdhrtghpth htohepmhgrohgsihgsoheslhhoohhnghhsohhnrdgtnhdprhgtphhtthhopehmrghrtggv lhdrrghpfhgvlhgsrghumhesghhmrghilhdrtghomhdprhgtphhtthhopehpsghonhiiih hnihesrhgvughhrghtrdgtohhmpdhrtghpthhtohepghgrohhsohhngheslhhoohhnghhs ohhnrdgtnhdprhgtphhtthhopegvsghlrghkvgesrhgvughhrghtrdgtohhmpdhrtghpth htohepjhhirgiguhhnrdihrghnghesfhhlhihgohgrthdrtghomhdprhgtphhtthhopehq vghmuhdquggvvhgvlhesnhhonhhgnhhurdhorhhgpdhrtghpthhtohepfigrnhhghigrnh grnhehheeshhhurgifvghirdgtohhmpdhrtghpthhtohepiihhrghouddrlhhiuhesihhn thgvlhdrtghomh X-ME-Proxy: Feedback-ID: ifd894703:Fastmail From: Jiaxun Yang Date: Thu, 26 Dec 2024 21:19:33 +0000 Subject: [PATCH v2 02/23] target/loongarch: Fix address generation for gen_sc MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241226-la32-fixes1-v2-2-0414594f8cb5@flygoat.com> References: <20241226-la32-fixes1-v2-0-0414594f8cb5@flygoat.com> In-Reply-To: <20241226-la32-fixes1-v2-0-0414594f8cb5@flygoat.com> To: qemu-devel@nongnu.org Cc: Song Gao , Bibo Mao , Eric Blake , Markus Armbruster , Eduardo Habkost , Marcel Apfelbaum , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Yanan Wang , Zhao Liu , Paolo Bonzini , Jiaxun Yang X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1715; i=jiaxun.yang@flygoat.com; h=from:subject:message-id; bh=JXml0K3ROVIscLytx9HCnpVchfiE4wBfBikTFNxlvXg=; b=owGbwMvMwCXmXMhTe71c8zDjabUkhvTcE9meQU9vBm/jmtv7TTSD14h5afh17dNHU1e23Yvjm 7GHhSe6o5SFQYyLQVZMkSVEQKlvQ+PFBdcfZP2BmcPKBDKEgYtTACYiIcDI8CU1xf/e5sk1J41n /n2WuvhhYVjpnNu7Y95wZlpnVfYnXmL4n5Facvrdtm1Rh/Vnlhs41UddsLska7le4cv7fTnfxTf 18wMA X-Developer-Key: i=jiaxun.yang@flygoat.com; a=openpgp; fpr=980379BEFEBFBF477EA04EF9C111949073FC0F67 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=103.168.172.155; envelope-from=jiaxun.yang@flygoat.com; helo=fhigh-a4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @flygoat.com) X-ZM-MESSAGEID: 1735248027487116600 gen_sc should use make_address_i to obtain source address to ensure that address is properly truncated. Another temp value is created in middle to avoid data corruption as make_address_i may return the same memory location as src1. Signed-off-by: Jiaxun Yang Reviewed-by: Richard Henderson --- target/loongarch/tcg/insn_trans/trans_atomic.c.inc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/loongarch/tcg/insn_trans/trans_atomic.c.inc b/target/lo= ongarch/tcg/insn_trans/trans_atomic.c.inc index 974bc2a70feddbf021a07b19a0859781eb3a11c4..c35f6f3ce47877ab6ad84fa2cbc= 50b46c0b23ad1 100644 --- a/target/loongarch/tcg/insn_trans/trans_atomic.c.inc +++ b/target/loongarch/tcg/insn_trans/trans_atomic.c.inc @@ -22,13 +22,12 @@ static bool gen_sc(DisasContext *ctx, arg_rr_i *a, MemO= p mop) TCGv dest =3D gpr_dst(ctx, a->rd, EXT_NONE); TCGv src1 =3D gpr_src(ctx, a->rj, EXT_NONE); TCGv src2 =3D gpr_src(ctx, a->rd, EXT_NONE); - TCGv t0 =3D tcg_temp_new(); + TCGv t0 =3D make_address_i(ctx, src1, a->imm); TCGv val =3D tcg_temp_new(); =20 TCGLabel *l1 =3D gen_new_label(); TCGLabel *done =3D gen_new_label(); =20 - tcg_gen_addi_tl(t0, src1, a->imm); tcg_gen_brcond_tl(TCG_COND_EQ, t0, cpu_lladdr, l1); tcg_gen_movi_tl(dest, 0); tcg_gen_br(done); @@ -36,6 +35,7 @@ static bool gen_sc(DisasContext *ctx, arg_rr_i *a, MemOp = mop) gen_set_label(l1); tcg_gen_mov_tl(val, src2); /* generate cmpxchg */ + t0 =3D tcg_temp_new(); tcg_gen_atomic_cmpxchg_tl(t0, cpu_lladdr, cpu_llval, val, ctx->mem_idx, mop); tcg_gen_setcond_tl(TCG_COND_EQ, dest, t0, cpu_llval); --=20 2.43.0