From patchwork Fri Dec 7 10:36:08 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 153112 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp337288ljp; Fri, 7 Dec 2018 02:40:07 -0800 (PST) X-Google-Smtp-Source: AFSGD/V73oQmJZnNAuxYG/Rujrs56d78kroFu/icitozvZAFPi/8pKUtwvytug7a/6enUchT1oXm X-Received: by 2002:a37:ea0a:: with SMTP id t10mr1233366qkj.273.1544179207027; Fri, 07 Dec 2018 02:40:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544179207; cv=none; d=google.com; s=arc-20160816; b=00ndvBMhCpXiRngAtPVMpqzF3ZFzEOdjRoSwDxHfjImyU1n8mut2uhnAS58oqAQgk2 lc/WhaqCuy00vn5B7kZcBXk+MEhUH+vYYQve9MiE4mHasxHkuTrLBBRlF1BjZJooUI04 VTv1a2rqXoY6u9KZQHf00IdMi9ytvXiobVeDFs303OShmRmaAiD1cz1THWCgsKGtLcoF KwYuJDXIMb1ZrkgYnfLeQRBxBELXeOxjI4HCaU7zUW6crnHYeBBqOlRBZadS+ePqqX4/ rK9YUiVNZXFqJ7E/A/QfAO4FQ227K/3jW29Nq7PYUNeiqZdpAnR2eB2tgBxdw5phKgWe uWVw== 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=JFdWs6eYKiJMy9nZV/6pMCAE27SKK+ui75wieoQo31U=; b=MXbI6qkJbL1rP404AfHGt2eqiAUQBVfhLU62Icj2NunHOfFfqSFPJBs8rRrx8wS62e WwDgvcXdXcexEWNuC4ilXzSE3f0Xa8xpl2PqyLfNcFfduGIJU9b8iz3m9jTP9XLi7QX7 Km0ME5YErt3xkpIcCboOCnBpaDpDQYOM+4eYXZGN74hBC6rySB4CWHoLHGfntMr6BuYG YyP+1ifDFDgd6Ojw8kX7GpiVQdF9Ym5AU/MtXxZ1KjT9l5DmUElW02C+cu7bYoLoBk43 NO/kGwNhvH1W6CIrtjaU450GLYXnPIkKtWEY+8Mb2wSASUf4iWje6d8WNbNVI8h5Gns4 J9Bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=isNywPv3; 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 v19si322681qvk.110.2018.12.07.02.40.06 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 07 Dec 2018 02:40:07 -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=isNywPv3; 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]:45260 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDYE-0003gC-ED for patch@linaro.org; Fri, 07 Dec 2018 05:40:06 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59023) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gVDUx-0007y2-0a for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:36:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gVDUw-0007Em-0A for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:36:42 -0500 Received: from mail-ot1-x343.google.com ([2607:f8b0:4864:20::343]:36576) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gVDUv-0007E0-Ow for qemu-devel@nongnu.org; Fri, 07 Dec 2018 05:36:41 -0500 Received: by mail-ot1-x343.google.com with SMTP id k98so3365220otk.3 for ; Fri, 07 Dec 2018 02:36:41 -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=JFdWs6eYKiJMy9nZV/6pMCAE27SKK+ui75wieoQo31U=; b=isNywPv33US7PbuZGMdmSg9V+arzUH6Bmlj/9fFMuTEXRv3qWu7MsY3/VtYmNDeaWF 1zoLZJeU1iX+UGjUYFUqDMws61g3AMfLSZX0p2/u08mcLl9c9cSz1nJCkeSht0jOa8ZZ 0aoQ9UeHxdeRXZ5mMibUxryUhf5yRvC4xNys8= 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=JFdWs6eYKiJMy9nZV/6pMCAE27SKK+ui75wieoQo31U=; b=dOcTQXsh2zYTI3nMX7XkfRh2mPrFenAS0QMXcXx8ySNylce6BACUdmCFJngzf0sPV4 nJ1bkBL8dXw5lCe0gNIAQs7bY2LYXBxuvw+tIx7pk24FPZfBhxW50+pAbwJl3BBdY/c9 troFoPUSrVJssl+IOmb8jV9OgSscJBFHz9Pcms9r/XAnAcEBd9CqgfR1vxH/w+o+DN1+ 6qDtO9o5fwTksJHghA3qPzGa4uNVUCGw1XyUrT/CprRz5TC6nhcXHTIlTt/7C+q7cQQj 0lvg127dIVXR3kMoy/8sxRF17r7brGXAeRY4EhX+ocqICMfOw1vC5+13isMQmPySMjNe 1q9Q== X-Gm-Message-State: AA+aEWYRoLn7j9r9+Q7J1Q3OnWYiFy/K1KNZt2Vr4YdAV5lbMSAH/JS/ 0yVFDlro92ynZdTUzgI2r9Re+eRGl3g= X-Received: by 2002:a9d:620f:: with SMTP id g15mr1010638otj.296.1544179000741; Fri, 07 Dec 2018 02:36:40 -0800 (PST) Received: from cloudburst.twiddle.net (172.189-204-159.bestel.com.mx. [189.204.159.172]) by smtp.gmail.com with ESMTPSA id c19sm2037594otl.16.2018.12.07.02.36.39 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 07 Dec 2018 02:36:40 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Fri, 7 Dec 2018 04:36:08 -0600 Message-Id: <20181207103631.28193-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181207103631.28193-1-richard.henderson@linaro.org> References: <20181207103631.28193-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::343 Subject: [Qemu-devel] [PATCH 03/26] 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, ramana.radhakrishnan@arm.com 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. Signed-off-by: Richard Henderson --- 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 Reviewed-by: Peter Maydell diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 80d65866c6..f70eff8bcf 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3024,6 +3024,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) \ @@ -3066,6 +3068,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 1e20956376..158c550fab 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12991,6 +12991,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 the 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;