From patchwork Wed Jul 31 20:38:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 170250 Delivered-To: patch@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4475074ile; Wed, 31 Jul 2019 13:44:17 -0700 (PDT) X-Google-Smtp-Source: APXvYqx60VuSZzq6lsFzVInJ5YOdzWCa9VoGBdmxbupFPq2hxWnZCO+YNdL6al4iLqvxDwXTEXHW X-Received: by 2002:a67:fb8d:: with SMTP id n13mr77759412vsr.46.1564605857254; Wed, 31 Jul 2019 13:44:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564605857; cv=none; d=google.com; s=arc-20160816; b=JFTkFlWRaDHRxgCr+WeA5auayJXqIRlgiT+S5uhm22lLQ63e81d3u4wWNawgI6LOZV IFQzffdThzK0rGKLsVTd7PYkNd9Jb2BDe9SLvsqqxjMcC7fxhYp+pUFGnNUbj+GYI4zS yuLKFA4mFtC+zJdC/9t4MsqP5ZqB3RkeDL0DKq/XujE+3OLsW4jykM6kJWk06sNFNPDT o9qVf9MJV9VDS5GPX1fNj9/cuWOWWOqFi03zEAaa91d+0CRyu5Zw1crPpKp1g64WNG/Y uwbDpDTk+urEVY7IdsN51ddqDd7/Q/6hoZ2zQWtPHYjf3pighseTyWb6sknmJlB5A2KW d5BA== 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; bh=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=uJorzubrPw189HiPlSdCAVofUqmFVql7l21mZkol4z/WkSNwaOwdZ3DUNMUBiwHr/X Ewa5oS2jQINln7p21e6e/iVR7nWueQxXkdZ5NbW2rt5w/i4gn0Z8Eq5V0AWEUZ/O3RWH 7nxGoEDjZPxcm99k4YVsm9myJ2APZg+S7TxMk0qMMu9dmx3JOP40/lW3FXfTbbu7sX1X hnCpy0MTTL69uB6q1rLOHNT3b0eiM0/3RJeZUxeOfuRHRCwvn8dqKFUju+cAsA7OWUJW YAZ8gHY/Ll1kPAd8pAy1gIrZ6OTcAYqf9ofKmGmzZWgd/D6i1SsyeOqsA0j5ZaaXQyKd Lv0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Kdwl74B6; 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 e3si16862586vsj.343.2019.07.31.13.44.17 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 31 Jul 2019 13:44:17 -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=Kdwl74B6; 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]:44322 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvSK-0007Ex-PP for patch@linaro.org; Wed, 31 Jul 2019 16:44:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32919) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hsvMz-0005Dl-3O for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hsvMx-0003dJ-QN for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:45 -0400 Received: from mail-pf1-x429.google.com ([2607:f8b0:4864:20::429]:34882) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hsvMx-0003cs-Ks for qemu-devel@nongnu.org; Wed, 31 Jul 2019 16:38:43 -0400 Received: by mail-pf1-x429.google.com with SMTP id u14so32533762pfn.2 for ; Wed, 31 Jul 2019 13:38:43 -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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=Kdwl74B6/jWmsEEKylVhNh+FnEqvpfAEzIn2lRU1DV+O/n0aqloQ5a9vX12Kj+4j+a AhFLTo/SkoMoEZu0dPjijScKjTXgFHIreIjwOGrdEpw/a8TLIsXUs8BT66ED9TnXbzYe VuK58p3XkTOTfylmbJXdoHnsQkMk0JfAw3i8+dCotxAOcyZ3+WxrhPH5Y08pZ1xUdH6d VcGvyaF2775EPpVE1zlsbEJjPZwCAOwagUCd9m9Q1DmZ+W7jA25BCPeyS9hzI+wDedeq IsqL8bubc932Lws41JBLO2MTvydw/Bz8l12PPTb7Hxfkw9MctKDI6qdeZ+ZTcRXvAoae clgg== 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=F8zJJPz0HoAAcPGItYsG98fn3EhRGHL9/KSAWCPhxyQ=; b=NtK6/tlsq29oH/i2+aAHn+UnnFoy0R890Fgju6eFfFVzJoX5aBQ89P7SNr+NtoCgSP I6tywbPPrMKVQlvA8+Rj10Nv3N2nLuJFduh7cn7rhk5ZHypTw2CZCk4xW0Ztska6cu5r bY4TBTrIWrmG65Y8f6wB0mc/yy3eY73W1lAVVLXHWUz01zQZciE+bKuiTrDC/d2B0xjH wkMp81EVmtY95WSFGaqLItKq0ZaAXHgTkjZP6CZNVuoI+B56Qn0sTL71H04wEIGNpI54 NKilLDRnlUzm3S0vLwmWrlR8g5aHjXfs3LYBOz5It6X777hCaEUIQevFkL4juKbkNQHh DHrg== X-Gm-Message-State: APjAAAVuDTWkcEAx8vqab69gXIKBoRPbpVL84rKPTw9XqCa+Iw63N3BN PLKA3+EIX3SeZfBO895NnwdkNwafA90= X-Received: by 2002:a63:7c0d:: with SMTP id x13mr75531824pgc.360.1564605522335; Wed, 31 Jul 2019 13:38:42 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id g4sm84054164pfo.93.2019.07.31.13.38.41 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 13:38:41 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 31 Jul 2019 13:38:03 -0700 Message-Id: <20190731203813.30765-23-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190731203813.30765-1-richard.henderson@linaro.org> References: <20190731203813.30765-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::429 Subject: [Qemu-devel] [PATCH v2 22/32] target/arm: Add regime_has_2_ranges 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, 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 | 22 +++++----------------- target/arm/translate-a64.c | 3 +-- 3 files changed, 22 insertions(+), 19 deletions(-) -- 2.17.1 diff --git a/target/arm/internals.h b/target/arm/internals.h index dd0bc4377f..1b64ceeda6 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -824,6 +824,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 9c2c81c434..5472424179 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -9006,15 +9006,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)) { @@ -9548,7 +9541,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; @@ -9558,7 +9550,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); @@ -9714,10 +9706,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 { @@ -11368,8 +11357,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); int tbii, tbid; - /* 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 dbe2189e51..06ff3a7f2e 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 {