From nobody Wed Oct 1 02:11:46 2025 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 1548715918054784.8586722521687; Mon, 28 Jan 2019 14:51:58 -0800 (PST) Received: from localhost ([127.0.0.1]:39724 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goFky-0004ux-VN for importer@patchew.org; Mon, 28 Jan 2019 17:51:57 -0500 Received: from eggs.gnu.org ([209.51.188.92]:47054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goFcC-0006rk-Ue for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:42:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1goFRE-0006Cn-Ua for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:31:34 -0500 Received: from mail-oi1-x244.google.com ([2607:f8b0:4864:20::244]:35290) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1goFRE-0006Ai-Js for qemu-devel@nongnu.org; Mon, 28 Jan 2019 17:31:32 -0500 Received: by mail-oi1-x244.google.com with SMTP id v6so14530861oif.2 for ; Mon, 28 Jan 2019 14:31:29 -0800 (PST) Received: from cloudburst.twiddle.net ([12.227.73.85]) by smtp.gmail.com with ESMTPSA id v3sm7460438oib.57.2019.01.28.14.31.27 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 28 Jan 2019 14:31:27 -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=yfx9FpdqdozZiBPg7dcsv6e5CFB+7qa5v/xOlmbgNhY=; b=kM4pn0wB9UQR3RwymhGca/pcSefCUtQUgGGnOOBospAPrRGzF2FuPPeq3FuWtRpjuE qgduZmP4+N0hoThqHclyS+E7FuZZWum3hY7bkXqpOq3dXUEK7vXW7PK/2qjl5oOB5Leb x90pq8fSLHWvnsKEjjqKvUTCNm178LayPE+n8= 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=yfx9FpdqdozZiBPg7dcsv6e5CFB+7qa5v/xOlmbgNhY=; b=AcP1piEgnaWCFpWjM2Pl/+0FT+P6iBceBUueutx6OU1zTRp89dF/5CYYvtc7nONvBC YQ42ZxE0oQ3HXLOd0NkH08Jpmg1GX5bIZIqjGk93jPafEmOxQD8Hm1XR1bajGGz+2UlE sl0SqyQjXE3ElJLsoEHd0PUjUUdTwio+UuU47RdaLbv77gfXfLyTHGui2l8zGhFqPSCT sasV0blvhVnl/56uviaNZFlL+elgt2YwwiGbeTGFGeD7NkFK1mODtdaXNCsLAL0uRatc jydH4EwFf+ZIXKoXjf4Zf5ZLlFDXezDJL+wN7Kifq6thaySAF1MqQjM1tr1gx2ZgJAlV iOyQ== X-Gm-Message-State: AJcUukctIn2VlyGE/5/KjTxqI6quo9XM9sBBQOOmi8o7YjoieDgjMu+y 0DcWuQsLv+VRl0Sh1qKU2jtGWTB06nw= X-Google-Smtp-Source: ALg8bN6ZlkTfgoWdL3TKZm9tusiJfU9wcZzJs9E5wx5rDX4EKEzEVkgEhkBijLCWNIFvd03DR6mnNg== X-Received: by 2002:aca:aad8:: with SMTP id t207mr7021779oie.90.1548714688679; Mon, 28 Jan 2019 14:31:28 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Mon, 28 Jan 2019 14:31:09 -0800 Message-Id: <20190128223118.5255-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190128223118.5255-1-richard.henderson@linaro.org> References: <20190128223118.5255-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::244 Subject: [Qemu-devel] [PATCH v2 03/12] target/arm: Add BT and BTYPE to tb->flags 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" Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson --- target/arm/cpu.h | 2 ++ target/arm/translate.h | 4 ++++ target/arm/helper.c | 22 +++++++++++++++------- target/arm/translate-a64.c | 2 ++ 4 files changed, 23 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 76e2f8fd42..e18f823419 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3043,6 +3043,8 @@ FIELD(TBFLAG_A64, TBII, 0, 2) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) +FIELD(TBFLAG_A64, BT, 9, 1) +FIELD(TBFLAG_A64, BTYPE, 10, 2) =20 static inline bool bswap_code(bool sctlr_b) { diff --git a/target/arm/translate.h b/target/arm/translate.h index bb37d35741..3d5e8bacac 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -69,6 +69,10 @@ typedef struct DisasContext { bool ss_same_el; /* True if v8.3-PAuth is active. */ bool pauth_active; + /* True with v8.5-BTI and SCTLR_ELx.BT* set. */ + bool bt; + /* A copy of PSTATE.BTYPE, which will be 0 without v8.5-BTI. */ + uint8_t btype; /* Bottom two bits of XScale c15_cpar coprocessor access control reg */ int c15_cpar; /* TCG op of the current insn_start. */ diff --git a/target/arm/helper.c b/target/arm/helper.c index 92666e5208..6efe88a157 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -13607,6 +13607,7 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_= ulong *pc, =20 if (is_a64(env)) { ARMCPU *cpu =3D arm_env_get_cpu(env); + uint64_t sctlr; =20 *pc =3D env->pc; flags =3D FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); @@ -13651,6 +13652,12 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target= _ulong *pc, flags =3D FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); } =20 + if (current_el =3D=3D 0) { + /* FIXME: ARMv8.1-VHE S2 translation regime. */ + sctlr =3D env->cp15.sctlr_el[1]; + } else { + sctlr =3D env->cp15.sctlr_el[current_el]; + } if (cpu_isar_feature(aa64_pauth, cpu)) { /* * In order to save space in flags, we record only whether @@ -13658,17 +13665,18 @@ void cpu_get_tb_cpu_state(CPUARMState *env, targe= t_ulong *pc, * a nop, or "active" when some action must be performed. * The decision of which action to take is left to a helper. */ - uint64_t sctlr; - if (current_el =3D=3D 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr =3D env->cp15.sctlr_el[1]; - } else { - sctlr =3D env->cp15.sctlr_el[current_el]; - } if (sctlr & (SCTLR_EnIA | SCTLR_EnIB | SCTLR_EnDA | SCTLR_EnDB= )) { flags =3D FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); } } + + if (cpu_isar_feature(aa64_bti, cpu)) { + /* Note that SCTLR_EL[23].BT =3D=3D SCTLR_BT1. */ + if (sctlr & (current_el =3D=3D 0 ? SCTLR_BT0 : SCTLR_BT1)) { + flags =3D FIELD_DP32(flags, TBFLAG_A64, BT, 1); + } + flags =3D FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); + } } else { *pc =3D env->regs[15]; flags =3D FIELD_DP32(flags, TBFLAG_A32, THUMB, env->thumb); diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 611279e98e..9ce523e2ff 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -13801,6 +13801,8 @@ static void aarch64_tr_init_disas_context(DisasCont= extBase *dcbase, dc->sve_excp_el =3D FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); dc->sve_len =3D (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; dc->pauth_active =3D FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); + dc->bt =3D FIELD_EX32(tb_flags, TBFLAG_A64, BT); + dc->btype =3D FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE); dc->vec_len =3D 0; dc->vec_stride =3D 0; dc->cp_regs =3D arm_cpu->cp_regs; --=20 2.17.2