qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Michael Weiser <michael.weiser@gmx.de>
To: qemu-arm@nongnu.org
Cc: Michael Weiser <michael.weiser@gmx.de>,
	Peter Maydell <peter.maydell@linaro.org>,
	qemu-devel@nongnu.org
Subject: [Qemu-devel] [RFC PATCH] target/arm: Fix stlxp for aarch64_be
Date: Fri, 22 Dec 2017 20:23:00 +0100	[thread overview]
Message-ID: <20171222192300.46997-1-michael.weiser@gmx.de> (raw)

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 ldxp
behaves nor how native code expects the result of stlxp to be stored in memory.

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 handling.
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_-routines.
Both is currently beyond my skill level, though.

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
---
 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,
 
         success = 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 = 0;
 #else
@@ -541,14 +541,14 @@ static uint64_t do_paired_cmpxchg64_be(CPUARMState *env, uint64_t addr,
         TCGMemOpIdx oi0 = make_memop_idx(MO_BEQ | MO_ALIGN_16, mem_idx);
         TCGMemOpIdx oi1 = make_memop_idx(MO_BEQ, mem_idx);
 
-        o1 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);
-        o0 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);
+        o0 = helper_be_ldq_mmu(env, addr + 0, oi0, ra);
+        o1 = helper_be_ldq_mmu(env, addr + 8, oi1, ra);
         oldv = int128_make128(o0, o1);
 
         success = 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
     }
-- 
2.15.1

                 reply	other threads:[~2017-12-22 23:53 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171222192300.46997-1-michael.weiser@gmx.de \
    --to=michael.weiser@gmx.de \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).