Skip to contentSkip to conversation

target/arm: Fix int128_make128 lo, hi order in paired_cmpxchg64_be

RFC PATCH Applied Catherine Ho 3 participants 5 messages Feb 1, 2019 – Feb 14, 2019

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 target/arm: Fix int128_make128 lo, hi order in paired_cmpxchg64_be

The lo,hi order is different from the comments. And in commit 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128"), it changes the original code logic. So just restore the old code logic before this commit:
do_paired_cmpxchg64_be():

    cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
    newv = int128_make128(new_hi, new_lo);
Fixes 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128")

---
I didn't see any obvious real error case here, so set it as RFC

 target/arm/helper-a64.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
target/arm/helper-a64.c +2 -2
index 101fa6d3ea..70850e564d 100644
@@ -583,8 +583,8 @@ uint64_t HELPER(paired_cmpxchg64_be)(CPUARMState *env, uint64_t addr,
      * High and low need to be switched here because this is not actually a
      * 128bit store but two doublewords stored consecutively
      */
-    Int128 cmpv = int128_make128(env->exclusive_val, env->exclusive_high);
-    Int128 newv = int128_make128(new_lo, new_hi);
+    Int128 cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
+    Int128 newv = int128_make128(new_hi, new_lo);
     Int128 oldv;
     uintptr_t ra = GETPC();
     uint64_t o0, o1;
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Catherine Ho

The lo,hi order is different from the comments. And in commit 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128"), it changes the original code logic. So just restore the old code logic before this commit:
do_paired_cmpxchg64_be():

Quoted 7 lines
    cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
    newv = int128_make128(new_hi, new_lo);
Fixes 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128")

---

r~

#2 lore raw
Quoted 10 lines · Richard Henderson
Quoted 8 lines · Catherine Ho

The lo,hi order is different from the comments. And in commit 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128"), it changes the original code logic. So just restore the old code logic before this commit:
do_paired_cmpxchg64_be():

    cmpv = int128_make128(env->exclusive_high, env->exclusive_val);
    newv = int128_make128(new_hi, new_lo);
Quoted 7 lines
Quoted 4 lines
Fixes 1ec182c33379 ("target/arm: Convert to HAVE_CMPXCHG128")

---

Thanks. Richard: is this effectively a bugfix for big-endian guest code ?

-- PMM

#3 lore raw
Quoted 1 line · Peter Maydell

Thanks. Richard: is this effectively a bugfix for big-endian guest code ?

Yes.

r~

#4 lore raw
Quoted 5 lines · Richard Henderson
Quoted 1 line · Peter Maydell

Thanks. Richard: is this effectively a bugfix for big-endian guest code ?

Yes.

Thanks, applied to target-arm.next; I've added a line to the commit message to note that it only affects BE guests.

-- PMM