From patchwork Wed Oct 23 15:00:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 177319 Delivered-To: patch@linaro.org Received: by 2002:a92:409a:0:0:0:0:0 with SMTP id d26csp907711ill; Wed, 23 Oct 2019 08:48:32 -0700 (PDT) X-Google-Smtp-Source: APXvYqyqY1l57JlANBYjDYUZy+LweZNEyTQ8WDRhSM6czZcNa8tMkkV7ib/1sexzbMQVAIhTeop7 X-Received: by 2002:ac8:359d:: with SMTP id k29mr9399678qtb.96.1571845712540; Wed, 23 Oct 2019 08:48:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571845712; cv=none; d=google.com; s=arc-20160816; b=ZLdZPpF3+SCKIoqK8EI2Rl68wGnzKt1wyxK7w4/t2b1AuIvEHJN/4U58UL68L1hr4K HBAqKBs1qllbPPdm2ZGS3tWq21dXG8Rr8PAj/IqO/dHLKZI6m3OGFYr8zHj+n1EK+XTm H3BTuSFzN1A0NCMRguKus+rs2UcCBDzYnjxbxGPsSagX0NCO/Fb7xOL2t9rP3LnsqsJN 2OUB5kUNN5qB1WNVkxgiiP3ZjFzYk0hj+x/QyfP9SyDiWvfL/SBqFADBFyand2zrQoC1 LOAWM2tOMoDXcuOaHkIqTsNGmpcO4VunS/pUndVRHNOk1ZFaamNYTLEeu1VqgqCJC9xx 2DDw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=UkzWHUTpFthIfQVy0NzJgzZOkNfWgDN9gBuKupnF6zONzkme3zk0wvAauF0O2MTwF5 n3ueoeUkIx3ZxdhBKtU+DIpYVOZIdBSqQa6yyEUHrUKt6U/C4iXAGkcLHUG+rY5eLH2F CymZDYcyRi6yWvKQo5/UrW/W+kJEFq/Uj9BuDRGKlhRUomB03iqmKzinU7RqPJYoQWMP e4D6KNKAVLczZxAcpa9xS858Nyw30hxhxzvUBQiX/bdP44YzGxeKit/VoKJgiWZfMcdz 3TlqlG581hUG4XvyVlvXk0q2eK2zhY+yYJdYsuNvLpXaRSrDiWkkL67LLTS+e/CBym1N +rJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SU1JrHFr; 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=pass (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 c22si14569105qko.286.2019.10.23.08.48.32 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 23 Oct 2019 08:48:32 -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=pass header.i=@linaro.org header.s=google header.b=SU1JrHFr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:39954 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNIsB-0007Is-Fw for patch@linaro.org; Wed, 23 Oct 2019 11:48:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iNI8x-0008FR-9f for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iNI8q-0001E9-RO for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:46 -0400 Received: from mail-qt1-x842.google.com ([2607:f8b0:4864:20::842]:46546) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iNI8q-0000zc-KZ for qemu-devel@nongnu.org; Wed, 23 Oct 2019 11:01:40 -0400 Received: by mail-qt1-x842.google.com with SMTP id u22so32677173qtq.13 for ; Wed, 23 Oct 2019 08:01:06 -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 :mime-version:content-transfer-encoding; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=SU1JrHFr7k1kmhDhIJjaVmbpu850wRRaC9NGaYOyxFWi712AROvpFjL55boVXtSq8/ hOLu1pCT3DAPAC3DgondPj8aRGK1Y919fMNqcwgMgETJgLT2h+QMDuyRl47RzyEeaz// b1kyG9sA3sKOdCTY9mwTrcGIM10kq4+3bljqGRm4O2ChzXeO4rB5wDrodvOPQkDJI+jg zq96aDdOO0XKzo9+EWWKybYWY+DspwWBvxuvU+Y2U00WuWXjsyHib71GDcxI3jtS4L3R wCSpO0oglseT+djDXNZOSreX8lTPNfzATUgaG7iO27/l8UwmdNhSRgrENSDdZuMXdxtB EoDQ== 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:mime-version:content-transfer-encoding; bh=qxe5WkTH2gH9OxzrQymT8yteWQToRtaNSxbFtmMzahk=; b=U+xiaZ8sXmhcmm8UrgPRCjCcKsAcUsweQwzDdkkfhQIrNmsbh4qsi44C+aX0qGMDy2 X0jnZs4833Q0e+ZTVtQv92p9Hqzn2ilAjjaDFu1uIucQ0VM8IwzYaWCchOXJ9mv/Wh1n eQtZy6Gp3l9jFERsoEsCaxe1Z+JmkGLDiVvxMRmGbbB1jd+BSdCDuv3dwWC/jOprp/23 DAtxNFh4JnTcvgR6eoA2DSwCsoOvhSOyjV7eePVP6cHgPQkxyHrIdwbQTs8mY9ucdmjA 8VhDCv/igS8eRRsENRYdHl6Mk/93Bm6VR6h5I19jdWDKSQT2akYHeXdSLKNbdesHl6jW Oaig== X-Gm-Message-State: APjAAAXYdEnYTwhk9bi9IzjGrp3KoRvRT47344IyNQdGdpK1L9TJyEw3 T1wbbOC2UwninHLKKjPTP2jYVU8kIDo= X-Received: by 2002:ac8:7a97:: with SMTP id x23mr9729232qtr.38.1571842864257; Wed, 23 Oct 2019 08:01:04 -0700 (PDT) Received: from localhost.localdomain (198-4-20-64.static.cosmoweb.net. [64.20.4.198]) by smtp.gmail.com with ESMTPSA id l189sm11030168qke.69.2019.10.23.08.01.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Oct 2019 08:01:03 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v9 02/24] target/arm: Split out rebuild_hflags_a64 Date: Wed, 23 Oct 2019 11:00:35 -0400 Message-Id: <20191023150057.25731-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191023150057.25731-1-richard.henderson@linaro.org> References: <20191023150057.25731-1-richard.henderson@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::842 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 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. Reviewed-by: Alex Bennée Signed-off-by: Richard Henderson --- target/arm/helper.c | 131 +++++++++++++++++++++++--------------------- 1 file changed, 69 insertions(+), 62 deletions(-) -- 2.17.1 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: