From patchwork Fri May 4 22:45:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 135034 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp596323lji; Fri, 4 May 2018 15:46:52 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqXxbnU++5wjq+im/NHCpdb9d6vIIzUSkJ+TMk2Q4AUiwYkgrs3W8GxduuzBkBxViBKrKHB X-Received: by 10.233.225.13 with SMTP id g13mr23763171qkm.113.1525474012175; Fri, 04 May 2018 15:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525474012; cv=none; d=google.com; s=arc-20160816; b=ayE3t37nUrtad1ahM8KRQxX8JJwsU2wtBYcCsQqHtcF5gRf1fcz0MFYhiBTQC8YF0T 1+qiiR6kKm3h9dhXx/kKue4ocZs9WNGeozIC8I5GfRLpvnOHI4qXKFXtAhbw8qhZzd3O W1XJC4fUu84wFlnoHc+6CtwCbOVo0RnY3HsevRD+hGrlPvUujFLcmYcdIl5ihxSS0g8U IejOCWDZkYgpgDEd/Y17rAoCTLVwZIjARzFI3PxkvmeUg6vYqODcdwXW9C/fRnIP5eE0 n8mvuDuuWFM08421wUboHFSGFF/TIIBAViOA6frNPvpe5DVpqTbV7LN9mY69NyOs3zoj Uz8Q== 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=6z9+zx40B+ooj2v+9U4VTuPYHaQ+bbZH6j/23MH2A4g=; b=AFTtGzAD6S8vVGb/4anu6ysVcjyAv3KAmblbwuJGOxWrguOSxIdAQEi6KS87A1WH31 SJpQdL/2lGxhL8ae02uRtezKSUFg+nzIxelqxKyX5arSkxZxHQsPuefimF0ukAg3x4AE 0pq5oeODx0QbPy/NhyqxISlAd9FM3gzLl6HFivPJU6w1WWYYonTVAiStEY6bGLMZUiU8 miQX01BV+5SFVo5d8IvR+jX2oLigGfutCC0gei44X+G6ByefLL/Xfo367mZgt+YeXONU rLkhFgseE6rx52CQGcmJx4mAp9MIPMFK0KejcNF+NzL19GLcNpDxiSVJonh3qhHUVsl3 qlbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=TBeoQ2L4; 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 j12-v6si16140140qtf.334.2018.05.04.15.46.51 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 04 May 2018 15:46:52 -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=TBeoQ2L4; 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]:36722 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEjTX-0006IV-O3 for patch@linaro.org; Fri, 04 May 2018 18:46:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43133) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fEjSD-0005ev-Nb for qemu-devel@nongnu.org; Fri, 04 May 2018 18:45:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fEjS9-0006uU-WC for qemu-devel@nongnu.org; Fri, 04 May 2018 18:45:29 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:38195) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fEjS9-0006tW-Qg for qemu-devel@nongnu.org; Fri, 04 May 2018 18:45:25 -0400 Received: by mail-pg0-x244.google.com with SMTP id n9-v6so16359797pgq.5 for ; Fri, 04 May 2018 15:45:25 -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=6z9+zx40B+ooj2v+9U4VTuPYHaQ+bbZH6j/23MH2A4g=; b=TBeoQ2L4XDJCBIjV8awyWhQ0H26NvpydYjoa7bnhZ9vz2WCHXI6izGmbot6Zf2WumA MkvGNRmHWtrojPIL2yeyng4xSV3r1IrINk+f+Uk9qbnKBSdnyETsfxozLOvaobGgKHBI iUCccMrjaWhKWxBGuBw5vUg7WZWUm7E0InfTY= 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=6z9+zx40B+ooj2v+9U4VTuPYHaQ+bbZH6j/23MH2A4g=; b=KPAOIsTjnNPjcTTne3z3RfDWmUUObpnwI0QSetoXEIhuYc7um3I+sMwCG+zgmpfcDO M/kTdUVC8KgX/JMxtGCxagXjz0eQ1ONIVI6UW2RedYMIpNTIRhRVE7U3gzCK0Hc7aEev aXO1LhAVJXtVunMB2AkgPbD49/ElPfcBKMAGy9Tj5YuZK/sVckpEEePsLzOAUTvWL9YI 9+ID1FuCxTgbI7gJXhh+cIoGz8H7mnL7YI3CBXTZZGsQBQYelXv5nWNmRydrbkJyLUhv +aU9UaWYjNEZ00nTqu00sSBycpt+FcmJ+yGqWsyVVOvuseEWHN37fGzd/+VG0Xcio+bX Kodw== X-Gm-Message-State: ALQs6tB0ivPSrnN8DqMo5zTtygG8yNz0dQt5whxFB/74nRADvUF35Vsw ML9HM/14dbXfANZ8J2KBorXL96A93wQ= X-Received: by 2002:a63:7543:: with SMTP id f3-v6mr19976773pgn.256.1525473923939; Fri, 04 May 2018 15:45:23 -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 b5sm33604244pfc.16.2018.05.04.15.45.22 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 04 May 2018 15:45:22 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 4 May 2018 15:45:21 -0700 Message-Id: <20180504224521.7801-1-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180504183021.19318-1-richard.henderson@linaro.org> References: <20180504183021.19318-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:c05::244 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, qemu-arm@nongnu.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 --- v3: Do not zero-extend X[s] via the third parameter to read_cpu_reg. --- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- 2.14.3 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) */