From patchwork Mon Jun 27 19:02:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 641207 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rddwh4HjMz9ssM for ; Tue, 28 Jun 2016 05:17:08 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=braap.org header.i=@braap.org header.b=T21isDIb; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=messagingengine.com header.i=@messagingengine.com header.b=nxDvOL05; dkim-atps=neutral Received: from localhost ([::1]:60576 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHc1q-0006m6-Fx for incoming@patchwork.ozlabs.org; Mon, 27 Jun 2016 15:17:06 -0400 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 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 9C64520390; Mon, 27 Jun 2016 15:02:36 -0400 (EDT) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Mon, 27 Jun 2016 15:02:36 -0400 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=braap.org; h=cc :date:from:in-reply-to:message-id:references:subject:to :x-sasl-enc:x-sasl-enc; s=mesmtp; bh=iZ91XsedYccK1UJ7op8KXsuGAnY =; b=T21isDIbXmdaohQHPhxoYjNI/w7K8F2W7DuRZXCDPJrGWQwNjujIonyQM86 HNE9cSA2JQoVMMTTIx/1SUH0x0z3RCseVY6hTKYqI/BsFvWM1XVmZFKgaKTvgbsr YR87EvihwpXvwNMz841j0G+rjNikqcZZbvbU2gjCMOPk9mVA= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=cc:date:from:in-reply-to:message-id :references:subject:to:x-sasl-enc:x-sasl-enc; s=smtpout; bh=iZ91 XsedYccK1UJ7op8KXsuGAnY=; b=nxDvOL05GkPjhnWBHGTcsBHJUNtcdcRVPIpN tGNyVpULDg8Jhzpj+ujNKSOcAxD7zgFxlXKSHgIKkLEvsMPqUPlWPHMnXnlgUhdo f/KnaLnmkCHJIKR1iGI/uY7HK03N+HE9fg2R8BLwCYLHRhHFmvAI1DQX6nolmFpc fgCXecQ= X-Sasl-enc: QK78NVRPfvbKAf8iXOwHth4kBDeWlXj+4wCKQqLbi/uC 1467054156 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 38898CC078; Mon, 27 Jun 2016 15:02:36 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Mon, 27 Jun 2016 15:02:12 -0400 Message-Id: <1467054136-10430-27-git-send-email-cota@braap.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1467054136-10430-1-git-send-email-cota@braap.org> References: <1467054136-10430-1-git-send-email-cota@braap.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 66.111.4.27 Subject: [Qemu-devel] [RFC 26/30] target-arm: add cmpxchg helpers for aarch64 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 , Alvise Rigo , Sergey Fedorov , Paolo Bonzini , =?UTF-8?q?Alex=20Benn=C3=A9e?= , Richard Henderson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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)