From patchwork Tue May 8 15:14:35 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135185 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp4523544lji; Tue, 8 May 2018 08:26:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq72tsQ2Uk9ZZskdsq1avErXm40qcK3/vbkOpw1z4QSdUwIgeeVyQHsozp5B3+uoKnHALXQ X-Received: by 10.55.194.65 with SMTP id j1mr1577414qkm.108.1525793198538; Tue, 08 May 2018 08:26:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525793198; cv=none; d=google.com; s=arc-20160816; b=UAP9AAgrSgFpFatYFSTTd3R/8TWqD/NKEyQPuuScx0xMnXqaF+NDSbk7tyJzHad9Wp FDvHrMxxDFeNRjAXpp5Q/qc34VSkfQ+3PTPV5O49IziYNXknaCEmKfGjT+SfO4MHG24O ovLB3zySb7DR95ui7QgGZqI5RTBZSvSeIiJR6hk0JkfDRk13YIvApJWJzkUPaJhw+IaW 18uFidRRM9F8U0XzPHNHeLopjeKjW/QElDn/+2ichxtwYHfIZA9ThvauywokCaDPoHu8 uMeGClJ5vClb8y4Huo2wQmUPPAbOCON+WqzNllgyuxGRZEXSfxvjZY/qB8lnkBtiEKZP qyNA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=wbBlVw1yD/e3VN1hxWuACb0Y7yVLZRzzJWwStnao8pNRi1BWgqdTEuyIv3ran74SVS yFSEOSo6RXgfi/n2ukGtf4nhMY0WtYODLjt8EYftmT3emtlhZpTAffRYEhKevQhk3uQT Ti7++C+RTbmnEmr42PNeq5Gd/QWEj0NsQkXm00IP6uOssAfW6UnUztpUmIB5CUz93XZM vje3bRXZr7b8UlrNDrQ6FfF846sY/YF/e0QUM1FrLdupofMu81DpOz/PV3Z/JSF9YfoM em0hF8Qyryxu3Kk6/Y29Ubw9tnUWad2VdJGDDG0I8KgOcXHC4ISlgou00oQUCKRgITBd j0gw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C+/sOXwV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id e44-v6si894529qvd.129.2018.05.08.08.26.38 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 May 2018 08:26:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=C+/sOXwV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:51871 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4Vh-0007YN-RD for patch@linaro.org; Tue, 08 May 2018 11:26:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fG4KM-0006hY-U9 for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fG4KK-0008Fs-9T for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:54 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:35145) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fG4KK-0008Ex-4m for qemu-devel@nongnu.org; Tue, 08 May 2018 11:14:52 -0400 Received: by mail-pl0-x241.google.com with SMTP id i5-v6so2416543plt.2 for ; Tue, 08 May 2018 08:14:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=C+/sOXwV2h4jn9oE5bnTe/cCvgX58TgMsBIEL9aKnhhG6Lc0QjddF83W/oxnsnLvap SkKtaINBwAA3akK5I35xYoWfqq7+UFZ0TSkcCRdx+gH5OlDj4LEHRicQUlaOBiqbEO2L gZAlPS/JAW5pg8Fr0JZRPY9VRzr0icu/gkdOo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8rcPASnE+C7rW9/bI3AEK2ZVz+3GRCpBYozOZLaQ8f8=; b=Ud6HruYv7Tx+q30xEb/Pzs8EiuYklV3pf3bEWteeMBjl84PsLe4V/EeRpyKYqKAGJr L6UTvSLeRgbyyr0fvX8MQ82tyoWKAVfzIatrffN5GCGZ7YteRFJ1bgPmdymjudsssQif NTYqTEVe2IS2N9KPc2hEtjd0Y9UCFSegnbATl8cIk2nRFx97u6kj2AWMnD2cOEgxavMA tjnFMu5Hv3XAdHLtsnSd48rR8V7cRV65AgSa7N3giTH+Q2iTSKUT7TmZ7qTtUCVnItF0 AgN1GAsuwRhxAG4Tt7ThLagbnKYL9KIurKopP5Nc99UvXU5hWIidEqQdBdi6kBOq574S yqnA== X-Gm-Message-State: ALQs6tAfyhotg5PRxnvHy1yS+RtsWcQYC6ktBtyjoPMj5whSWqor5eMv DwGhkTu31KXcxxtS+P4fkpjKxjiFe0s= X-Received: by 2002:a17:902:b485:: with SMTP id y5-v6mr10138235plr.381.1525792490916; Tue, 08 May 2018 08:14:50 -0700 (PDT) Received: from cloudburst.twiddle.net (97-113-2-170.tukw.qwest.net. [97.113.2.170]) by smtp.gmail.com with ESMTPSA id n10sm55598896pfj.68.2018.05.08.08.14.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 May 2018 08:14:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Tue, 8 May 2018 08:14:35 -0700 Message-Id: <20180508151437.4232-9-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508151437.4232-1-richard.henderson@linaro.org> References: <20180508151437.4232-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v3 08/10] target/arm: Fill in disas_ldst_atomic 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@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" This implements all of the v8.1-Atomics instructions except for compare-and-swap, which is decoded elsewhere. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- 2.17.0 diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 6acad791e6..c13858a690 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -84,6 +84,7 @@ typedef void NeonGenOneOpFn(TCGv_i64, TCGv_i64); typedef void CryptoTwoOpFn(TCGv_ptr, TCGv_ptr); typedef void CryptoThreeOpIntFn(TCGv_ptr, TCGv_ptr, TCGv_i32); typedef void CryptoThreeOpFn(TCGv_ptr, TCGv_ptr, TCGv_ptr); +typedef void AtomicThreeOpFn(TCGv_i64, TCGv_i64, TCGv_i64, TCGArg, TCGMemOp); /* Note that the gvec expanders operate on offsets + sizes. */ typedef void GVecGen2Fn(unsigned, uint32_t, uint32_t, uint32_t, uint32_t); @@ -2772,6 +2773,8 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, int rn = extract32(insn, 5, 5); int o3_opc = extract32(insn, 12, 4); int feature = ARM_FEATURE_V8_ATOMICS; + TCGv_i64 tcg_rn, tcg_rs; + AtomicThreeOpFn *fn; if (is_vector) { unallocated_encoding(s); @@ -2779,14 +2782,32 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, } switch (o3_opc) { case 000: /* LDADD */ + fn = tcg_gen_atomic_fetch_add_i64; + break; case 001: /* LDCLR */ + fn = tcg_gen_atomic_fetch_and_i64; + break; case 002: /* LDEOR */ + fn = tcg_gen_atomic_fetch_xor_i64; + break; case 003: /* LDSET */ + fn = tcg_gen_atomic_fetch_or_i64; + break; case 004: /* LDSMAX */ + fn = tcg_gen_atomic_fetch_smax_i64; + break; case 005: /* LDSMIN */ + fn = tcg_gen_atomic_fetch_smin_i64; + break; case 006: /* LDUMAX */ + fn = tcg_gen_atomic_fetch_umax_i64; + break; case 007: /* LDUMIN */ + fn = tcg_gen_atomic_fetch_umin_i64; + break; case 010: /* SWP */ + fn = tcg_gen_atomic_xchg_i64; + break; default: unallocated_encoding(s); return; @@ -2796,8 +2817,21 @@ static void disas_ldst_atomic(DisasContext *s, uint32_t insn, return; } - (void)rs; - (void)rn; + if (rn == 31) { + gen_check_sp_alignment(s); + } + tcg_rn = cpu_reg_sp(s, rn); + tcg_rs = read_cpu_reg(s, rs, true); + + if (o3_opc == 1) { /* LDCLR */ + tcg_gen_not_i64(tcg_rs, tcg_rs); + } + + /* The tcg atomic primitives are all full barriers. Therefore we + * can ignore the Acquire and Release bits of this instruction. + */ + fn(cpu_reg(s, rt), tcg_rn, tcg_rs, get_mem_index(s), + s->be_data | size | MO_ALIGN); } /* Load/store register (all forms) */