From patchwork Fri Dec 14 05:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153751 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1676441ljp; Thu, 13 Dec 2018 21:33:39 -0800 (PST) X-Google-Smtp-Source: AFSGD/WX/RFNzC8LZdF1zQxd2X1/cvA5Y1rKkHI6RNTdLCUhBhbeQ7U0CtCIke3Sdxk9LlKsgBi7 X-Received: by 2002:ac8:3a22:: with SMTP id w31mr1496553qte.302.1544765619754; Thu, 13 Dec 2018 21:33:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544765619; cv=none; d=google.com; s=arc-20160816; b=O/hxp5wyvjtaA8UtnPAXTcS//awHQjh/RMiaFnoH6A4t1uStTQ02f0JekYhgNjAEYj JlZeVqkPA/3XoRmLTLBijnzMOrsu5F1Mj5BPTOjH01RaJjhUCpwj+fLUu9pyG+hul8Lf KfAvt050oUOBngNUJv+HWq1wyU1s6+JC9CysuS2AAHw+AEeSjRAJuqIqXsdKG4XxtFxs LqfMwIHpC6Sw+rae0q66vxC/8R4joW1TVoKCRuT7eByno3t2+u19orZa8WgGEN2/iHQY n1qhah7zGLiY8JQabt7oEL8r3Y99aBxjS78PUEnl/QZY/gQK4uQHu8dYKIO/gwBhBNE5 lIrA== 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=K33mNHUcprNraw8i7ozzfhPn3gQjuDAdVvhTCmVz184=; b=IIn7Kvuin0VeKWCo7j/oKTfEkuBBVfTifek7vwgMrAv/vWz2XCgeJSCHvsGC/KN/2g hHbjzjyqQUSDCcgaFM/4W05S+goQ2ojZIOyQwlptyIwpC2quwnVyCkVBhU4/QWzSSrRy c6+upmgP44m3b48PFpzpq936/BnXTSdn5PjoNwclEz2EkM8NotsEJByjHq61yh82PTa7 G+SWxscJIi0hhDRZlYaY8PbIESL94/qWvtj1TcOQEMdPYhUEsd+gWP/HUgK1QG5WoWXd /LUd6OhGbniMmSHEK6mXWwfK9AP5J2cqOq9lpE7mpTvdmsx2cTcuXMIxErjBvKbFobJ4 ISBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GF6+U6H4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t64si2104190qkf.154.2018.12.13.21.33.39 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 13 Dec 2018 21:33:39 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GF6+U6H4; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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]:59471 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXg6V-0002nr-3i for patch@linaro.org; Fri, 14 Dec 2018 00:33:39 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gXfxX-0004Ow-6Z for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:24 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gXfxV-0005Ky-B1 for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:22 -0500 Received: from mail-ot1-x341.google.com ([2607:f8b0:4864:20::341]:37360) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gXfxT-0005Jn-Dr for qemu-devel@nongnu.org; Fri, 14 Dec 2018 00:24:19 -0500 Received: by mail-ot1-x341.google.com with SMTP id 40so4318573oth.4 for ; Thu, 13 Dec 2018 21:24:17 -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=K33mNHUcprNraw8i7ozzfhPn3gQjuDAdVvhTCmVz184=; b=GF6+U6H4wL53TEndcpTqe4cNkqfGntkiwgPNGz9FBpe0eIrYsF0Z5j4KjRl5S+RzXW ufnhaykitY5+V7itU64bvBxjZRLTa1et62Qk/aAiojKSG7bAL2RCe5tDhTkvOTtnl5/w KWW5p3nMNW9pG0Y9PElpAOX3Akbyd6gqsIRww= 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=K33mNHUcprNraw8i7ozzfhPn3gQjuDAdVvhTCmVz184=; b=ivmK8ofrUyhYclQ5/uOBxL2SJE9vCeDOMUqOFt5FpxRBxEsFSEuXzYc0KQ5HEi4vtS 2CENOW5MqpnYwVpAUX3ffK/wsWuEIUZfbDPNU0HHFCyl7uIuCpoV5TfFy9U6suOJC08z CfbGokmExSa6WihMiUawfGd4W+2ysQyV9OegNM4H8hQKQi+5v+ZMpVGsGrcVgb+/c8Wj C2HxGrfvyMPFXYEvL8h65r+3HnvJeebFYlTLv7TKg8IVMzn+MJg8oCK4Wqwzv5BB2zcV 69S2AUudyNtjuy9Qcrym1PPY0F+zDDEGaYXDYvNqgeVpcHWjCXvWP8E/tOxygKykAsCt oarw== X-Gm-Message-State: AA+aEWaEymTRdBQ4XffQz+twykE2xXPblQrnzDCVoQiOO6KQR9w7dHIW tU1FGO7fGWn8Ki8EWA26Jj4eg5NG+sihIw== X-Received: by 2002:a9d:6c3:: with SMTP id 61mr1224874otx.314.1544765056702; Thu, 13 Dec 2018 21:24:16 -0800 (PST) Received: from cloudburst.twiddle.net ([187.217.227.243]) by smtp.gmail.com with ESMTPSA id r1sm1845379oti.44.2018.12.13.21.24.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 13 Dec 2018 21:24:16 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Thu, 13 Dec 2018 23:23:46 -0600 Message-Id: <20181214052410.11863-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181214052410.11863-1-richard.henderson@linaro.org> References: <20181214052410.11863-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::341 Subject: [Qemu-devel] [PATCH v2 03/27] target/arm: Add PAuth active bit to tbflags 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" There are 5 bits of state that could be added, but to save space within tbflags, add only a single enable bit. Helpers will determine the rest of the state at runtime. Reviewed-by: Peter Maydell Signed-off-by: Richard Henderson ---- v2: Fix whitespace, comment grammar. --- target/arm/cpu.h | 4 ++++ target/arm/translate.h | 2 ++ target/arm/helper.c | 19 +++++++++++++++++++ target/arm/translate-a64.c | 1 + 4 files changed, 26 insertions(+) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index cd2519d43e..898243c93e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3032,6 +3032,8 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) #define ARM_TBFLAG_SVEEXC_EL_MASK (0x3 << ARM_TBFLAG_SVEEXC_EL_SHIFT) #define ARM_TBFLAG_ZCR_LEN_SHIFT 4 #define ARM_TBFLAG_ZCR_LEN_MASK (0xf << ARM_TBFLAG_ZCR_LEN_SHIFT) +#define ARM_TBFLAG_PAUTH_ACTIVE_SHIFT 8 +#define ARM_TBFLAG_PAUTH_ACTIVE_MASK (1ull << ARM_TBFLAG_PAUTH_ACTIVE_SHIFT) /* some convenience accessor macros */ #define ARM_TBFLAG_AARCH64_STATE(F) \ @@ -3074,6 +3076,8 @@ static inline bool arm_cpu_data_is_big_endian(CPUARMState *env) (((F) & ARM_TBFLAG_SVEEXC_EL_MASK) >> ARM_TBFLAG_SVEEXC_EL_SHIFT) #define ARM_TBFLAG_ZCR_LEN(F) \ (((F) & ARM_TBFLAG_ZCR_LEN_MASK) >> ARM_TBFLAG_ZCR_LEN_SHIFT) +#define ARM_TBFLAG_PAUTH_ACTIVE(F) \ + (((F) & ARM_TBFLAG_PAUTH_ACTIVE_MASK) >> ARM_TBFLAG_PAUTH_ACTIVE_SHIFT) static inline bool bswap_code(bool sctlr_b) { diff --git a/target/arm/translate.h b/target/arm/translate.h index 1550aa8bc7..d8a8bb4e9c 100644 --- a/target/arm/translate.h +++ b/target/arm/translate.h @@ -68,6 +68,8 @@ typedef struct DisasContext { bool is_ldex; /* True if a single-step exception will be taken to the current EL */ bool ss_same_el; + /* True if v8.3-PAuth is active. */ + bool pauth_active; /* 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 644599b29d..bd0cff5c27 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12981,6 +12981,25 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags |= sve_el << ARM_TBFLAG_SVEEXC_EL_SHIFT; flags |= zcr_len << ARM_TBFLAG_ZCR_LEN_SHIFT; } + + 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. + */ + 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 |= ARM_TBFLAG_PAUTH_ACTIVE_MASK; + } + } } else { *pc = env->regs[15]; flags = (env->thumb << ARM_TBFLAG_THUMB_SHIFT) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index e1da1e4d6f..7c1cc1ce8e 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -13407,6 +13407,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->fp_excp_el = ARM_TBFLAG_FPEXC_EL(dc->base.tb->flags); dc->sve_excp_el = ARM_TBFLAG_SVEEXC_EL(dc->base.tb->flags); dc->sve_len = (ARM_TBFLAG_ZCR_LEN(dc->base.tb->flags) + 1) * 16; + dc->pauth_active = ARM_TBFLAG_PAUTH_ACTIVE(dc->base.tb->flags); dc->vec_len = 0; dc->vec_stride = 0; dc->cp_regs = arm_cpu->cp_regs;