From patchwork Fri Oct 11 15:55:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 175985 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp941482ill; Fri, 11 Oct 2019 08:57:21 -0700 (PDT) X-Google-Smtp-Source: APXvYqxpwr6O1pfxiB3FRI9+OpwvNstd1uP1LP/mA4NfjsJuWmzxqGQR/4BL1Xx5bmnvIHYNu2pC X-Received: by 2002:a05:6402:60e:: with SMTP id n14mr14632359edv.147.1570809440969; Fri, 11 Oct 2019 08:57:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570809440; cv=none; d=google.com; s=arc-20160816; b=kPWWIPr1XwKvaQig0SEuYMBRERspDPUA9NjP4budN3yMrHILltRm+HVyknuz6MCN9o FWSM3IwzVloA3Iwou3NrCjCXjCNYF2KuxAu9IA7wvgPdwKihDyKrg8xVIgipyioi9dgQ 9mYNmqm0FVkXGG2hGvMidxoURBwZQXDe0A/VWBKhVn6C4b0OfDXwC2Goeq2MPRaI/O1D gRkwyBMVlYUK3npJvzeCkjHKrNTIUWqntBU7koJXWPmiy8PShNFG8ybHLBGi6rEcwT9P Jmg0Bg2hrsexo0wCong0qi0BrM7sJLKWxKZjiRjzMkDf42xNbR3/TJgT46/91kCrVJU0 Xt+A== 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=65DLYW7/Ow+07Tjw5e+t9xOA5BC0nBNoELJCwewcid4=; b=J0zlPG5ZVLsdM5Cigj4oaO0g1gucsFMM6yJsFQEA4irL3vkzNvMniaTidl2kW7pAHe jLkC8O3sMTyq1Zu8nhWIPHHmlLrIW4cv07ibaPv7nEGStOzukTWgWvo1TUxW+U7NGtdx D5QJLX2foqH/DyjkEr6xirZso0DQ2xpSzUogSifEN12D87/4ZAHPOWpCQwjOf7dba+sf b3pRKyiau3Q8HxQPHnDLhuwnna5Mkr3Ln7zRtSULGUACCglVhW7WykUWIBtagqB9ggt5 axr8ExV5hhAwcK5Ju4BwLkN7Cy29crPBmFQ4qeYmMdVoGcr6NPXZjqXgKJ6+UPAyAnzB UNEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=xB8opQP2; 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 s1si5771993ejf.305.2019.10.11.08.57.20 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 11 Oct 2019 08:57:20 -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=xB8opQP2; 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]:52798 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIxI7-00036t-BU for patch@linaro.org; Fri, 11 Oct 2019 11:57:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33575) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iIxGk-0002FM-Q0 for qemu-devel@nongnu.org; Fri, 11 Oct 2019 11:55:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iIxGh-0007YF-Ci for qemu-devel@nongnu.org; Fri, 11 Oct 2019 11:55:54 -0400 Received: from mail-yb1-xb41.google.com ([2607:f8b0:4864:20::b41]:36667) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iIxGh-0007Xi-94 for qemu-devel@nongnu.org; Fri, 11 Oct 2019 11:55:51 -0400 Received: by mail-yb1-xb41.google.com with SMTP id t4so584258ybk.3 for ; Fri, 11 Oct 2019 08:55:51 -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=65DLYW7/Ow+07Tjw5e+t9xOA5BC0nBNoELJCwewcid4=; b=xB8opQP2dG3/FvXwITem/t/Ars+nHM7HXma72cKBb38DmxycOvdsbbVdbHEJvLE5Hc HvJtbBnrvs6Jt8dtkpgGfuW+qP+6s4mZ/AGbt1yMOwA5+dVBOg3onVkcKx1aDiF4g81J Vn9JidJmGsS/Rr+/OlW1D8IJOtd7CqAsFwszqgKyVC8B0YLUA33fm6phpO+K8vI5cD92 9FEfRUEyDFKC2DSCUqD5rNIOBD860fAV/SMjajkH27Uhf31ucGPn0lcd56czqB1wHYkU wCFeZrDznnfI6aV4t1Xc6A5r1DA2LRDojZPdOAUPsiEQHSI64j56QBy9WvZc/FzuIYzK 01bw== 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=65DLYW7/Ow+07Tjw5e+t9xOA5BC0nBNoELJCwewcid4=; b=aqLokq8KHxRm8jtI0Ye63B8QjzUyRXXcgIYTFqYuXBKrQ+gjRRcBlKI+G6FDOsR61V IEkchErMTauBCiKutFevp0C/Z22297B2L4n4Nk+4JYd5YjqwWbGiQmTXbA+9oS9JqXPn 68jBmtXNDQfYdVkdguwxbyCclziLIoBbV5N6OqJc5MpIHehQfVJWZ6PuoEFBem6Wk13s 5KZ6hVIL+eh/BkoiU2l+BLGWhq+ojdmz8SI8T4Cn5bCqw/k2RtqyJEb1kqw5kB1HDAGi 8M9OFyZLfh4Jgv4nATV4A/Oo6k1+Efxxovec2S68e/Bh0OPZHknaCKSjceq38gWFk36t 03Lw== X-Gm-Message-State: APjAAAUiFqT/eGVKxccyuF0i6Tcw98bYVYE3roQhqNe36EjTlxEkM9GD MbsTE5SD1nLVobH4D+Q9a8q4Z2emAiQ= X-Received: by 2002:a5b:30d:: with SMTP id j13mr10597617ybp.308.1570809350192; Fri, 11 Oct 2019 08:55:50 -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 d17sm2473139ywb.95.2019.10.11.08.55.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 11 Oct 2019 08:55:49 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v6 02/20] target/arm: Split out rebuild_hflags_a64 Date: Fri, 11 Oct 2019 11:55:28 -0400 Message-Id: <20191011155546.14342-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191011155546.14342-1-richard.henderson@linaro.org> References: <20191011155546.14342-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::b41 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: laurent.desnogues@gmail.com, peter.maydell@linaro.org, qemu-arm@nongnu.org Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Create a function to compute the values of the TBFLAG_A64 bits that will be cached. For now, the env->hflags variable is not used, and the results are fed back to cpu_get_tb_cpu_state. Note that not all BTI related flags are cached, so we have to test the BTI feature twice -- once for those bits moved out to rebuild_hflags_a64 and once for those bits that remain in cpu_get_tb_cpu_state. Signed-off-by: Richard Henderson --- target/arm/helper.c | 131 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 62 deletions(-) -- 2.17.1 Reviewed-by: Alex Bennée diff --git a/target/arm/helper.c b/target/arm/helper.c index 8829d91ae1..69da04786e 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -11070,6 +11070,71 @@ static uint32_t rebuild_hflags_common(CPUARMState *env, int fp_el, return flags; } +static uint32_t rebuild_hflags_a64(CPUARMState *env, int el, int fp_el, + ARMMMUIdx mmu_idx) +{ + ARMMMUIdx stage1 = stage_1_mmu_idx(mmu_idx); + ARMVAParameters p0 = aa64_va_parameters_both(env, 0, stage1); + uint32_t flags = 0; + uint64_t sctlr; + int tbii, tbid; + + flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); + + /* 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); + flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); + + if (cpu_isar_feature(aa64_sve, env_archcpu(env))) { + int sve_el = sve_exception_el(env, el); + uint32_t zcr_len; + + /* + * If SVE is disabled, but FP is enabled, + * then the effective len is 0. + */ + if (sve_el != 0 && fp_el == 0) { + zcr_len = 0; + } else { + zcr_len = sve_zcr_len_for_el(env, el); + } + flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); + flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); + } + + sctlr = arm_sctlr(env, el); + + if (cpu_isar_feature(aa64_pauth, env_archcpu(env))) { + /* + * In order to save space in flags, we record only whether + * pauth is "inactive", meaning all insns are implemented as + * a nop, or "active" when some action must be performed. + * The decision of which action to take is left to a helper. + */ + if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { + flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); + } + } + + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { + /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ + if (sctlr & (el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { + flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); + } + } + + return rebuild_hflags_common(env, fp_el, mmu_idx, flags); +} + void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, target_ulong *cs_base, uint32_t *pflags) { @@ -11079,67 +11144,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, uint32_t flags = 0; if (is_a64(env)) { - ARMCPU *cpu = env_archcpu(env); - uint64_t sctlr; - *pc = env->pc; - flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); - - /* Get control bits for tagged 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); - flags = FIELD_DP32(flags, TBFLAG_A64, TBID, tbid); - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - int sve_el = sve_exception_el(env, current_el); - uint32_t zcr_len; - - /* If SVE is disabled, but FP is enabled, - * then the effective len is 0. - */ - if (sve_el != 0 && fp_el == 0) { - zcr_len = 0; - } else { - zcr_len = sve_zcr_len_for_el(env, current_el); - } - flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); - flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); - } - - sctlr = arm_sctlr(env, current_el); - - if (cpu_isar_feature(aa64_pauth, cpu)) { - /* - * In order to save space in flags, we record only whether - * pauth is "inactive", meaning all insns are implemented as - * a nop, or "active" when some action must be performed. - * The decision of which action to take is left to a helper. - */ - if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB)) { - flags = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); - } - } - - if (cpu_isar_feature(aa64_bti, cpu)) { - /* Note that SCTLR_EL[23].BT == SCTLR_BT1. */ - if (sctlr & (current_el == 0 ? SCTLR_BT0 : SCTLR_BT1)) { - flags = FIELD_DP32(flags, TBFLAG_A64, BT, 1); - } + flags = rebuild_hflags_a64(env, current_el, fp_el, mmu_idx); + if (cpu_isar_feature(aa64_bti, env_archcpu(env))) { flags = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); } } else { @@ -11159,9 +11166,9 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A32, XSCALE_CPAR, env->cp15.c15_cpar); } - } - flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); + flags = rebuild_hflags_common(env, fp_el, mmu_idx, flags); + } /* The SS_ACTIVE and PSTATE_SS bits correspond to the state machine * states defined in the ARM ARM for software singlestep: