From patchwork Tue Aug 29 23:23:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 718269 Delivered-To: patch@linaro.org Received: by 2002:adf:d20a:0:b0:31d:da82:a3b4 with SMTP id j10csp244955wrh; Tue, 29 Aug 2023 16:30:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHIZzedbTNpCRqyo8PVARSP0KTPI3whMp1a7j3w8bpeq/nureio+abOS3hId8nd4wG3AfcS X-Received: by 2002:a25:acc3:0:b0:d7a:def7:b96a with SMTP id x3-20020a25acc3000000b00d7adef7b96amr553373ybd.53.1693351808832; Tue, 29 Aug 2023 16:30:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1693351808; cv=none; d=google.com; s=arc-20160816; b=zDzsSSZw3pFzO1DOf363y9Y/2hLQUf2VZW9M0EFkiDBacfTI5rZZ1xkL7W7mVc39pq sgJqLbdlZeqO1Gru0uKjJ0qXbScZ/j3dYJA7v3tbXQ0AXcit5GQgnkjYYoaHsEYpGoI6 g8H2SQi+q/wG+5leZXidOx+K7mgknK61sO02Rm0EH6v5WIrwTeZ+Pu3zHxPbZBM7vqgL G/ZJ40nrsaV5KfWfYQMSE4+LyI+F/3OGHIQpNC6a9aaeItq16i8N+mNqoYJfZL8jMFYi Jf3rfaxT8qNkBUZIlwfGnQytxaeGn26TxhPwbQNk4OPU3niAPVupS42g9tj7Xsx/CvdL 3VXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dSHDOqmpvVqWZn7zJjJYDufm+wpdwBxF2KdyWkAtGiQ=; fh=L6OjQZ2TPsHFQEGPRBuboSqhQBavDZ5pPqlyX67xn3A=; b=CF5VeqL1cDMQ0Xbcg0q1wIF2Jl9FspM3gqwdOhYOrNb5Z8WZhjuG/ETQ8B4u1OsaUr dXcnODUjSu9EMATvN6id880ef+kHd+pRZpn/Q8cg25eu8LPacPta1KBLrBvae8blLciC Ja2X9r0CBQTfBjdG7UaupNR5XCJyD3E51khrEFmpWh0jG2AxOK8GQfx3qOMxYYeaJvrM wOIRNS952+HO2xY52++Lu+nikO4Xvv1x0xG3l7ZZ3fRyX5WzyIU5PjOZBQbKCCX/74Vq +0S0gJcpgegSDlgyQo3bxAoZ9B3LrwnoT45Ul+H/1YYgHooRCPjfNH3Az6ABcu8X1Q/0 ZIwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=RBXDMiCA; 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=pass (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 m15-20020a05622a054f00b00410ac15cbf6si6761043qtx.456.2023.08.29.16.30.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 29 Aug 2023 16:30:08 -0700 (PDT) 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=pass header.i=@linaro.org header.s=google header.b=RBXDMiCA; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qb83r-0003vm-VX; Tue, 29 Aug 2023 19:23:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qb83p-0003fi-3t for qemu-devel@nongnu.org; Tue, 29 Aug 2023 19:23:49 -0400 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qb83k-0001N1-9A for qemu-devel@nongnu.org; Tue, 29 Aug 2023 19:23:48 -0400 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-68bed286169so4261470b3a.1 for ; Tue, 29 Aug 2023 16:23:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1693351423; x=1693956223; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dSHDOqmpvVqWZn7zJjJYDufm+wpdwBxF2KdyWkAtGiQ=; b=RBXDMiCAbVEWOh24jzMgBq9SwBVpcHnOk3/ikUpgslogFgev87rbJIm9UFqTo99h+1 xI/c5F72Riu/P1YyUly9Vzy5UkBORtDJ3bp6J8I+1yNXvA/o3NnZb4KRLeIRk/UphrbX hW8zThsIEkc6sc7aDqZutKsJqxklxuA6SYQ8JQf/arAmCVrJX+vqql911fc9ankbDXbK 8zdktD6Tu9TqgbdmreLutguBDRk3MkIRvANfuXrx0ujcr36LqqgyvvqBJXgTgqLNUnyQ Upn2d4l51zR3aGhgD3fpPanjaCVMAC6SPsIY8O9IyCGlnYZogNQVicPLVmH1E2diqFrD aUxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1693351423; x=1693956223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dSHDOqmpvVqWZn7zJjJYDufm+wpdwBxF2KdyWkAtGiQ=; b=dikAqFaou1mgclySXlrATd0xmurlIUTedLix+h0lKssUOviXfCY7NG9yL/jcSNrwJ8 XvWHvFy4J68DR9VRC2Lntew/hzLJgyEs5IZiFKpwWQaUgYVc+zHX47X3suezLpPtGJQZ 0m++OT5B7jjrIJlgzbeVxx3ZhRw4OmSAd8wi4CIW/OHDLYKiz1Bb2ab0C886qyDfudvz TxKiqtWf7ypVZc1mLa2UuxtZVGRHljH6bXadjdTfj23esjrhsmw/BeSff/K3dGoeh/dK 6sz6HujeHBcFws7ul5Y2WVSZeDtibrrq49YHyAPM8c9xXJ+QfPWkg23sNzW+E65iwX8g Ejkg== X-Gm-Message-State: AOJu0YwBbuegMJuLqfC0Hvxru5+pqab9xClPw4FOVJMXplhpP11vfn7I Gjd0+hZp/7ds5L2h1KfkIsVnXggCIdWcXPEbGq8= X-Received: by 2002:a05:6a20:4c84:b0:148:d5d9:aaa9 with SMTP id fq4-20020a056a204c8400b00148d5d9aaa9mr554519pzb.33.1693351422849; Tue, 29 Aug 2023 16:23:42 -0700 (PDT) Received: from stoup.. ([71.212.131.115]) by smtp.gmail.com with ESMTPSA id t9-20020a170902e84900b001b9dadf8bd2sm9829970plg.190.2023.08.29.16.23.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Aug 2023 16:23:42 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Cc: aaron@os.amperecomputing.com, qemu-arm@nongnu.org, Peter Maydell Subject: [PATCH v5 06/12] target/arm: Implement FEAT_EPAC Date: Tue, 29 Aug 2023 16:23:29 -0700 Message-Id: <20230829232335.965414-7-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230829232335.965414-1-richard.henderson@linaro.org> References: <20230829232335.965414-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::42c; envelope-from=richard.henderson@linaro.org; helo=mail-pf1-x42c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Aaron Lindsay Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson Message-Id: <20230609172324.982888-5-aaron@os.amperecomputing.com> Signed-off-by: Richard Henderson --- docs/system/arm/emulation.rst | 1 + target/arm/tcg/cpu64.c | 2 +- target/arm/tcg/pauth_helper.c | 16 +++++++++++----- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/docs/system/arm/emulation.rst b/docs/system/arm/emulation.rst index 06af20d10f..4866a73ca0 100644 --- a/docs/system/arm/emulation.rst +++ b/docs/system/arm/emulation.rst @@ -27,6 +27,7 @@ the following architecture extensions: - FEAT_DotProd (Advanced SIMD dot product instructions) - FEAT_DoubleFault (Double Fault Extension) - FEAT_E0PD (Preventing EL0 access to halves of address maps) +- FEAT_EPAC (Enhanced pointer authentication) - FEAT_ETS (Enhanced Translation Synchronization) - FEAT_EVT (Enhanced Virtualization Traps) - FEAT_FCMA (Floating-point complex number instructions) diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index fec6a4875d..85bf94ee40 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -758,7 +758,7 @@ void aarch64_max_tcg_initfn(Object *obj) t = cpu->isar.id_aa64isar1; t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ - t = FIELD_DP64(t, ID_AA64ISAR1, APA, PauthFeat_1); + t = FIELD_DP64(t, ID_AA64ISAR1, APA, PauthFeat_EPAC); t = FIELD_DP64(t, ID_AA64ISAR1, API, 1); t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index bb03409ee5..63e1009ea7 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -326,8 +326,10 @@ static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data) { + ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false); + ARMPauthFeature pauth_feature = cpu_isar_feature(pauth_feature, cpu); uint64_t pac, ext_ptr, ext, test; int bot_bit, top_bit; @@ -351,11 +353,15 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, */ test = sextract64(ptr, bot_bit, top_bit - bot_bit); if (test != 0 && test != -1) { - /* - * Note that our top_bit is one greater than the pseudocode's - * version, hence "- 2" here. - */ - pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); + if (pauth_feature == PauthFeat_EPAC) { + pac = 0; + } else { + /* + * Note that our top_bit is one greater than the pseudocode's + * version, hence "- 2" here. + */ + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); + } } /*