From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58951) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHboE-0006jt-Lh for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHboC-0008OG-60 for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:01 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:54046) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHbo9-0008Gn-Um for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:00 -0400 From: "Emilio G. Cota" Date: Mon, 27 Jun 2016 15:02:12 -0400 Message-Id: <1467054136-10430-27-git-send-email-cota@braap.org> In-Reply-To: <1467054136-10430-1-git-send-email-cota@braap.org> References: <1467054136-10430-1-git-send-email-cota@braap.org> Subject: [Qemu-devel] [RFC 26/30] target-arm: add cmpxchg helpers for aarch64 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: QEMU Developers , MTTCG Devel Cc: =?UTF-8?q?Alex=20Benn=C3=A9e?= , Paolo Bonzini , Richard Henderson , Sergey Fedorov , Alvise Rigo , Peter Maydell Signed-off-by: Emilio G. Cota --- target-arm/helper-a64.c | 50 +++++++++++++++++++++++++++++++++++++++++++++++++ target-arm/helper-a64.h | 6 ++++++ 2 files changed, 56 insertions(+) diff --git a/target-arm/helper-a64.c b/target-arm/helper-a64.c index 41e48a4..f859e8e 100644 --- a/target-arm/helper-a64.c +++ b/target-arm/helper-a64.c @@ -19,6 +19,8 @@ #include "qemu/osdep.h" #include "cpu.h" +#include "exec/exec-all.h" +#include "exec/cpu_ldst.h" #include "exec/gdbstub.h" #include "exec/helper-proto.h" #include "qemu/host-utils.h" @@ -444,3 +446,51 @@ uint64_t HELPER(crc32c_64)(uint64_t acc, uint64_t val, uint32_t bytes) /* Linux crc32c converts the output to one's complement. */ return crc32c(acc, buf, bytes) ^ 0xffffffff; } + +/* returns 0 on success; 1 otherwise */ +#define GEN_CMPXCHG64(SUFFIX) \ +uint64_t \ +HELPER(glue(cmpxchg64, SUFFIX))(CPUARMState *env, uint64_t addr, uint64_t old, \ + uint64_t new) \ +{ \ + uint64_t read; \ + \ + read = glue(glue(glue(cpu_, cmpxchg), SUFFIX), \ + _data_ra)(env, addr, old, new, GETPC()); \ + return read != old; \ +} + +GEN_CMPXCHG64(b) +GEN_CMPXCHG64(w) +GEN_CMPXCHG64(l) +GEN_CMPXCHG64(q) +#undef GEN_CMPXCHG64 + +/* returns 0 on success; 1 otherwise */ +uint64_t +HELPER(paired_cmpxchg64l)(CPUARMState *env, uint64_t addr, uint64_t old_lo, + uint64_t old_hi, uint64_t new_lo, uint64_t new_hi) +{ + uint64_t old, new; + uint64_t read; + + old = old_hi; + old <<= 32; + old |= old_lo; + + new = new_hi; + new <<= 32; + new |= new_lo; + + read = cpu_cmpxchgq_data_ra(env, addr, old, new, GETPC()); + return read != old; +} + +/* returns 0 on success; 1 otherwise */ +uint64_t +HELPER(paired_cmpxchg64q)(CPUARMState *env, uint64_t addr, uint64_t old_lo, + uint64_t old_hi, uint64_t new_lo, uint64_t new_hi) +{ + return !cpu_cmpxchgo_data_ra(env, addr, &old_lo, &old_hi, new_lo, new_hi, + GETPC()); +} diff --git a/target-arm/helper-a64.h b/target-arm/helper-a64.h index 1d3d10f..e7880cf 100644 --- a/target-arm/helper-a64.h +++ b/target-arm/helper-a64.h @@ -46,3 +46,9 @@ DEF_HELPER_FLAGS_2(frecpx_f32, TCG_CALL_NO_RWG, f32, f32, ptr) DEF_HELPER_FLAGS_2(fcvtx_f64_to_f32, TCG_CALL_NO_RWG, f32, f64, env) DEF_HELPER_FLAGS_3(crc32_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) DEF_HELPER_FLAGS_3(crc32c_64, TCG_CALL_NO_RWG_SE, i64, i64, i64, i32) +DEF_HELPER_4(cmpxchg64b, i64, env, i64, i64, i64) +DEF_HELPER_4(cmpxchg64w, i64, env, i64, i64, i64) +DEF_HELPER_4(cmpxchg64l, i64, env, i64, i64, i64) +DEF_HELPER_4(cmpxchg64q, i64, env, i64, i64, i64) +DEF_HELPER_6(paired_cmpxchg64l, i64, env, i64, i64, i64, i64, i64) +DEF_HELPER_6(paired_cmpxchg64q, i64, env, i64, i64, i64, i64, i64) -- 2.5.0