From nobody Tue Feb 10 05:45:42 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 154698727665217.329060885483955; Tue, 8 Jan 2019 14:41:16 -0800 (PST) Received: from localhost ([127.0.0.1]:41983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gh03f-0008HV-Ga for importer@patchew.org; Tue, 08 Jan 2019 17:41:15 -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) 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) 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-Google-Smtp-Source: ALg8bN6egf05w1YlSpV8w1zlt0NQ0aAsv+lYG/dYgc5E/5rcqDfSLUH/xDuqvp583oShsgy6Bgiv2A== X-Received: by 2002:a17:902:2bc5:: with SMTP id l63mr3618103plb.107.1546986755992; 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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(-) 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 *e= nv) } #endif =20 -#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); =20 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 mm= u_idx) return mmu_idx; } =20 -/* 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 =3D stage_1_mmu_idx(mmu_idx); - - tcr =3D regime_tcr(env, mmu_idx); - el =3D 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 =3D stage_1_mmu_idx(mmu_idx); - - tcr =3D regime_tcr(env, mmu_idx); - el =3D 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, targe= t_ulong *pc, =20 *pc =3D env->pc; flags =3D FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - /* Get control bits for tagged addresses */ - flags =3D 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 =3D stage_1_mmu_idx(mmu_idx); + ARMVAParameters p0 =3D 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 =3D aa64_va_parameters_both(env, -1, st= age1); + tbid =3D (p1.tbi << 1) | p0.tbi; + tbii =3D tbid & ~((p1.tbid << 1) | p0.tbid); + } else { + tbid =3D p0.tbi; + tbii =3D tbid & !p0.tbid; + } + + flags =3D FIELD_DP32(flags, TBFLAG_A64, TBII, tbii); + } +#endif =20 if (cpu_isar_feature(aa64_sve, cpu)) { int sve_el =3D sve_exception_el(env, current_el); --=20 2.17.2