From nobody Tue Feb 10 03:40:00 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 15471230253168.117080539365475; Thu, 10 Jan 2019 04:23:45 -0800 (PST) Received: from localhost ([127.0.0.1]:57492 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZN6-00004w-S0 for importer@patchew.org; Thu, 10 Jan 2019 07:23:40 -0500 Received: from eggs.gnu.org ([209.51.188.92]:55944) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ghZHV-0004Uh-RW for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:17:54 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ghZHU-0007Yj-UE for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:17:53 -0500 Received: from mail-pl1-x643.google.com ([2607:f8b0:4864:20::643]:43506) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ghZHU-0007Y8-Ne for qemu-devel@nongnu.org; Thu, 10 Jan 2019 07:17:52 -0500 Received: by mail-pl1-x643.google.com with SMTP id gn14so5109073plb.10 for ; Thu, 10 Jan 2019 04:17:52 -0800 (PST) Received: from cloudburst.twiddle.net (c220-239-117-135.belrs4.nsw.optusnet.com.au. [220.239.117.135]) by smtp.gmail.com with ESMTPSA id h74sm140934699pfd.35.2019.01.10.04.17.49 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Jan 2019 04:17:50 -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=fkaNmZExNvexpax6vpTVFC0ERbhvs5NzXZdOCGU7hoY=; b=PZHnUCJ0kNHlPBr0dOaEwsCUJEWxpULjgxa2NpGOlAgXGVQSYO5CWe3QMcaP3PH17V M0yv+q631zamwC8dVyYLCf7lGuy0RAn0e7I2iwwHZfstVQ0O6Z+xS2eFBSr3owHWAtQG FmVM5TcMWTyqiJBSHqaehZUSt8QzZhduXAWmY= 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=fkaNmZExNvexpax6vpTVFC0ERbhvs5NzXZdOCGU7hoY=; b=GqDE2/EOl4v09Yxa13pRx41tlhanjiC3Cp/MJ13bz17/TrA7OwaqW1XksI7LSjcEsT 8WsISXSCGLVwXnn2uEzoDgtlz2JV9DBCwvwaGVha36Qa2UoO6dujy2wsCpBDHzoxBqZr o36k7+Tt8xgPvizPZGo74RmrkEe8MZvZmbGjeOZIGbnmNNP/4q2CPKlKtP098ULrXobW W2wnsY/ioOuaqbz9OkMg71OkePEoUsfXhpYoDaSugLRFu6zQ3zBIJyN1scL3w3IY7Da0 IV3DaIxKPCEcGiS8pGhoMicd0m1I9UvEFi1PSWZPzsuIU2SY7XZ8V2SrKmCt9eLUawQJ taUQ== X-Gm-Message-State: AJcUukd+CmVkiFrRFfVArIcmuG094xSVgntBMK+W4DhjdU6Wt7gAlIu1 6jQugS3i1MSrK5IprJDB6M8HcoVF+38RAA== X-Google-Smtp-Source: ALg8bN6kP7TFBWsTwgi50SN4nBZZj37TlDac2PTjhyYF+cPb/EQHT/V96x1HGmzdqgqjPT6OYaFdvw== X-Received: by 2002:a17:902:8c91:: with SMTP id t17mr9823027plo.119.1547122671242; Thu, 10 Jan 2019 04:17:51 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 10 Jan 2019 23:17:28 +1100 Message-Id: <20190110121736.23448-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190110121736.23448-1-richard.henderson@linaro.org> References: <20190110121736.23448-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 03/11] 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" Signed-off-by: Richard Henderson Reviewed-by: Peter Maydell --- 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 8179c07250..506c490a16 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -2990,6 +2990,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 0e1bf521ab..138d9d5565 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -13076,6 +13076,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); @@ -13120,6 +13121,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 @@ -13127,17 +13134,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 e43f0982f9..ca2ae40701 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -13800,6 +13800,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