From patchwork Mon Jun 27 19:02:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emilio Cota X-Patchwork-Id: 9201157 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A6A49607D3 for ; Mon, 27 Jun 2016 19:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9590E285B3 for ; Mon, 27 Jun 2016 19:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 89E68285B9; Mon, 27 Jun 2016 19:16:11 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34D5C285B3 for ; Mon, 27 Jun 2016 19:16:11 +0000 (UTC) Received: from localhost ([::1]:60573 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHc0w-0005Dk-7f for patchwork-qemu-devel@patchwork.kernel.org; Mon, 27 Jun 2016 15:16:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58995) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHboF-0006lI-FY for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHboB-0008NA-5o for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:03:02 -0400 Received: from out3-smtp.messagingengine.com ([66.111.4.27]:44733) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHbo8-0008CC-RJ for qemu-devel@nongnu.org; Mon, 27 Jun 2016 15:02:59 -0400 Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailout.nyi.internal (Postfix) with ESMTP id AA5BF20A04; Mon, 27 Jun 2016 15:02:35 -0400 (EDT) Received: from frontend1 ([10.202.2.160]) by compute1.internal (MEProxy); Mon, 27 Jun 2016 15:02:35 -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=T6KqxCl2hZ3AQAOYwaxfCXzDAYg =; b=CN3NDV4IWNT+Q71UNWypX4kLF6VTfuoUvlOyL8SlCNXQhLMN0lJJoMmB9J0 3DWd026CwcZG9HO2NUNFpAvmdwUOQbmoAhCz7TK+alLLAvhgEooDWYEUXdVa1KqR Q680HRGeTA6iwslEdF+q/IX85yWxR36p11SI+uKp6LAKm7HQ= 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=T6Kq xCl2hZ3AQAOYwaxfCXzDAYg=; b=tb0za2GzoVx0pb1Oa83Jo2j2ZCvYWD+Z34YB owT+/aCtoe5mH4XXPs0lUvcyq71vvg+d8cXKUO8msGpptYD4hJaEQnlOvbOMowcN GbSyE1A4Ky+z+xopyltZULZWiWm6m8K8YxCbRaUblllsUXhXpDb818fU2ICjNT9J 1S03rhQ= X-Sasl-enc: 3KnBAvUibgyetRS0JcQch500ZqxorJieOXmPFpnhcpDw 1467054155 Received: from localhost (flamenco.cs.columbia.edu [128.59.20.216]) by mail.messagingengine.com (Postfix) with ESMTPA id 558B8F2022; Mon, 27 Jun 2016 15:02:35 -0400 (EDT) From: "Emilio G. Cota" To: QEMU Developers , MTTCG Devel Date: Mon, 27 Jun 2016 15:02:07 -0400 Message-Id: <1467054136-10430-22-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 21/30] target-arm: add cmpxchg helpers 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Emilio G. Cota --- target-arm/helper.c | 35 +++++++++++++++++++++++++++++++++++ target-arm/helper.h | 5 +++++ 2 files changed, 40 insertions(+) diff --git a/target-arm/helper.c b/target-arm/helper.c index 1f9cdac..b38bfbd 100644 --- a/target-arm/helper.c +++ b/target-arm/helper.c @@ -9409,3 +9409,38 @@ uint32_t HELPER(crc32c)(uint32_t acc, uint32_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_CMPXCHG(NAME) \ +uint32_t \ +HELPER(NAME)(CPUARMState *env, uint32_t addr, uint64_t old64, uint32_t new) \ +{ \ + uint32_t old = old64; \ + uint32_t read; \ + \ + read = glue(glue(cpu_, NAME), _data_ra)(env, addr, old, new, GETPC()); \ + return read != old; \ +} +GEN_CMPXCHG(cmpxchgb) +GEN_CMPXCHG(cmpxchgw) +GEN_CMPXCHG(cmpxchgl) +#undef GEN_CMPXCHG + +/* + * Returns 0 on success; 1 otherwise. + * Bringing in @new_lo and @new_hi is unusual given that @old is 64-bit, + * but we do it to save a few TCG instructions. + */ +uint32_t HELPER(cmpxchgq)(CPUARMState *env, uint32_t addr, uint64_t old, + uint32_t new_lo, uint32_t new_hi) +{ + uint64_t read; + uint64_t new; + + new = new_hi; + new <<= 32; + new |= new_lo; + + read = cpu_cmpxchgq_data_ra(env, addr, old, new, GETPC()); + return read != old; +} diff --git a/target-arm/helper.h b/target-arm/helper.h index 84aa637..f3d6f26 100644 --- a/target-arm/helper.h +++ b/target-arm/helper.h @@ -537,6 +537,11 @@ DEF_HELPER_2(dc_zva, void, env, i64) DEF_HELPER_FLAGS_2(neon_pmull_64_lo, TCG_CALL_NO_RWG_SE, i64, i64, i64) DEF_HELPER_FLAGS_2(neon_pmull_64_hi, TCG_CALL_NO_RWG_SE, i64, i64, i64) +DEF_HELPER_4(cmpxchgb, i32, env, i32, i64, i32) +DEF_HELPER_4(cmpxchgw, i32, env, i32, i64, i32) +DEF_HELPER_4(cmpxchgl, i32, env, i32, i64, i32) +DEF_HELPER_5(cmpxchgq, i32, env, i32, i64, i32, i32) + #ifdef TARGET_AARCH64 #include "helper-a64.h" #endif