From patchwork Tue Dec 3 02:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 180681 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp950328ile; Mon, 2 Dec 2019 18:49:52 -0800 (PST) X-Google-Smtp-Source: APXvYqzezDobcrPjtlA1X82JhfYaj2XRfY8VyQScX/oqf+5AGSC2lSpqf9HX1wvK05hlAfbOav40 X-Received: by 2002:a05:620a:95a:: with SMTP id w26mr2880212qkw.501.1575341392705; Mon, 02 Dec 2019 18:49:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575341392; cv=none; d=google.com; s=arc-20160816; b=bQPZNgIYXx6tMKvj3t7kfgEa6ggXmkru/9FkNT8kwu7ov/AoCxW7nYLNfgFaICPtcM +iIOTqC7k9f7zPFfYiI99NGW/HBDRKxLXyQ4Jtv3fRJNvn5XhBHgseC/DlmyZ3ZK+nuH tJ0ADQ9IDyKg5/a87m2Kf6RGJkh0pOydak3dqAHOhiT2beRRgvq+UKhCfMGUu76qEWF6 EtE0CPr6C8+/nZoW5GlGBlxKcyC+yG1uy+G9kyn0XZaJKkYYCKQ1illTVDbvecgAMIKl EiAul/na+FRMyx7LQ0ddA0MAIFgn3C1y019YBjl8Vwh5c/dKkQDyUmgLFMGxe+Z/OpOF 7iBA== 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=Xos4Pslsfo4lMRc6yGUlLi8dcXsFQtvPjw86xkjAaB4=; b=tpKOcaH8ELd9VAW6scTDhprBv3Enx7pr3rxBrR3mZ0kQpbYDBkuNczjMUpueqryZR3 FQ7UJeurgCi22C/9Mj3D7jPD3ipBQkHWCamHoETw34+xb+/nswNXvKJPPR35vGUaY4wQ zLAVjhKy3DQ2HrAIeG0tPQ1BOET8mWvjLSAclN8YYPFwLF59U5VDrShKOyU5ho+FGvwx MVXEQx+U8fPyYptw8mQHHeF3goGnyUZkE4myYW6wN+G7XOkPUea8TD6dTQVLaXrsOEjk krr7FZIih7lrZD1PVhXWALX1Id242kXY5u7S5gMiipyaL4BGGfwzPKTJ3owzmrXdRqn1 QPgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b="Q4MyJw/M"; 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 u7si1135797qtu.61.2019.12.02.18.49.52 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 02 Dec 2019 18:49:52 -0800 (PST) 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="Q4MyJw/M"; 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]:47462 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibyG7-0001Na-Qc for patch@linaro.org; Mon, 02 Dec 2019 21:49:51 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60898) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ibxxF-0003Kc-OL for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ibxxA-0008Qf-S0 for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:19 -0500 Received: from mail-pg1-x534.google.com ([2607:f8b0:4864:20::534]:38114) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ibxxA-0008H4-Hm for qemu-devel@nongnu.org; Mon, 02 Dec 2019 21:30:16 -0500 Received: by mail-pg1-x534.google.com with SMTP id t3so873505pgl.5 for ; Mon, 02 Dec 2019 18:30:05 -0800 (PST) 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=Xos4Pslsfo4lMRc6yGUlLi8dcXsFQtvPjw86xkjAaB4=; b=Q4MyJw/MPPJJLnumBttiKd6PWw2/qCyRSnsED03QpmI3408zBN8QUDgCCBEMnT63RF 6LvGpvw96bFsVuVQubRf7yPryZZj7ZgJRgTsGNuJRca6EdZr/aI5cMg3S6DE0y20avs+ Pyi8q//BDqYpsdZC89wliKYuN+9fWwn1iSPbFEpKwZOVsDG30KFKtKtg3MTfyORK2q1N gfVPqdYGopMTzm1kFydqesuXBAEtymkeGMjnx1+cafAYPiEoVwAFm9udh2k34/K5NNOP v2DwUpGt6e/Lu43l3HSYBYQUdYXuO7WWT6IVjblsmOLWkSvqrc5UzSGyveU32PkeS4th /DFA== 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=Xos4Pslsfo4lMRc6yGUlLi8dcXsFQtvPjw86xkjAaB4=; b=NMyUwmW0vfDpo8RTgfCm/oB6YD8DtH5SqWtzEB8DELMbeqqfKAOrO+kK+6OwcwWnsf yBhY8rWpNxbMULpFa6aWPqSSxnScdum5ECNSTmoh27ihEZc/ltSwIvixZRcAB6QUsj0y RmXo1VZqWApR8oBeA+/cmKA/uBk79c66NTXK0LqUzLvw5jf7k9aIYMgs6ehzNIwI7XvR vX3vdOBOi/pem3DNHYt8sT2w/kD/hTkJpGNSHed/DK//ks2EhDD+mU70w2b1uHr+xfte iFuh6t9XlreOiX5iS4JVGqYgPk1uvy+1JvjTqss9RTfflCF3k4VrWrrAgL0iNutMP/z0 iVmg== X-Gm-Message-State: APjAAAVWtDqwa6vU0TW0r9muo55udmG0U4255NiSUnp717FucgAqXDNQ GN6XWTuzT/ghmdBCfCeq6OMXoHYthAg= X-Received: by 2002:a65:590f:: with SMTP id f15mr2729309pgu.381.1575340204022; Mon, 02 Dec 2019 18:30:04 -0800 (PST) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id q22sm873695pfg.170.2019.12.02.18.30.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Dec 2019 18:30:03 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v4 19/40] target/arm: Add regime_has_2_ranges Date: Mon, 2 Dec 2019 18:29:16 -0800 Message-Id: <20191203022937.1474-20-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191203022937.1474-1-richard.henderson@linaro.org> References: <20191203022937.1474-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::534 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, alex.bennee@linaro.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Richard Henderson --- target/arm/internals.h | 16 ++++++++++++++++ target/arm/helper.c | 23 ++++++----------------- target/arm/translate-a64.c | 3 +-- 3 files changed, 23 insertions(+), 19 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/internals.h b/target/arm/internals.h index d73615064c..1ca9a7cc78 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -837,6 +837,22 @@ 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_Stage1_E0: + case ARMMMUIdx_Stage1_E1: + case ARMMMUIdx_EL10_0: + case ARMMMUIdx_EL10_1: + case ARMMMUIdx_EL20_0: + case ARMMMUIdx_EL20_2: + 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 f86285ffbe..27adf24fa6 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8885,15 +8885,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)) { @@ -9427,7 +9420,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, using16k, using64k; int select, tsz; @@ -9437,7 +9429,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); @@ -9593,10 +9585,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 { @@ -11306,8 +11295,8 @@ static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - if (regime_el(env, stage1) < 2) { + /* Get control bits for tagged addresses. */ + 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 885c99f0c9..d0b65c49e2 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 {