From patchwork Thu Oct 17 18:50:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 176683 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp1337966ill; Thu, 17 Oct 2019 11:52:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqxi7DEO8qo76ydHaSoLM7zB9Ao2lR3VQgxJs2BQnWo4fxiq0I3Lmgti8ntpobawdv7QXqZO X-Received: by 2002:a05:620a:12b9:: with SMTP id x25mr1456170qki.4.1571338327850; Thu, 17 Oct 2019 11:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1571338327; cv=none; d=google.com; s=arc-20160816; b=NPAYc4RjbQIKT52ixte0ajuZIbqfa6O41Z+ev/KfdCv2UZr/f1tkn0vM0o7NbaytSL 3+mTjn9AZSQ62yE/T+AxaAhrsdVbtZSf/dosY5M1ubENe2g8kl6DfykSzM3BMrku/iMl qg3nI30oD4L4CWSLl+3DUP5q9sYxtLGuwmyihXvFc/a49e3h0Z+Ucaww1zTtlOn1q1re 4VVWvXCD9eMow9CE9bheBh84GNUGWwKP90Amq3u+5o4p0BprQBk/ojYn2/LsnYvFUxmS ZYgvQNFQqEVUZ0+ti+1UhKSZMeekc51g7RkfhBcQaAhZcDHdxHdKmrlgSJjns7irS62q g/CA== 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=udJuL9Qeed+9BBACfy/zX7yDSpzS/YlN6hjDw0SLge6hF0Fp3AjzQNvbirTtYJxCRI K/8RrZH/glfB9Sm619TBFXa0grxi+39q+sIZ10y8nRLhQ30twByF/NPl8ws3+c+MHHQD blMff1Rq4W8eRZ4EomFb4+5yPKQVs/DD6Ntm1H75BBXBGZCnr1ka6SlBTrPoFNAcJUBI trIqErV4MZCsoVqaADFFUFNMGR4YZFN8XvO6dRaMK2ry7Ot3cU/PMDutwgQM0nPuB6iH 0xiwjV2coNiLKcQIrTLNOMPBTSpmtWDHjzXCNbyIv/T1dvgxsql0cN6Bhk0Ej27EOZdl f/uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Q1lu7Byx; 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 y66si3047640qke.145.2019.10.17.11.52.07 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 17 Oct 2019 11:52:07 -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=Q1lu7Byx; 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]:56722 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLAsY-00015k-S5 for patch@linaro.org; Thu, 17 Oct 2019 14:52:06 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35011) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iLArl-00012L-Te for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iLArk-0000pF-IA for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:17 -0400 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]:34848) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1iLArk-0000ov-Cb for qemu-devel@nongnu.org; Thu, 17 Oct 2019 14:51:16 -0400 Received: by mail-pg1-x543.google.com with SMTP id p30so1877102pgl.2 for ; Thu, 17 Oct 2019 11:51:16 -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=Q1lu7ByxrpzlIeZR7hd36AnvstqdCH0FqremQcY5bEBwh5ML/Pl+SQzmYM6o4oZDvf i0JNMSCcI1FS/HEY5FKmJ9q9nQwUcqxLNR7DQw264C0PoTbIj1Stf52BbBvosEHytdNo MKbj1yuPtBBGQJ2Bg012yCombWsvnBMG75dK6LoKU3JqIfPOT0dmhCK5nI09c8jRUFCG Lde/2Blk46bxNLtTmU6y04NShABoWxpLWv+iwcmB6GOWEDt8+rCs2xGiXVUslz98HFCp Fwkvsrc3LH55QPCtKsdcVYx9iVyxgrZppj5m5MTMzMJEi6so8O1l+daCziKqz9MvAWau aHWA== 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=qJVjwYeTthXRBhAvyG1nOK47VQXtxLg5+Uto1n4Z+Rb2ueQiYJfcYSYyIPLL/RNvBK 9z2jxzwKcFwM+pyB5pyePHGGXSPO44MryY6/CVnds5AgP1Dw3WYnN87c6mZlDb4gkIi/ KaaGzeVZ80VhjRCqTmpxahzl3GRpnTgdsyv1OykekeiOw60Q4EEmPoclWtZ9flvD0JPK 3dUThO7QJzvqkmhDQgj5usaCV19PVVkOutu8vzbNfnWmzV/wcmYxUY7Onj1wiQ+mwdi6 myCRy1AV/k+X/u15B9KdjFSw5qMvR/2g8oLwrPHdW9ek+j7V/OWu2TipeBGdL0ggX2Jw Wl3A== X-Gm-Message-State: APjAAAWdlsR4Pi4sVhn3vjAj3SG4AP7U+VjvAv20Jn0wuhYEHV3yKy8C 8ZG00nwfNMK3zlI8LA8aydTT1JWhnrI= X-Received: by 2002:aa7:8ad0:: with SMTP id b16mr1855140pfd.255.1571338274993; Thu, 17 Oct 2019 11:51:14 -0700 (PDT) Received: from localhost.localdomain (97-113-7-119.tukw.qwest.net. [97.113.7.119]) by smtp.gmail.com with ESMTPSA id s97sm5009256pjc.4.2019.10.17.11.51.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 17 Oct 2019 11:51:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Subject: [PATCH v7 02/20] target/arm: Split out rebuild_hflags_a64 Date: Thu, 17 Oct 2019 11:50:52 -0700 Message-Id: <20191017185110.539-3-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191017185110.539-1-richard.henderson@linaro.org> References: <20191017185110.539-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::543 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: