From nobody Tue Oct 28 04:16:43 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1513986891515630.8628726292758; Fri, 22 Dec 2017 15:54:51 -0800 (PST) Received: from localhost ([::1]:39486 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSX9A-00065x-D1 for importer@patchew.org; Fri, 22 Dec 2017 18:54:36 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54332) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eSX8G-0005jT-64 for qemu-devel@nongnu.org; Fri, 22 Dec 2017 18:53:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eSX8D-0003vG-3s for qemu-devel@nongnu.org; Fri, 22 Dec 2017 18:53:40 -0500 Received: from heinz.dinsnail.net ([2a01:238:43b4:3200:9392:5dcc:2f0e:a960]:55414) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eSX8C-0003sJ-T3; Fri, 22 Dec 2017 18:53:37 -0500 Received: from localhost (p5DD4E4D5.dip0.t-ipconnect.de [93.212.228.213]) by heinz.dinsnail.net (8.14.9/8.14.9) with ESMTP id vBMNqv5n000616 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Sat, 23 Dec 2017 00:52:58 +0100 From: Michael Weiser To: qemu-arm@nongnu.org Date: Fri, 22 Dec 2017 20:23:00 +0100 Message-Id: <20171222192300.46997-1-michael.weiser@gmx.de> X-Mailer: git-send-email 2.14.3 (Apple Git-98) X-dinsnail-net-MailScanner-Information: Please contact the ISP for more information X-dinsnail-net-MailScanner-ID: vBMNqv5n000616 X-dinsnail-net-MailScanner: Found to be clean X-dinsnail-net-MailScanner-SpamScore: ssss X-dinsnail-net-MailScanner-From: michael@dinsnail.net X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a01:238:43b4:3200:9392:5dcc:2f0e:a960 Subject: [Qemu-devel] [RFC PATCH] target/arm: Fix stlxp for aarch64_be X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Michael Weiser , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In big-endian mode, stlxp would not only store the individual doublewords big-endian but also swap them in memory. This does not correspond to how ld= xp behaves nor how native code expects the result of stlxp to be stored in mem= ory. Also, when comparing if the values in memory still match what was previously loaded by ldxp, stlxp would also swap the values loaded from memory, making= the comparison against the previously loaded value fail always. With this change an aarch64_be Linux 4.14.4 kernel succeeds to boots up in system emulation mode. This change makes paired_cmpxchg64 helpers differ only in endianness handli= ng. It might be possible to fold them into a single routine using variables and function pointers or get rid of them completely in favour of tcg_gen_-routi= nes. Both is currently beyond my skill level, though. Signed-off-by: Michael Weiser --- target/arm/helper-a64.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/target/arm/helper-a64.c b/target/arm/helper-a64.c index b84ebcae6e..bab6446588 100644 --- a/target/arm/helper-a64.c +++ b/target/arm/helper-a64.c @@ -532,8 +532,8 @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *env= , uint64_t addr, =20 success =3D int128_eq(oldv, cmpv); if (success) { - stq_be_p(haddr + 0, int128_gethi(newv)); - stq_be_p(haddr + 1, int128_getlo(newv)); + stq_be_p(haddr + 0, int128_getlo(newv)); + stq_be_p(haddr + 1, int128_gethi(newv)); } helper_retaddr =3D 0; #else @@ -541,14 +541,14 @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *e= nv, uint64_t addr, TCGMemOpIdx oi0 =3D make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx); TCGMemOpIdx oi1 =3D make_memop_idx(MO_BEQ, mem_idx); =20 - o1 =3D helper_be_ldq_mmu(env, addr + 0, oi0, ra); - o0 =3D helper_be_ldq_mmu(env, addr + 8, oi1, ra); + o0 =3D helper_be_ldq_mmu(env, addr + 0, oi0, ra); + o1 =3D helper_be_ldq_mmu(env, addr + 8, oi1, ra); oldv =3D int128_make128(o0, o1); =20 success =3D int128_eq(oldv, cmpv); if (success) { - helper_be_stq_mmu(env, addr + 0, int128_gethi(newv), oi1, ra); - helper_be_stq_mmu(env, addr + 8, int128_getlo(newv), oi1, ra); + helper_be_stq_mmu(env, addr + 0, int128_getlo(newv), oi1, ra); + helper_be_stq_mmu(env, addr + 8, int128_gethi(newv), oi1, ra); } #endif } --=20 2.15.1