From patchwork Fri Oct 11 13:47:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 175949 Delivered-To: patch@linaro.org Received: by 2002:ac9:3c86:0:0:0:0:0 with SMTP id w6csp958477ocf; Fri, 11 Oct 2019 06:49:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqzKS0cxXmkDOxTeGImaZ8CEFxUtR/P6/dAPHVmKqNxxdgOagzFRinFGN7o2NOezKT6TZ4ao X-Received: by 2002:a37:ab1a:: with SMTP id u26mr15923237qke.401.1570801783104; Fri, 11 Oct 2019 06:49:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570801783; cv=none; d=google.com; s=arc-20160816; b=v2NWrjRJhtPnmBPZePOY83LamkU01IX+V6kltDrZHejsijIdlJkK3CqUqhTH8aq5Co s+gYivwI4aSi/O8Z3YPadJSPZK0BDyTtwKGpQ/LIcU35zosjec2qpo2NgUQLIjG1P0pd /yq4ivjKKEpzpLQ+NqRygk5emSNQqHexZspnLTPBejP7fQLKGi8t7rMIZvORy9NQIPcQ 2T5PoiezBWuYfUsu0fM0Z/K3Uj2Qev8ZSk8DI3E+aWt/qursKUGVjs0HUWJ9QDG3yQtk tEWdPw9+kYu9GQPxqYMI+YdlQMuSD9C9SZDlcl36mhdaEeODykZNrLwwebg0+AKRbDMs rG9A== 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:references:in-reply-to :message-id:date:subject:to:from:dkim-signature; bh=kRVYi/cd4sJBmkOfsvOkC48A2821IfvOweyDTIJZmas=; b=ObwIQrkPqzAnvrTNPihiB5sSzVCOdpnNqTUmXZKx2j1/OHxCv/wLuJIuji50h01QKp Aq2v8UdUe2/Jps1P0y6bt+jsZQdb36zLiuGOvUfQ/7vqoOBMT88JYLloLtlF7l14vwWl olBWrqm/4HdeNcpTu6yPLp9DLNvLOrdvRu3BcDIsaWn7ugl0fb5s9EdeWikUamVuZWbS L4h4izfLVSC5g9temnGZEvBtveINdMxIaddFqzsUwrpb94KIKbhNVipBfxjDj3+8Eqvp 4ayoNMhFeP9qOE24RidSW7LGeYyFoQYrvteo9kJV+ksi5tysVr6ceF/6AvgJAsuQuXxU mINQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Yu/oJVtW"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id c195si8841226qkg.354.2019.10.11.06.49.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Oct 2019 06:49:43 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Yu/oJVtW"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:50274 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIvIc-0003PG-B2 for patch@linaro.org; Fri, 11 Oct 2019 09:49:42 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:38590) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIvHZ-0003KI-AU for qemu-devel@nongnu.org; Fri, 11 Oct 2019 09:48:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIvHY-00036v-4R for qemu-devel@nongnu.org; Fri, 11 Oct 2019 09:48:37 -0400 Received: from mail-yw1-xc41.google.com ([2607:f8b0:4864:20::c41]:44044) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iIvHY-00036l-1A for qemu-devel@nongnu.org; Fri, 11 Oct 2019 09:48:36 -0400 Received: by mail-yw1-xc41.google.com with SMTP id m13so3479895ywa.11 for ; Fri, 11 Oct 2019 06:48:35 -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=kRVYi/cd4sJBmkOfsvOkC48A2821IfvOweyDTIJZmas=; b=Yu/oJVtWKrqV6rqzPN9bt3luBufZ2oDC3OERGl0GNEiR0Ec/IrLQ/RY8dEN4N7Txsr JN7wwXOKpZucUAlDQxFNxdTevpFefm/oE3lkc2HLb/8rQkgrIbgBVaEKfbiF1Ma28UoU 9/aqem6igw2tSOnup1QKzToC/hxXzIXNIXXyG0jFh0d1sTKNkziMRqokOFmkEYRw7rkk ySgqA4aCmp1UYa3iC2a9j499kcfAU20V/8uLhAfp2NHkanHPZuXI1V74hVT7T9be5sc/ nHZuxco4xVpsrXtL1UQV6gEP5snEQMcngc/mSbi3gxklON07IBhzkRFAZrXV9iE7iC05 sJTA== 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=kRVYi/cd4sJBmkOfsvOkC48A2821IfvOweyDTIJZmas=; b=KJyKcOHp/+S4BWyQt5KTj6n46GXBennljJIDPJhdqvVeMMEAF3LnaE2Ro654Zo8UoY 50zfl4wkyhP0JtlWVP/fTWIhNQfZ3mu4AfsEI5F81uCWxxu8oB+U6TUOrvcnqp4PZEwS ERBPxn4ySIoZOMLyIPjD1bb5WyETvUitb8DBl9RSnVNgfDfQFzdOWet1YBBGUJqiS3lz B2pXdP0ouiuEnTDygB8G/Od4FEI+kLBvC795SNM6Kjdq3zXLDNS3iv0tXgy9TJQSJ4vL anexdT3V8YSvxL3vFJa50wluRMG1ugmU9WzHa4NA4Icf/wP12OBtDID71GLSnqccLTZp 5mrA== X-Gm-Message-State: APjAAAW+O+33+NYVvpT/iVDOTKM3aD6WWVl1d8Zs2Tc3RSVg8HhWH1My 8G3c66AT/Gr32fOr0AxYBYG/ugpvi10= X-Received: by 2002:a81:2b09:: with SMTP id r9mr2411212ywr.346.1570801715120; Fri, 11 Oct 2019 06:48:35 -0700 (PDT) Received: from cloudburst.gateway.pace.com (67.216.151.25.pool.hargray.net. [67.216.151.25]) by smtp.gmail.com with ESMTPSA id f68sm2534000ywb.96.2019.10.11.06.48.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2019 06:48:34 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v5 02/22] target/arm: Add regime_has_2_ranges Date: Fri, 11 Oct 2019 09:47:24 -0400 Message-Id: <20191011134744.2477-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011134744.2477-1-richard.henderson@linaro.org> References: <20191011134744.2477-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::c41 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 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" A translation with 2 ranges has both positive and negative addresses. This is true for the EL1&0 and the as-yet unimplemented EL2&0 regimes. Signed-off-by: Richard Henderson --- target/arm/internals.h | 14 ++++++++++++++ target/arm/helper.c | 22 +++++----------------- target/arm/translate-a64.c | 3 +-- 3 files changed, 20 insertions(+), 19 deletions(-) -- 2.17.1 Reviewed-by: Peter Maydell diff --git a/target/arm/internals.h b/target/arm/internals.h index dcc5d6cca3..9486680b87 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -804,6 +804,20 @@ static inline void arm_call_el_change_hook(ARMCPU *cpu) } } +/* Return true if this address translation regime has two ranges. */ +static inline bool regime_has_2_ranges(ARMMMUIdx mmu_idx) +{ + switch (mmu_idx) { + case ARMMMUIdx_S12NSE0: + case ARMMMUIdx_S12NSE1: + case ARMMMUIdx_S1NSE0: + case ARMMMUIdx_S1NSE1: + return true; + default: + return false; + } +} + /* Return true if this address translation regime is secure */ static inline bool regime_is_secure(CPUARMState *env, ARMMMUIdx mmu_idx) { diff --git a/target/arm/helper.c b/target/arm/helper.c index b690eda136..f9dee51ede 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8774,15 +8774,8 @@ static int get_S1prot(CPUARMState *env, ARMMMUIdx mmu_idx, bool is_aa64, } if (is_aa64) { - switch (regime_el(env, mmu_idx)) { - case 1: - if (!is_user) { - xn = pxn || (user_rw & PAGE_WRITE); - } - break; - case 2: - case 3: - break; + if (regime_has_2_ranges(mmu_idx) && !is_user) { + xn = pxn || (user_rw & PAGE_WRITE); } } else if (arm_feature(env, ARM_FEATURE_V7)) { switch (regime_el(env, mmu_idx)) { @@ -9316,7 +9309,6 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, ARMMMUIdx mmu_idx) { uint64_t tcr = regime_tcr(env, mmu_idx)->raw_tcr; - uint32_t el = regime_el(env, mmu_idx); bool tbi, tbid, epd, hpd, tcma, using16k, using64k; int select, tsz; @@ -9326,7 +9318,7 @@ ARMVAParameters aa64_va_parameters_both(CPUARMState *env, uint64_t va, */ select = extract64(va, 55, 1); - if (el > 1) { + if (!regime_has_2_ranges(mmu_idx)) { tsz = extract32(tcr, 0, 6); using64k = extract32(tcr, 14, 1); using16k = extract32(tcr, 15, 1); @@ -9486,10 +9478,7 @@ static bool get_phys_addr_lpae(CPUARMState *env, target_ulong address, param = aa64_va_parameters(env, address, mmu_idx, access_type != MMU_INST_FETCH); level = 0; - /* If we are in 64-bit EL2 or EL3 then there is no TTBR1, so mark it - * invalid. - */ - ttbr1_valid = (el < 2); + ttbr1_valid = regime_has_2_ranges(mmu_idx); addrsize = 64 - 8 * param.tbi; inputsize = 64 - param.tsz; } else { @@ -11095,8 +11084,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); int tbii; - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { + if (regime_has_2_ranges(mmu_idx)) { ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); tbid = (p1.tbi << 1) | p0.tbi; tbii = tbid & ~((p1.tbid << 1) | p0.tbid); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 51f3af9cd9..c85db69db4 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -175,8 +175,7 @@ static void gen_top_byte_ignore(DisasContext *s, TCGv_i64 dst, if (tbi == 0) { /* Load unmodified address */ tcg_gen_mov_i64(dst, src); - } else if (s->current_el >= 2) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ + } else if (!regime_has_2_ranges(s->mmu_idx)) { /* Force tag byte to all zero */ tcg_gen_extract_i64(dst, src, 0, 56); } else {