From patchwork Tue Jan 8 22:31:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155019 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp38345jaa; Tue, 8 Jan 2019 14:42:06 -0800 (PST) X-Google-Smtp-Source: ALg8bN67OvkVld0d/Peg3fLoF/qkReO5wTkIA86usgXiE7b2wxYXJfS6oeUc8dZWeI/gQl7yzcnl X-Received: by 2002:adf:aa9c:: with SMTP id h28mr2810827wrc.216.1546987326758; Tue, 08 Jan 2019 14:42:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546987326; cv=none; d=google.com; s=arc-20160816; b=VscQW2V/Yr9bLciKAaiCHFd6IzgWWr3vnaKoSfyXxp8Cb3Itr5vXW/2pTkd/HFymit ArYSb+d/mMGtU0kUcLotxYr2m6rKLv9nkOsi4sfkmCRLhHaS1c1ASeNbdXueFuxYMK1n H0Lg/Pk9bumvAPj7pBw0mJeugBEGNdDXwlJXUEOaXdLO6RqOaOxEzc8c68s1RTl5fIxM 8Bj4Wi8GIJXOw/maNPBveFC8LCnfZZfmTFepBfbYq0qdaaa//rLTL1dVYoba5+nF/59L Ogg9Q2SapUlv7XX57a1PQTs7u3d+VhJan3w/+1e2L7VDIJ4yOZwjk0WpBSeOJT9acIwQ xPaQ== 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=x4CNbPTPbLbD5OUpnvxNmBSc1i8+hDI/XOOOW1xKo9M=; b=kxoLgWq6liC2JrLdB+4rHJmyQJhET7tqXfC+CsOJmwFrQ2cQ0AAUqlCG2zPfxiBGmc L37VusLvlpFJe0qzoy16iLl+kwGDf7ZTH2UhExqiU10OKg3RCxJ+83DyBmqwAhcsUkEs BopJu4pWKqyDVyFe4WuKog/JrtlFyKHddHkj5sq89P0B2QBXVG6oEZZ1AonQTvjt4TU2 rGGl53cLoBA3Y8EhDrknqw89BijMN7I9wE85rFBR6O2XAEV7eoJoxnyQ8gaVQbvSS4Xt DNmnIdNY5ZESDjnU65XdQvK5WuAygzx7E+BUs9N+Zz+s5CjoFcIvRvYAjaOx0CJu7ujm apsA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=bh2NdUAu; 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 i7si37323578wrq.79.2019.01.08.14.42.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:42:06 -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=bh2NdUAu; 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 ([127.0.0.1]:41983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh04T-0008HV-Fb for patch@linaro.org; Tue, 08 Jan 2019 17:42:05 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52910) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzvK-0000UT-DE for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:39 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzvJ-00053Y-F8 for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:38 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:38112) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzvJ-00052m-8M for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:32:37 -0500 Received: by mail-pl1-x643.google.com with SMTP id e5so2564207plb.5 for ; Tue, 08 Jan 2019 14:32:37 -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=x4CNbPTPbLbD5OUpnvxNmBSc1i8+hDI/XOOOW1xKo9M=; b=bh2NdUAuWjlPasMBVlhc2XOTtxmAr91Vd6TxMNxGLB5e31n2gVatzFpxnanUd9TU3g JtvnQQrtUAaDo9AooSw9B/FUrHGCX0UgeycdLN0nuEGxu6g+8LK8QSDi5E5JanPaWJ43 XzPRuC/t3+2dz/psBojt9191xQvqSg2vvmvjM= 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=x4CNbPTPbLbD5OUpnvxNmBSc1i8+hDI/XOOOW1xKo9M=; b=dJ2eoXoN6CNgb9BqPcSNq0xOJDihgriQw7aCF1RpW8NT0es/5wpa67XOT3MgL8pOBn yP3ZnUsfvaX1KXuJkVUmcGFAz5AIJ0yp3YqBY52x1d1p6Y6x5ko7SYWvjdmn/c14/+Vv bZFve8ab0PKOjOU582jvC3IXDkj8PcKbHV+iOEv5aQcDnlNq20XBJVaHBWvd58g3DMyL htclL+Ula3E45GxJc6xROQq5EyeVwkrj9WhKv85uE1m5pHKWoU8TgCKn57yymloeECiv jVsrziqPlSgtoMTubBHr7HF28t2QM2nCMW51GfSuPNOZiAo3rUBhzj/pSuh3N2xS2aOf CG9Q== X-Gm-Message-State: AJcUukdDoo1JQmWrBp+1CFrG0+h7antoqgs0DRPG6tG6+IQPpCMnSP+Z 9sXneYnXa5FB3pCye65mYEuLhEoe0CY= X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr3618103plb.107.1546986755992; Tue, 08 Jan 2019 14:32:35 -0800 (PST) Received: from cloudburst.lan (2001-44b8-2176-c800-8cc6-2630-7d99-5ef1.static.ipv6.internode.on.net. [2001:44b8:2176:c800:8cc6:2630:7d99:5ef1]) by smtp.gmail.com with ESMTPSA id w128sm100686177pfw.79.2019.01.08.14.32.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:32:35 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:21 +1000 Message-Id: <20190108223129.5570-24-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190108223129.5570-1-richard.henderson@linaro.org> References: <20190108223129.5570-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::643 Subject: [Qemu-devel] [PATCH v3 23/31] target/arm: Reuse aa64_va_parameters for setting tbflags 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 Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" The arm_regime_tbi{0,1} functions are replacable with the new function by giving the lowest and highest address. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- v3: Use aa64_va_parameters_both and compute both tbii and tbid. Merged back from a later patch set. --- target/arm/cpu.h | 35 ----------------------- target/arm/helper.c | 70 ++++++++++++++++----------------------------- 2 files changed, 24 insertions(+), 81 deletions(-) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index ea9b8ec4a1..8512ca3552 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3015,41 +3015,6 @@ static inline bool arm_cpu_bswap_data(CPUARMState *env) } #endif -#ifndef CONFIG_USER_ONLY -/** - * arm_regime_tbi0: - * @env: CPUARMState - * @mmu_idx: MMU index indicating required translation regime - * - * Extracts the TBI0 value from the appropriate TCR for the current EL - * - * Returns: the TBI0 value. - */ -uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx); - -/** - * arm_regime_tbi1: - * @env: CPUARMState - * @mmu_idx: MMU index indicating required translation regime - * - * Extracts the TBI1 value from the appropriate TCR for the current EL - * - * Returns: the TBI1 value. - */ -uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx); -#else -/* We can't handle tagged addresses properly in user-only mode */ -static inline uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - return 0; -} - -static inline uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - return 0; -} -#endif - void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *flags); diff --git a/target/arm/helper.c b/target/arm/helper.c index cc3c0d47c8..e610155166 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8957,48 +8957,6 @@ static inline ARMMMUIdx stage_1_mmu_idx(ARMMMUIdx mmu_idx) return mmu_idx; } -/* Returns TBI0 value for current regime el */ -uint32_t arm_regime_tbi0(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - TCR *tcr; - uint32_t el; - - /* For EL0 and EL1, TBI is controlled by stage 1's TCR, so convert - * a stage 1+2 mmu index into the appropriate stage 1 mmu index. - */ - mmu_idx = stage_1_mmu_idx(mmu_idx); - - tcr = regime_tcr(env, mmu_idx); - el = regime_el(env, mmu_idx); - - if (el > 1) { - return extract64(tcr->raw_tcr, 20, 1); - } else { - return extract64(tcr->raw_tcr, 37, 1); - } -} - -/* Returns TBI1 value for current regime el */ -uint32_t arm_regime_tbi1(CPUARMState *env, ARMMMUIdx mmu_idx) -{ - TCR *tcr; - uint32_t el; - - /* For EL0 and EL1, TBI is controlled by stage 1's TCR, so convert - * a stage 1+2 mmu index into the appropriate stage 1 mmu index. - */ - mmu_idx = stage_1_mmu_idx(mmu_idx); - - tcr = regime_tcr(env, mmu_idx); - el = regime_el(env, mmu_idx); - - if (el > 1) { - return 0; - } else { - return extract64(tcr->raw_tcr, 38, 1); - } -} - /* Return the TTBR associated with this translation regime */ static inline uint64_t regime_ttbr(CPUARMState *env, ARMMMUIdx mmu_idx, int ttbrn) @@ -13051,10 +13009,30 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, *pc = env->pc; flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - /* Get control bits for tagged addresses */ - flags = FIELD_DP32(flags, TBFLAG_A64, TBII, - (arm_regime_tbi1(env, mmu_idx) << 1) | - arm_regime_tbi0(env, mmu_idx)); + +#ifndef CONFIG_USER_ONLY + /* + * Get control bits for tagged addresses. Note that the + * translator only uses this for instruction addresses. + */ + { + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); + 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) { + ARMVAParameters p1 = aa64_va_parameters_both(env, -1, stage1); + tbid = (p1.tbi << 1) | p0.tbi; + tbii = tbid & ~((p1.tbid << 1) | p0.tbid); + } else { + tbid = p0.tbi; + tbii = tbid & !p0.tbid; + } + + flags = FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); + } +#endif if (cpu_isar_feature(aa64_sve, cpu)) { int sve_el = sve_exception_el(env, current_el);