From patchwork Mon Jan 28 22:31:09 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156907 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3964646jaa; Mon, 28 Jan 2019 14:50:14 -0800 (PST) X-Google-Smtp-Source: ALg8bN7PRi3S9/7YiSQfCoZs1lBLduI7fm4bwxfeGDn9NDqPQTVOVxET5y6L0yfDNJphafVG2QQ5 X-Received: by 2002:a5d:6889:: with SMTP id h9mr23300778wru.222.1548715814040; Mon, 28 Jan 2019 14:50:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548715814; cv=none; d=google.com; s=arc-20160816; b=pw/meBAuzulrYkSFHFLYIvBycqzqr9OtL+k0wFfqfJ4/gB4Vs8OJO6pGQ18euUnIm7 wI3xjmIJP6dKYWIoAhFCnNBzwBHoPQyYC8k82MfnO9wXLououIrNoEfCY/qB2el/7hlT /N/DC4owhO81OU8L5Vxf2RtY/C1Xwna0wMiyoaUjjFhHa0H/8jlC09ikosSk7pDT27Fp FZbeuY3rNLiJRHIfaE4GacMgreMZ4hg4WQ0+3qJUwqe19ajT0iSGLdHjD5w4Wsis6aQu LUcMm3ftbafDqy2MDMxbcZcU4TQsSdLs8gDsXQlqF+fCG304NIwuuKFk8+B6Fr3ZJ7bB PkVg== 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:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=yfx9FpdqdozZiBPg7dcsv6e5CFB+7qa5v/xOlmbgNhY=; b=MaqooS0oehRtTYSYZ6TuBN03fZF1N1JLDAexhNDfubWVcZDcxaFKhAuLpqvq+fCmA9 8scw4b51Lbj5sSO1HNbNMxBEfWMWDVyX2jKGTRqpjcKs2EzhNnrELtDRAmBFXKbypM2X azjVsu2wj5FfH8FfZ38h2bx1rdZFFGT3xIp5Ke3XiR0SA3+ahMcKzj4ya4a4rrExAK8d q3WU2aANvQXHhLHnhhTjxg5g8jteQHXLeRDBj4X6TkJB7x5DlTwtmMLBAuVQQtG3jXiT RMHRoVQafEcrPtGsRqhrkbtPBjtqWZ8UiHIKeKv6Fyv/GF+fbvOoJ1HdVGFi9qOUHVS/ /F5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=kM4pn0wB; 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 s82si529364wmf.82.2019.01.28.14.50.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 28 Jan 2019 14:50:14 -0800 (PST) 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=kM4pn0wB; 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 ([127.0.0.1]:39684 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1goFjJ-0003hE-0E for patch@linaro.org; Mon, 28 Jan 2019 17:50:13 -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) 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-Received: by 2002:aca:aad8:: with SMTP id t207mr7021779oie.90.1548714688679; Mon, 28 Jan 2019 14:31:28 -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) 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.17.2 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) 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, if (is_a64(env)) { ARMCPU *cpu = arm_env_get_cpu(env); + uint64_t sctlr; *pc = env->pc; flags = FIELD_DP32(flags, TBFLAG_ANY, AARCH64_STATE, 1); @@ -13651,6 +13652,12 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); } + if (current_el == 0) { + /* FIXME: ARMv8.1-VHE S2 translation regime. */ + sctlr = env->cp15.sctlr_el[1]; + } else { + sctlr = 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, target_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 == 0) { - /* FIXME: ARMv8.1-VHE S2 translation regime. */ - sctlr = env->cp15.sctlr_el[1]; - } else { - sctlr = env->cp15.sctlr_el[current_el]; - } 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 = FIELD_DP32(flags, TBFLAG_A64, BTYPE, env->btype); + } } else { *pc = env->regs[15]; flags = 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(DisasContextBase *dcbase, dc->sve_excp_el = FIELD_EX32(tb_flags, TBFLAG_A64, SVEEXC_EL); dc->sve_len = (FIELD_EX32(tb_flags, TBFLAG_A64, ZCR_LEN) + 1) * 16; dc->pauth_active = FIELD_EX32(tb_flags, TBFLAG_A64, PAUTH_ACTIVE); + dc->bt = FIELD_EX32(tb_flags, TBFLAG_A64, BT); + dc->btype = FIELD_EX32(tb_flags, TBFLAG_A64, BTYPE); dc->vec_len = 0; dc->vec_stride = 0; dc->cp_regs = arm_cpu->cp_regs;