From patchwork Fri Apr 27 00:26:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 134542 Delivered-To: patch@linaro.org Received: by 10.46.151.6 with SMTP id r6csp92850lji; Thu, 26 Apr 2018 17:34:25 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqowWpVrvXzHnO23H6k2XvOXPsBvsMGREJaUcg4oYVcL/Fs1nHQn8DrDG+9pCKm9Vawofjp X-Received: by 2002:a0c:c242:: with SMTP id w2-v6mr180282qvh.91.1524789265466; Thu, 26 Apr 2018 17:34:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524789265; cv=none; d=google.com; s=arc-20160816; b=eViCrmBAAWPcVDLIEd1W+NyMfBK4SD6U8GjQUxaI7c2ZJfJmDd00XT15l6iD4/df+R TZebXwCK+Sc6Tar2rnNxzpylgVsqJiz08/13yBxMKSoU5sCrC6xA3SJN6j7L5wVAMwzk W649fnmBMSdDJmot+OH/2oz+5vcsoymLz4G1K+85sOMXHMgJxcw/IHB7VYWNJyqfCmz9 YA/Wddc0bjLSA8uuitdGyYzXgDxVnskBN0TP7M23ZHYE+Z4Z9G/fpT8yfE8K4Plo0PLL O1RLSqrkTRggNtSWg5TubbYcnWIufCg3Hr7rBbes4uCmaqE3IlZ0n+HCN9PnsGsaTsQ1 HQFQ== 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=PEHUreWTV/acmi7x+XdpvFcJ/L5D2uAinn5jMrYd4EU=; b=Dm+CQZk6/yWilCbYoWqTkAF0tGCSnKFBukmTsBqoGm/N8LCR+l+j+K1f+Q5ApGoBCM hhV/tyO+xpVotzYkYibrbcalF8QYhTh4DnFUp3/rZt4k5ew4A0/ISGi4Mg+SEm0hT8U1 4rlOhAz9zpVA0SfMCIRbQUrrZBfkeP4pD3LN5b31QSm/G/RgspH/+vHSTJs+updDbdGz tw3lz2lrEJfA/CqpPwcAt0Gh2tLQmvkrkXPDZ75Zz9kzMCDYJPn7tvH7eWR8/ZtzMHp3 m5nhaJ1yT8TqB8hkk1ig5KffTmuUGrxNqCcqPq6fHgd64cGm66R6VJ2/SOIUN8cgfwPV D3nQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=FLNN+sJd; 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 w21-v6si96788qtg.389.2018.04.26.17.34.25 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 26 Apr 2018 17:34:25 -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=FLNN+sJd; 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]:45141 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBrLE-0007n0-Qq for patch@linaro.org; Thu, 26 Apr 2018 20:34:24 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51786) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fBrEJ-0002A9-9P for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fBrEI-0004by-7j for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:15 -0400 Received: from mail-pg0-x244.google.com ([2607:f8b0:400e:c05::244]:39973) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fBrEI-0004b1-2q for qemu-devel@nongnu.org; Thu, 26 Apr 2018 20:27:14 -0400 Received: by mail-pg0-x244.google.com with SMTP id l2-v6so146604pgc.7 for ; Thu, 26 Apr 2018 17:27:14 -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=PEHUreWTV/acmi7x+XdpvFcJ/L5D2uAinn5jMrYd4EU=; b=FLNN+sJdxxxdiPxv4H2aykvYSnSE7lg3m1ZrqWCuaCpW3lLc/haGpA701JMWTiJ3Q2 DzfXRHFPxkIJZLoxZwyRAGmkOJWC2PV7ob0rK8jL0YqGCq/a9rZzpuaUJ2/ISTNSxlez RFdKjCW9LwzXJwoO3VtIvWk3ZGfhkKH+BUnMQ= 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=PEHUreWTV/acmi7x+XdpvFcJ/L5D2uAinn5jMrYd4EU=; b=dupbacrsf+h29vwZFekI62gvkHeKa3NsAlPlpfo/l+bBRegTHvf+Eog8p/IvT9SfRx WPa5dLns7lWoqa5cg/+2CPDp7fdlie089/nhcI26kpP49n4ykKDc4F8a1YCUAIAp/1tL 8K1ns5R7LJkqKM9HKUaIEIubyV1XcP0YvYXLgOy2WR2Zjf2bTjO0AOd3O6Z8v/8I+VnQ JT0W7jQR1WeH6oOrKLWSr1zbTDcE01I6ELwwO7uClk83z6fb88oOu48zqYB82dsPtU61 M8YrRTe3t9QMjEzHahrbARESmJFf3AS5oCSh6rUl0RpPZG/Xt0bcF/YLLV5ljZH+bDjz 4XIg== X-Gm-Message-State: ALQs6tA9qDI85LA0mViOhemWbWKpHG6GClJnZirzWN9Gi+2/9spc2QdZ SkAC37KmbMtZrkKl9mBCHAhitg2Zu3Q= X-Received: by 2002:a65:4648:: with SMTP id k8-v6mr169735pgr.47.1524788832880; Thu, 26 Apr 2018 17:27:12 -0700 (PDT) Received: from cloudburst.twiddle.net.com ([2605:e000:112b:41da:c94c:5ee7:de92:7d78]) by smtp.gmail.com with ESMTPSA id g76sm86338pfj.102.2018.04.26.17.27.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Apr 2018 17:27:11 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 26 Apr 2018 14:26:49 -1000 Message-Id: <20180427002651.28356-8-richard.henderson@linaro.org> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180427002651.28356-1-richard.henderson@linaro.org> References: <20180427002651.28356-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 7/9] 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: 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. Signed-off-by: Richard Henderson --- target/arm/translate-a64.c | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) -- 2.14.3 Reviewed-by: Peter Maydell diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 0706c8c394..6ed7627d79 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, false); + + 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) */