Skip to contentSkip to conversation

target-arm queue

GIT PULL Applied Peter Maydell 2 participants 3 messages Dec 5, 2016 – Dec 6, 2016

lore
Share & tools
lore
#0 lore raw

One patch for 2.8-rc3, which is Alex's partial revert of 1dd089d0 to fix A64 ldaxp.

thanks
-- PMM

The following changes since commit bc66cedb4141fb7588f2462c74310d8fb5dd4cf1:

Merge remote-tracking branch 'yongbok/tags/mips-20161204' into staging (2016-12-05 10:56:45 +0000)

are available in the git repository at:

git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20161205

for you to fetch changes up to 5460da501a57cd72eda6fec736d76539122e2f99:

target-arm/translate-a64: fix gen_load_exclusive (2016-12-05 17:52:01 +0000)

----------------------------------------------------------------
target-arm queue:
* fix gen_load_exclusive handling of ldaxp

----------------------------------------------------------------
Alex Bennée (1):
target-arm/translate-a64: fix gen_load_exclusive

 target-arm/translate-a64.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/1] target-arm/translate-a64: fix gen_load_exclusive

From: Alex Bennée <[email protected]>

While testing rth's latest TCG patches with risu I found ldaxp was broken. Investigating further I found it was broken by 1dd089d0 when the cmpxchg atomic work was merged. As part of that change the code attempted to be clever by doing a single 64 bit load and then shuffle the data around to set the two 32 bit registers.

As I couldn't quite follow the endian magic I've simply partially reverted the change to the original code gen_load_exclusive code. This doesn't affect the cmpxchg functionality as that is all done on in gen_store_exclusive part which is untouched.

I've also restored the comment that was removed (with a slight tweak to mention cmpxchg).

Message-id: [email protected]

---
 target-arm/translate-a64.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)
target-arm/translate-a64.c +19 -23
index de48747..6dc27a6 100644
@@ -1839,41 +1839,37 @@ static void disas_b_exc_sys(DisasContext *s, uint32_t insn)
     }
 }
 
+/*
+ * Load/Store exclusive instructions are implemented by remembering
+ * the value/address loaded, and seeing if these are the same
+ * when the store is performed. This is not actually the architecturally
+ * mandated semantics, but it works for typical guest code sequences
+ * and avoids having to monitor regular stores.
+ *
+ * The store exclusive uses the atomic cmpxchg primitives to avoid
+ * races in multi-threaded linux-user and when MTTCG softmmu is
+ * enabled.
+ */
 static void gen_load_exclusive(DisasContext *s, int rt, int rt2,
                                TCGv_i64 addr, int size, bool is_pair)
 {
     TCGv_i64 tmp = tcg_temp_new_i64();
-    TCGMemOp be = s->be_data;
+    TCGMemOp memop = s->be_data + size;
 
     g_assert(size <= 3);
+    tcg_gen_qemu_ld_i64(tmp, addr, get_mem_index(s), memop);
+
     if (is_pair) {
+        TCGv_i64 addr2 = tcg_temp_new_i64();
         TCGv_i64 hitmp = tcg_temp_new_i64();
 
-        if (size == 3) {
-            TCGv_i64 addr2 = tcg_temp_new_i64();
-
-            tcg_gen_qemu_ld_i64(tmp, addr, get_mem_index(s),
-                                MO_64 | MO_ALIGN_16 | be);
-            tcg_gen_addi_i64(addr2, addr, 8);
-            tcg_gen_qemu_ld_i64(hitmp, addr2, get_mem_index(s),
-                                MO_64 | MO_ALIGN | be);
-            tcg_temp_free_i64(addr2);
-        } else {
-            g_assert(size == 2);
-            tcg_gen_qemu_ld_i64(tmp, addr, get_mem_index(s),
-                                MO_64 | MO_ALIGN | be);
-            if (be == MO_LE) {
-                tcg_gen_extr32_i64(tmp, hitmp, tmp);
-            } else {
-                tcg_gen_extr32_i64(hitmp, tmp, tmp);
-            }
-        }
-
+        g_assert(size >= 2);
+        tcg_gen_addi_i64(addr2, addr, 1 << size);
+        tcg_gen_qemu_ld_i64(hitmp, addr2, get_mem_index(s), memop);
+        tcg_temp_free_i64(addr2);
         tcg_gen_mov_i64(cpu_exclusive_high, hitmp);
         tcg_gen_mov_i64(cpu_reg(s, rt2), hitmp);
         tcg_temp_free_i64(hitmp);
-    } else {
-        tcg_gen_qemu_ld_i64(tmp, addr, get_mem_index(s), size | MO_ALIGN | be);
     }
 
     tcg_gen_mov_i64(cpu_exclusive_val, tmp);
Signature · 1 line
2.7.4
#2 lore raw
In reply to Peter Maydell
Quoted 22 lines · Peter Maydell

One patch for 2.8-rc3, which is Alex's partial revert of 1dd089d0 to fix A64 ldaxp.

thanks
-- PMM

The following changes since commit bc66cedb4141fb7588f2462c74310d8fb5dd4cf1:

Merge remote-tracking branch 'yongbok/tags/mips-20161204' into staging (2016-12-05 10:56:45 +0000)

are available in the git repository at:

git://git.linaro.org/people/pmaydell/qemu-arm.git tags/pull-target-arm-20161205

for you to fetch changes up to 5460da501a57cd72eda6fec736d76539122e2f99:

target-arm/translate-a64: fix gen_load_exclusive (2016-12-05 17:52:01 +0000)

----------------------------------------------------------------
target-arm queue:
* fix gen_load_exclusive handling of ldaxp

Quoted 7 lines

----------------------------------------------------------------
Alex Bennée (1):
target-arm/translate-a64: fix gen_load_exclusive

 target-arm/translate-a64.c | 42 +++++++++++++++++++-----------------------
 1 file changed, 19 insertions(+), 23 deletions(-)

Thanks, applied to my staging tree:
https://github.com/stefanha/qemu/commits/staging

Stefan