From patchwork Tue Jan 8 22:31:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 155012 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp33296jaa; Tue, 8 Jan 2019 14:35:16 -0800 (PST) X-Google-Smtp-Source: ALg8bN73fWnIiwqnK6fkg3F/h3UgV5WnqGFQ79SgEst9qQyoHHVJCnqpSghfBRLwbhH7TBjHP4eC X-Received: by 2002:a1c:81ca:: with SMTP id c193mr3364356wmd.66.1546986916353; Tue, 08 Jan 2019 14:35:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546986916; cv=none; d=google.com; s=arc-20160816; b=zAVewBMO+fT7PH5hYdwh2C1yB9YIdJoPWuez4f38PDc5CE33e8NFAeX5owNjjoeKsS g4gh++wGrUjcuqrDZBu2fkOiVlgGszuyJpDs7FC9nhUqKlnyd1t2wwgfp/o0ypLfaVJF YdjzWaqZ35z9xUogEq+OmGkdj026lG1+SBNVG2oSIkB3XaEsFai+223uwqAt8MQo2Dmd b8zwPk0J2R56YdWzNIT5SmUa7TV2mZnoEDD5LdykPUf/Lj6wt0ASnc8cq8j9ARBFCSIU mJjZH3dXNotZgEMWJmCN0c+RJx+Kz+SqX4fgEAKQTCMPAB7wSB5b2fwEBKfPOtagoxW4 nKPg== 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=sbd4WM6pLVZ+wZDxANSyv9ApfZdYcZeOcA2TgJcvPjg=; b=YAtTbsSMaXXISbwTQ04+Dk3C/aVOUvT6bkBSAxm20ggqgponiLqVa81UsUXbu/uSNP yvNFy9D19BNrHz3jGwo7c38LCC9FyTeCfqY6GhJSFJ9PCohiiDeSqgLop6bTeUI1U/Um XNvhIFQHrG5k/SXX81Zcb3qs8MTHdLm3d1S8HG0h8se+faggUYFbN4s64cwId0K8q8Qo z/YvBU87NAow1sDt9TlBJjw2zxT834FLgCbxJLkKGIJLfDOag9xjeJ62hSZQ/DAGC7hu RGX4TGVYDlv6mdkpUSQYX5RA7RVkIDD+yW8psmqc3HRJkPPEQRZ4gie3GWLR5P6QVXV5 okXQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=J0OMeA5L; 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 c7si39352997wrh.256.2019.01.08.14.35.16 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 08 Jan 2019 14:35:16 -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=J0OMeA5L; 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]:40385 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzxr-0002ft-8k for patch@linaro.org; Tue, 08 Jan 2019 17:35:15 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ggzuU-0007z1-8G for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ggzuT-0004CS-AG for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:46 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:44474) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ggzuT-0004Bs-4Y for qemu-devel@nongnu.org; Tue, 08 Jan 2019 17:31:45 -0500 Received: by mail-pl1-x642.google.com with SMTP id e11so2558029plt.11 for ; Tue, 08 Jan 2019 14:31:45 -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=sbd4WM6pLVZ+wZDxANSyv9ApfZdYcZeOcA2TgJcvPjg=; b=J0OMeA5LLB9RwCaRyMEPf7mbefxtfXw3XLZXFtGjRtJUTHIJkwZLqwra2eApIjbm/S x6npo1iQIKV5nSc34GKx5RMpzBnHgBtgaiUzgE8BV2ENH8BSMvRgBIM5Zr8elhfH7+aQ KYj6XmIVkHW+LDpVzzUkOH45Xf1Vi06QMZhlw= 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=sbd4WM6pLVZ+wZDxANSyv9ApfZdYcZeOcA2TgJcvPjg=; b=EaWyc1sCYY5X2/Iocq5CZXzlhaciKdVJcwPg2HLNk7/gDKFWv9WKOg8zmBZZTKhsJ6 Wmrkjo8cFC/rKGmv3YjDI9L104xqnhR/kt0V87CRPJHbr4yXvpBNKKU4pRwTyhMiaBEH T79YuxN7hQlwUU6iD4H8GGZajXrBE3ReHAhC4EX60ehJ6RvLMC0y432g/IQ+VGfltlqF 439ENJOsh2QBjq+0vZ+NV6x07cEQkBRoupoo2boK3VsL32QuCz8M1TbANcCEZn0A6o55 F248NBshHVu2+WWm8OnW43dbAJoB0WyITtnBHmjHFPRhy4oV/iJZRyr1XfvF3V739Emz g+AA== X-Gm-Message-State: AJcUukft7s3UPyGZTFCzHRlO7Yd/BKnTIc8Hpfa8u7oe+CPJsYwYY6Qk elvPx4uM2TeYZWBXJ/Yu8ZjdmwUkQmU= X-Received: by 2002:a17:902:b68d:: with SMTP id c13mr3593080pls.102.1546986703719; Tue, 08 Jan 2019 14:31:43 -0800 (PST) Received: from cloudburst.lan (2001-44b8-2176-c800-8cc6-2630-7d99-5ef1.static.ipv6.internode.on.net. [2001:44b8:2176:c800:8cc6:2630:7d99:5ef1]) by smtp.gmail.com with ESMTPSA id w128sm100686177pfw.79.2019.01.08.14.31.41 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 08 Jan 2019 14:31:43 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Wed, 9 Jan 2019 08:31:01 +1000 Message-Id: <20190108223129.5570-4-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190108223129.5570-1-richard.henderson@linaro.org> References: <20190108223129.5570-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::642 Subject: [Qemu-devel] [PATCH v3 03/31] 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. v3: Rebase on FIELD definition. --- target/arm/cpu.h | 1 + target/arm/translate.h | 2 ++ target/arm/helper.c | 19 +++++++++++++++++++ target/arm/translate-a64.c | 1 + 4 files changed, 23 insertions(+) -- 2.17.2 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 843d5936ea..9ad7b2d11e 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3014,6 +3014,7 @@ FIELD(TBFLAG_A64, TBI0, 0, 1) FIELD(TBFLAG_A64, TBI1, 1, 1) FIELD(TBFLAG_A64, SVEEXC_EL, 2, 2) FIELD(TBFLAG_A64, ZCR_LEN, 4, 4) +FIELD(TBFLAG_A64, PAUTH_ACTIVE, 8, 1) 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 f00c141ef9..f23555b1dc 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -12983,6 +12983,25 @@ void cpu_get_tb_cpu_state(CPUARMState *env, target_ulong *pc, flags = FIELD_DP32(flags, TBFLAG_A64, SVEEXC_EL, sve_el); flags = FIELD_DP32(flags, TBFLAG_A64, ZCR_LEN, zcr_len); } + + 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 = FIELD_DP32(flags, TBFLAG_A64, PAUTH_ACTIVE, 1); + } + } } 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 b7b6ab6371..37a57af715 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -13409,6 +13409,7 @@ static void aarch64_tr_init_disas_context(DisasContextBase *dcbase, dc->fp_excp_el = FIELD_EX32(tb_flags, TBFLAG_ANY, FPEXC_EL); 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->vec_len = 0; dc->vec_stride = 0; dc->cp_regs = arm_cpu->cp_regs;