From patchwork Wed Feb 22 19:35:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149531 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 40E08C64EC7 for ; Wed, 22 Feb 2023 19:37:08 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuub-0007Oy-QV; Wed, 22 Feb 2023 14:36:21 -0500 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 1pUuuZ-0007LN-29; Wed, 22 Feb 2023 14:36:19 -0500 Received: from mail-bn8nam04on20721.outbound.protection.outlook.com ([2a01:111:f400:7e8d::721] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuX-0005XO-EG; Wed, 22 Feb 2023 14:36:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BYQTCVUxacn+TBiN0zOqojmIhf5MQ+bcOLaTRWulxt1iPW5Eht+vttEwdLCogjqz5NTDBG/5OCuxhsuaiePiZwsvA3c4kF5ggMGUXWpISmE6KMvfo3ziJIfBmUHi2htRo4PsR7viBu01akMjibf2Lr3fgfhPiUN70q2/gk4bdpETdTEbjGTu1K1xbH28LAa6u3V10Vh2KcnhPqioDKPalC4WWthQWLyQLERW2v99IZi+XWQ5stlCQNIHnWO4JcL2VU+sHNI0l9BTdX2QvsqOC94gwbUvcoutzJrXZ50Spz49FtGQza+OJkV3Uks2G80BNE9WM4SAtN8D9omr8i8dUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=BNl2m2yxSmcW/NtX5w1OuBKkkjtYq5GNQWvhXBddzNs=; b=GOykHSng6TbBC0XrH25iZov29LzhSu1mejVJ4PTNqCGVWmBdcDUl0vlSPn8QPQIKffM2ZtUYGbY9IswyTStYpcVYv0sdN6VWfTi62NMMRvgxERry6P8OhlgBA7dBq4WRVMxbF7cuHNd5yRgasYDl1Fgq93sRcpGxS0Fu5GijTRgzEHlnrf/tjiSx6Racz6nIMJbMCN3ynoBInEILrkIRhs+DiTHZjW5yG42IDVJ+kwRdmx7DeyoTtcCvJBHC0UgwafSclBU99RnX6Gruo+VuuJ4l6oIkrOFkIBPxh8+1M7jsjBeBqZTsWGDgmjmvmi6RP8+1S3fFy4TkUPf6iTToDg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=BNl2m2yxSmcW/NtX5w1OuBKkkjtYq5GNQWvhXBddzNs=; b=P55z7f44o7ho57pG0LVwiL/H2sXTIMZfiiFi8vsoNSHg4S1tsM6gG308+1dUn9e/FlLHVSBc7AUqG2ZIUbZypN60upibxZG9r+8XEAtpe6bArIIYF07ZMzK6BMTr8b/0+TtJx1w1YmDrrQdEjWql5ueMWfhwDkWMPVEiN0ah25U= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ0PR01MB6448.prod.exchangelabs.com (2603:10b6:a03:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:06 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:06 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 1/7] target/arm: v8.3 PAC ID_AA64ISAR[12] feature-detection Date: Wed, 22 Feb 2023 14:35:38 -0500 Message-Id: <20230222193544.3392713-2-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ0PR01MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: da977e2f-915f-4925-a6bf-08db150c0a55 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +56BWbiyODXBG4a08ogYBQK0AGBP3v2UyTooa96Ayrud8Ol7rv3GqC8IRYt3u4dytyUOzD/c5UKSn80xHMV81FiW2pVepG2qS0yyfx8Ag4mPS4uGbhNJBUlkkEh7Nk358eNknt0Rb/UV3ddHckf6HuAEvpCjFpWlFURbV8qhsOAUvsHI+679m7eDT5GgsNph/GphbIOyNR/ASXoo3TNAFaJ4w+HVDbKNckWy1qmWX/OB+BWtY4HVtFmctG+3rcTP3pJ50EPWdoIRM2vBC/P3bocrb8jX4z5vNylIWWyJxtuiFbP7VZwcPQQwuVrxddjlB2ydChM36YVSNTeDNNp6tGHkl7Ogh0su2FarlFEOcuZD9WX4b8sRiLJJaLub8EnSRbInS0Xk5P9N4cFM6udpFlxLCZsbFbgpaK+U26MYOKuXlw0VguAh10K/3t6lvPyxHOROkIbwDrd1V0I8MgOg1HEx7EjDY5KILNOxQpECzjEXAlMcQEeGJF6hHbGES6iA9RIPW2drhGsru+HOy8NdKDPb42SP9o++Hhuifc7D1WoF2ZYRUpuyyPQp9Of6Nf8KPuIdoQWKSccW/jZ33axAu6Q0JFHxXsSqMzoKz6m7YxChc/2CWypofeezGa5Wq45bu5NUvZTVYuTFXU6CHh8Lz5QPONaCOfsxteSaV/4YF+Q13pQzgg4Txv6+gb6qQlGHma7O28ZwieUfnju7BVwkPw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(39850400004)(396003)(366004)(346002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(316002)(4326008)(41300700001)(86362001)(107886003)(2616005)(83380400001)(26005)(38350700002)(6506007)(6486002)(186003)(6512007)(1076003)(6666004)(52116002)(110136005)(2906002)(38100700002)(478600001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7zG3Bvt+g1ESr5iRma8/LwBUuH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GDmPrLQaET4riRTC+Y8ndWzDu6de42twmyBxINqPmuxCXUCUk0RmEBP7Z+Os3OW0laLWhiG1HFwze447/PTzKuvHYjzjOypUl6jgJf6v/thzEOjxWhRgERqKtkSPY8xsg2EyUHkYeDdZhWFoy/AdHtVFSA2V+7XSl4QkOi62/B15Pvx2zAL2j1/CPV4vX2dadzEMFUhcXe4x/YglaIRVfYZqr18GtqL2Ed+Q1Lsb9gnvUi6b8XqOO6s6QMSBgJAE94v5leX8kpl5NFq8EjZr4OmO0ooTxuq3qNAcPdqi9QICDtwPZqDSBveyZiaTOlmhPI7llaIRvgMTnhRH9qiLvnK6+wa8aHIO7M7/3/BhXwAngKQwoln+6rbSb6vibP4550tSxLF5wvvM3pVRu5CWLituxU1r6StTdif3km2Bex3xnXo9k/KRUssaqbKBr5ufH66xGhvDO/i/BykF+1t+7Xr3mdfaJ4TngcTSawjIGG8NEVp5wPvdGcDotQmoIsl+88NpUdX/Hw= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: da977e2f-915f-4925-a6bf-08db150c0a55 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:06.1795 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3XV4oCv4QbHiGuq3oARCQVHRfrkED+r63Y8PHeDpPBMgSPjjaVo+g3SOwoPsk69dpGjqeiwMTj+FFN8RlR0c3/BXx7nHF8C57r7Xp+lJ/pkl6WR5clNl4pcxfeBu+emE X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6448 Received-SPF: pass client-ip=2a01:111:f400:7e8d::721; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay --- target/arm/cpu.h | 61 +++++++++++++++++++++++++++++++++++++-- target/arm/helper.c | 4 +-- target/arm/pauth_helper.c | 2 +- 3 files changed, 61 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8cf70693be..9c3cbc9a29 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1001,6 +1001,7 @@ struct ArchCPU { uint32_t dbgdevid1; uint64_t id_aa64isar0; uint64_t id_aa64isar1; + uint64_t id_aa64isar2; uint64_t id_aa64pfr0; uint64_t id_aa64pfr1; uint64_t id_aa64mmfr0; @@ -3902,18 +3903,72 @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) (FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) | FIELD_DP64(0, ID_AA64ISAR1, API, 0xf) | FIELD_DP64(0, ID_AA64ISAR1, GPA, 0xf) | - FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; + FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0 || + (id->id_aa64isar2 & + (FIELD_DP64(0, ID_AA64ISAR2, APA3, 0xf) | + FIELD_DP64(0, ID_AA64ISAR2, GPA3, 0xf))) != 0; } -static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +static inline bool isar_feature_aa64_pauth_arch_qarma5(const ARMISARegisters *id) { /* - * Return true if pauth is enabled with the architected QARMA algorithm. + * Return true if pauth is enabled with the architected QARMA5 algorithm. * QEMU will always set APA+GPA to the same value. */ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0; } +static inline bool isar_feature_aa64_pauth_arch_qarma3(const ARMISARegisters *id) +{ + /* + * Return true if pauth is enabled with the architected QARMA3 algorithm. + * QEMU will always set APA3+GPA3 to the same value. + */ + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; +} + +static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +{ + return isar_feature_aa64_pauth_arch_qarma5(id) || + isar_feature_aa64_pauth_arch_qarma3(id); +} + +static inline uint8_t isar_feature_pauth_get_features(const ARMISARegisters *id) +{ + if (isar_feature_aa64_pauth_arch_qarma5(id)) + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA); + else if (isar_feature_aa64_pauth_arch_qarma3(id)) + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3); + else + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API); +} + +static inline bool isar_feature_aa64_pauth_epac(const ARMISARegisters *id) +{ + /* + * Note that unlike most AArch64 features, EPAC is treated (in the ARM + * psedocode, at least) as not being implemented by larger values of this + * field. Our usage of '>=' rather than '==' here causes our implementation + * of PAC logic to diverge slightly from ARM pseudocode. + */ + return isar_feature_pauth_get_features(id) >= 0b0010; +} + +static inline bool isar_feature_aa64_pauth2(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0011; +} + +static inline bool isar_feature_aa64_fpac(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0100; +} + +static inline bool isar_feature_aa64_fpac_combine(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0101; +} + static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; diff --git a/target/arm/helper.c b/target/arm/helper.c index 72b37b7cf1..448ebf8301 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8028,11 +8028,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, .resetvalue = cpu->isar.id_aa64isar1 }, - { .name = "ID_AA64ISAR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_AA64ISAR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = 0 }, + .resetvalue = cpu->isar.id_aa64isar2 }, { .name = "ID_AA64ISAR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index d0483bf051..e5206453f6 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -282,7 +282,7 @@ static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier, static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, uint64_t modifier, ARMPACKey key) { - if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) { + if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { return pauth_computepac_architected(data, modifier, key); } else { return pauth_computepac_impdef(data, modifier, key); From patchwork Wed Feb 22 19:35:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149535 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3A528C61DA4 for ; Wed, 22 Feb 2023 19:38:05 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuuc-0007PY-W5; Wed, 22 Feb 2023 14:36:23 -0500 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 1pUuub-0007Oq-G3; Wed, 22 Feb 2023 14:36:21 -0500 Received: from mail-bn8nam04on20721.outbound.protection.outlook.com ([2a01:111:f400:7e8d::721] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuZ-0005XO-LO; Wed, 22 Feb 2023 14:36:21 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IDA+ZRiZbPfSAH5zsFoMhUqKQccapVIu1DXdszCn0Xs01Eixn9w7/Kj84K60lQtZRnUiZM23wmAOAWV2DZtddVjELPfguYxBrq4zrfpvOKB+KmqXtwmoEeQ65VkC8mzfl5v9aZLZPkxVa85sG18Fr1CNoUAJMWC6s3pUi9+8nv8wNabpCFV7WTm0W6TojxIg59ejMyjt10Nqn86D7abXoEsK7c82MjkMBB3qPKDkwcOzhqe5ZdpLMGd/o6W8MQbezZTwvz3xCAk74ANX5pfC6IQi0HEFD/RYntJYawfYYeqls3VsInv7kzlJofgauam/kOA1eMvqtbYy/qNvd4/Qsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rwDe/e0V4VQ7659mZIwBnxZ/MuFgJYvSiJkZ8YgWnNk=; b=T4H6Cjy3krcGqOqwD7Jv8cGjuHSLLj3L1nFPhfhBaiDxvCiVnJS6ivNyAPxqHRgsg05zzmRb56cwpqFWEwfPWjPyl/FQA/ZMMn9tUi4+H0imlTjRJ7ND9nXZezW+5Nfzv3cHPAORuSbqzYgBeaksi8jrkONEZTpvpasXK2VBJ2a61vScepfvxEH9bwu/Xp+rhk7/B1k42uG8DSZIhj/i0gfK0LicOGPRvRHsosBytHbTi9UHPxaQuPZzFPH80g2h0+VrXM76TAxLC7l1r+o2ZnCF/yd8L4K2zMCFTlE1E6y5lEhI+Sh/BtinjgSRoF6N082UG6TlkoK/0kTccLUEZA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rwDe/e0V4VQ7659mZIwBnxZ/MuFgJYvSiJkZ8YgWnNk=; b=mR7AduYiLKpzkPmlm2l+24KDCj51o7/wQx7mYVIOOqPsSa5/powBZ/GYy0+pxwEMBI3NHPk6FiZFkEFKvZ+KkII/tC4YNiW7LVKB8GynYmU8RgrFbZR5hbEei+IoxkFZguxwvO0xc7MtxGaqyyZq/WIcnfEY5AnLFqGF5oLtn60= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ0PR01MB6448.prod.exchangelabs.com (2603:10b6:a03:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:06 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:06 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 2/7] target/arm: Implement v8.3 QARMA3 PAC cipher Date: Wed, 22 Feb 2023 14:35:39 -0500 Message-Id: <20230222193544.3392713-3-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ0PR01MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: e0fd3f94-6466-4e1d-0012-08db150c0ab5 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: msIe3WvS1ZuzDW2Aqw1bOkm5PKDKZusRvey5NrIhC9Z/Tn6cHSwjrn+RwnZ8gmkWM6eCteaRlmUIdFwNtvmhed8aFtFBb1GZcRX+DKJCvNejs/0WMMAJUcYw3wOg7bFU/+gxjbhU0BP5TohwpAX4hX3+hTlTC05alclmRu/0z14JVHT7CzgGkCxg0/+t0SYkJv1e1HNp5eu5mQzYgNnVr3FB7otilo43yx0viSAI3Eq09GZANOQG5Usn10/dnGrZBanLS1degoOOev6w3UFkif8Wmc17m+5HJ8TjRouAJ/GNqBhV9uQFceJM1UQtUigl1dbuNo3OUlnTYbMVF8ow4NvRiOrvVMHtFyhgRhUZomuQ/o7oAb4kwe5hk7ewQgHNMXQhIa/a4JMXL0IyKYQkr2BmjE3AA5knle2QpSuJRA71VC9Z/BSW1nQ41iCm3sRHQER1snokmZeT2t9B1X7Z5dC78h4GcacWfVIzA8AXdlU6PvVr+6tU2vC08JLOjX6hrFmHhZs0CFsmtJ6VCtChHP8c+UZxCg5hrOPzyQ5AxY29f1rTKtrZVnEDwFSastQ9sMPZVGpQ/uk1ra/A7oFb3W/2YbdB7/mbx+33iMnTZ8R+bhZKcnjs54N1q/9YIqPuuKeqX+RQX7ONzOxvPuT7qATflcpJE0QJnXiZuB/QAWAj4uRsCUwJXm+h/NGTwEvhCbZiZqsFGZWswbY4NJ2BOQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(39850400004)(396003)(366004)(346002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(316002)(4326008)(41300700001)(86362001)(107886003)(2616005)(83380400001)(26005)(38350700002)(6506007)(6486002)(186003)(6512007)(1076003)(6666004)(52116002)(110136005)(2906002)(38100700002)(478600001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QV7GKT/aBNSS4ha9PcxLHBSmSNts6PvmLMxZOSzd/beZVmk+5Je6/vssCGvFOtY+VayS4x3IpVNCsLfC9oSvogKL5lS7imwcQG1XoNBqhlqj87QG5S0Hy49RHiyJgm2XYtuEEXDOnLvWcXIJNng6vtg83FP32+kUJLo0juHsmZ7YOV6lNZowZIM+mo9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LrPzK7arz7zt7s0ezDAoeJilU90Zv770iyxGNHaiG3oK7/A3GeNI5y/RU2+bHh6wEFph1ItAuRtd0fP471k+F9dKtd1ZE2SrNgB3MCB5fHRYi2RpW+4jGSTI61fkLVffhl/YVllJGo0/tIlXK7LTY9glG2qUglREhCdvPIvW9xgcCg0JYGB/JxrK3GqSFga4Aam5MK5oIawCvqDIaZ5HFnw/cBf6UavNXgDYBtqM90azNVfN1Ze2QoPtPLqU/swO4OsMpzgB+S225b9yj1tHVkU0QXCsH/bdOXt/AZMaH9mAWOgbaa+Pp6pf7saD2gfx33nSE/wY2Af/XBU1Ssil9/XCikeCcgmi5oegcSS9UnXAKqMCqUGHYVU= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e0fd3f94-6466-4e1d-0012-08db150c0ab5 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:06.8200 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wLHujsw85GoYGwZcApt8Fr+7Nb1Gr/PeGczH3pvU4b2qwsbImfMatoExytekpCCIGCBB6hRHvLp2UTwk341T0f8hORfxt9xHYv/arlrMJ8ykoOAaiatKHpt9J0qlA41C X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6448 Received-SPF: pass client-ip=2a01:111:f400:7e8d::721; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/pauth_helper.c | 50 +++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 10 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index e5206453f6..f525ef7fad 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -96,6 +96,21 @@ static uint64_t pac_sub(uint64_t i) return o; } +static uint64_t pac_sub1(uint64_t i) +{ + static const uint8_t sub1[16] = { + 0xa, 0xd, 0xe, 0x6, 0xf, 0x7, 0x3, 0x5, + 0x9, 0x8, 0x0, 0xc, 0xb, 0x1, 0x2, 0x4, + }; + uint64_t o = 0; + int b; + + for (b = 0; b < 64; b += 4) { + o |= (uint64_t)sub1[(i >> b) & 0xf] << b; + } + return o; +} + static uint64_t pac_inv_sub(uint64_t i) { static const uint8_t inv_sub[16] = { @@ -209,7 +224,7 @@ static uint64_t tweak_inv_shuffle(uint64_t i) } static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, - ARMPACKey key) + ARMPACKey key, bool isqarma3) { static const uint64_t RC[5] = { 0x0000000000000000ull, @@ -219,6 +234,7 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, 0x452821E638D01377ull, }; const uint64_t alpha = 0xC0AC29B7C97C50DDull; + int iterations = isqarma3 ? 2 : 4; /* * Note that in the ARM pseudocode, key0 contains bits <127:64> * and key1 contains bits <63:0> of the 128-bit key. @@ -231,7 +247,7 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, runningmod = modifier; workingval = data ^ key0; - for (i = 0; i <= 4; ++i) { + for (i = 0; i <= iterations; ++i) { roundkey = key1 ^ runningmod; workingval ^= roundkey; workingval ^= RC[i]; @@ -239,32 +255,44 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); } - workingval = pac_sub(workingval); + if (isqarma3) + workingval = pac_sub1(workingval); + else + workingval = pac_sub(workingval); runningmod = tweak_shuffle(runningmod); } roundkey = modk0 ^ runningmod; workingval ^= roundkey; workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); - workingval = pac_sub(workingval); + if (isqarma3) + workingval = pac_sub1(workingval); + else + workingval = pac_sub(workingval); workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); workingval ^= key1; workingval = pac_cell_inv_shuffle(workingval); - workingval = pac_inv_sub(workingval); + if (isqarma3) + workingval = pac_sub1(workingval); + else + workingval = pac_inv_sub(workingval); workingval = pac_mult(workingval); workingval = pac_cell_inv_shuffle(workingval); workingval ^= key0; workingval ^= runningmod; - for (i = 0; i <= 4; ++i) { - workingval = pac_inv_sub(workingval); - if (i < 4) { + for (i = 0; i <= iterations; ++i) { + if (isqarma3) + workingval = pac_sub1(workingval); + else + workingval = pac_inv_sub(workingval); + if (i < iterations) { workingval = pac_mult(workingval); workingval = pac_cell_inv_shuffle(workingval); } runningmod = tweak_inv_shuffle(runningmod); roundkey = key1 ^ runningmod; - workingval ^= RC[4 - i]; + workingval ^= RC[iterations - i]; workingval ^= roundkey; workingval ^= alpha; } @@ -283,7 +311,9 @@ static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, uint64_t modifier, ARMPACKey key) { if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { - return pauth_computepac_architected(data, modifier, key); + return pauth_computepac_architected(data, modifier, key, false); + } else if (cpu_isar_feature(aa64_pauth_arch_qarma3, env_archcpu(env))) { + return pauth_computepac_architected(data, modifier, key, true); } else { return pauth_computepac_impdef(data, modifier, key); } From patchwork Wed Feb 22 19:35:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149530 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E9D81C636D6 for ; Wed, 22 Feb 2023 19:37:07 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuuW-0007Iz-AF; Wed, 22 Feb 2023 14:36:16 -0500 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 1pUuuU-0007Hr-KS; Wed, 22 Feb 2023 14:36:14 -0500 Received: from mail-bn8nam04on20721.outbound.protection.outlook.com ([2a01:111:f400:7e8d::721] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuT-0005XO-1H; Wed, 22 Feb 2023 14:36:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=a9X1U0geQyXFMUlMxOEEbPRNxZpOow+3UtuvAstKfP94jxblEz8QoH0xXq09TfwRFwkocASpOe1ujFp/WxEYGxoRV+zvzyDzE+q0z5Eol2XOaZPw8Yk41xC0F7R+2M9/YUmYLEfqe7RlXAmMgR7v49GBYZL6Q6qFhpJXd7q/9PI08WJqS+vrvVebcaO/T0y3w1D3pH04c5Z+4mk6UlCXHS+eDMNf+sjslUXhedodegg1uHhW2yPoS1e2CB4zvJBMYb83dCz07bwRY6NACitVzAWyS7MQWhs+9Wevp3i9V9Ly46H0PBhfrXc/aFRF2NfF8Dgis9t8+tb/SFuh3Xnq8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=7Us8yGBQQo2+X7GcbXo32ObTU+IRgTK5fx26SfEsyVE=; b=oO+Eli+D25GqXL3aA4KDlv3gqHOJBVtqon339xU4wLjSTHerj5EzVNd+mqmMg4lqEEscylit6vCobPN8GM7zUNUTNBVOMOzSxlPuwCn+R1hVALnkHsEOHU8tmnRo2tYqzzOcbunU5A3kMYWL98wEtKkjq7ZHYVz8Gyv9JihV3cq1XHbKPLho0Qbddd7/Sjx/l6boiusmPDeruKo41M0SYasxFRYS3IHc6O99hEM5zpO+BZ1p2NfYXZ/fPr/HTlJFiWNcJWJSQ4UoeulXKpXUty5uE5zm6YDZo2yd64um5VKeRfO1iZRpMq2T/vmm4RUrwNb/rXiYi8jYOkxWjdL/ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=7Us8yGBQQo2+X7GcbXo32ObTU+IRgTK5fx26SfEsyVE=; b=RX5SWzGoONSQRGZCcn/j/4NFU133LMVee3sfl1hMnI60JlUQkZfA8Nt6kEMi3WDLyhOdLbq0MyebuTP9F0w9kwroX8LkulW6/1VKpeEQZJ7562tEco7TD15hGXPX8Tldj0LGhbr3r49AoH6TV/w2cdpGk2+WPuzmsKR5+aPcx28= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ0PR01MB6448.prod.exchangelabs.com (2603:10b6:a03:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:07 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:07 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 3/7] target/arm: Implement v8.3 EnhancedPAC Date: Wed, 22 Feb 2023 14:35:40 -0500 Message-Id: <20230222193544.3392713-4-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ0PR01MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: 099aca07-15c0-47d6-44bb-08db150c0b20 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /o3ODln4r+nwouZQTHJPemu/3ERanqmo7/No8PrVqmZRVlm9OMZUEswvF5hc5QMimq5eE6pIW8fRbXd4pHz+DhceFradImnaZ8pfWE1J98IZxZK0fqFzyFj4Hkhn0a32B41k9F4nq4gCvX2zWBHV4bH0GGkRDNBQBw77ifLMzIpmnQSAv3kglyNOxRBK6L+7f+Grdjf1oQxodvSmxmv1eSgVV17jbu0qB1S4Udy3z7T6GcnLAhVhtIkUJinkkdnxBTGz7Q3f3hNDhVMmF2DA7pKUDk7QpCo0kUH8C+qBhVsL4UD3QEKjpm7ItDZCu2tnV6PGXyxvGo0FrIALWgtmKfR7/DR87UDDUVb7py21/GcFR+cAtCFgM2GEi2QjsWEw1aoN1yJSgF1cre22WmU4o4BWUO0Uew2F7K23SaeSDQPs2wyg3IuPLGxhi8ULI8synKy6N+odyMsBGkxZcxggCsQamOZtfupjv6QqWkjU+3vKcx2lgQYdjUdSqoxzWYNE5OsVCQP1y0XY1i0xpBOWbJ+5OgBm/ZLCBmoGVDcNLJ+IADsGy3kc1MlYB5b6Avuo6uuZtzxgaTSyN6ApqGJ9OgAHkv5YF6ELZzNYcH0fejiw16sBokoQxZi+Hwn+IFEu/VuRdM40xhiwWfaPqwi7KsG1ciAL6eEIF/znhmHKA08g+CSUUouLSGNP0Sy4IEavyD+dhKKwTdYEivVtZspTHA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(39850400004)(396003)(366004)(346002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(316002)(4326008)(41300700001)(86362001)(107886003)(2616005)(83380400001)(26005)(38350700002)(6506007)(6486002)(186003)(6512007)(1076003)(6666004)(52116002)(110136005)(2906002)(38100700002)(4744005)(478600001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-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Zar6eS7VWxvFULvhahvUkgFC5pINIbB3FiePZNjbM7By9SHVsK1kvLfFZRkTssycdycNtzNACzR+QtmhoJcyN7eNGlEMYioE2mkbThlG9XD3FZLv2Y4P9BCEjaWDJqL9rqjTk8JAtyYvD+/Eila/CHBDzdT0+h8f0Tmobi5mkoO2X72QzoRvLYMMnOR9SXTNvW6aiQ5F8Pdm6k+kCfrnHbbEDMyZMGS3/oc0jUJZfsKdGJZ7Hx+j0PluLt2nbZM5kPDSxryd7qaEWtw7pvhdijoupmP2Kq3yEX3TgLkSFONIi2N5tUvvbd33qn6apsjEVqlk2gNWV7B+KzJ+y0ujUhSGWFOVRT/bJ5OdsXs+7wW8aGoVxcQmTQZN/YmO5HwiA5NqS97uboPS6sZc5jxDHCR9k2KEp+0vntvpoQIFCMTuRa49hes5WNL2f4ObFIY1G+vg+TKzVuB1E1Vi18kU95IrnnY+Ys0rcGra+li2sIG3PGhmjdwDznS69fFoeOcylyjK1gQ0fXxenrL9ePvT3XQmLPFeV37w3kZq2vCXvBXvcjJPXz+UiK+LsImT/PNKPgy4KZFCLE6k5XyeeDXeVqI1Ws0I= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 099aca07-15c0-47d6-44bb-08db150c0b20 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:07.5074 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: fG7zziWmw1VJXdmplpZG1J/lmE5jxVVV+0cAoo9xLiP48dLIocwbFkDNZ3t3tLrW76fiSRi5KsscmazAjsUhSPvKM2JS7JAxOqWnR+B+n3yj8DuEunT+ERvNSkZhN5dX X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6448 Received-SPF: pass client-ip=2a01:111:f400:7e8d::721; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/pauth_helper.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index f525ef7fad..a83956652f 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -347,11 +347,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 (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { + 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); + } } /* From patchwork Wed Feb 22 19:35:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149529 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 66F13C636D6 for ; Wed, 22 Feb 2023 19:36:46 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuuW-0007J2-Ab; Wed, 22 Feb 2023 14:36:16 -0500 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 1pUuuU-0007HV-8T; Wed, 22 Feb 2023 14:36:14 -0500 Received: from mail-dm6nam11on2071e.outbound.protection.outlook.com ([2a01:111:f400:7eaa::71e] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuS-0005XN-5S; Wed, 22 Feb 2023 14:36:14 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jKXHCNSs1koRxOG1FAqiAAg9Kdan2XlQYE7LRl6VgplCy5JptAfQvvm08X1QQhymDLZpLBvRO5DukXhN6WuhWHZhcMC2PyhU15gk53Xdv8L+BYTayhfF+w02YVtYQFYWLjjBYFiULIpLfiLbY0oCuzpaSAeK0EVttPrOHhcsOdbPN8mqSV9OjvQaCm2ZaxvvqVeAHgel5wRiT7Y5g9ouL0ZaAkgoqaVQdDzRKTEHJy2/8GuPK4281e4dz6esuRRrIXgIqxkwBol8wMRKyAKvXJZ1T5DPstldcHyUSe1T9ZbO4GCUjmYZ+yV+0bzKESENKZcYDrS5wtsBfOau8BlT/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VWBVNPCkegKSNV2fM0LBfJwOxfxCLzKu2b4eQ4z0jVs=; b=oRn/dYxjG9y5le0wQ9Zl9ut54TGQ+6tQlZM+O5E7O0iFAkPssdUraEA54mo6JD/MajaGU1bdm1PNGCN4JdtDsVNES4tSk75T2pkxFz+fp4Y9J4rbrBJphrf7GCxh//66byiURl7YzRaFe45apZARabRpBwcVVz/vn/kL1fCLwHrvCKrgfcclWBpqSKRXSY/GwtBrCA75QvJCf/xp9nDsyBYqIJ/ZEaSl+FyeQoGXrLOIBiWQ2e9pIq9LekwEUo/ifvDD8SrCVmd4qMkbIArZ/rf3xLUAe42gZQdrrgFVmFB1yhNbSIOJe1VC9O++5+TRdTPmUQmFa2g7/C0FdmCW+g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VWBVNPCkegKSNV2fM0LBfJwOxfxCLzKu2b4eQ4z0jVs=; b=CKq2/HymDWlKDUIuw3Wg8BY0kzW46fP7IqbaUAfUpBarkuj2y2Qady+Mmq5zKCZ/+RDloT2GMktY8+kqgfiOJYsajv1Q7EcRaOJB6L+8ef/kNM4MMZSx68AUSZLEyTJgCu5xlKUx92O4HGFqicWzFieWYYIy08zFl1QR6hZlXxY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by DM6PR01MB3849.prod.exchangelabs.com (2603:10b6:5:91::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:08 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:08 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 4/7] target/arm: Implement v8.3 Pauth2 Date: Wed, 22 Feb 2023 14:35:41 -0500 Message-Id: <20230222193544.3392713-5-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|DM6PR01MB3849:EE_ X-MS-Office365-Filtering-Correlation-Id: 085f6f5b-2524-4c84-7c57-08db150c0b7f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: AE84fRWQAhzmrdRruOMZSf6zIINMwv4kMgPUoM861Hw9yX83y91rq+Kfftc6l3Qx3+JBsgps+4gjPGBBWZtkCMenxqdFehgmN/3RhPn2wRKIhC4PBXMkLo9cpwXsvoH4xcS2fpnM1DdCKt6aPD6tbgswir7wLL9OV/W0kk04UFM7/Tjs0NW0gRgPXjhxg6G3CO5aUjFqHrc6/526PlMfx/39W/UW+ElJcQmei5KwxdtINfSKDGoGx0QC2y5jEZ1u0JdYIpRY5ztXjTWvL/3v+V7L0IJUs1U9x6aXk+/sUJQTvx5rNysk6vl7L0FEbeJu+v9GFDBqRLU7guhvfvlPdaI2sp+z1iSoc7ty+xDIpjl2TUPHsbYPi29R7D7VcJ0q6KmTXbFwghF5vjVbxgk8+Kt2c1bE1B92E1F7CUXRZLCZIX/SLxKYYzWg0AmQPu+eFdlZpZfWKPUF0PuF45Ulu2lCR2S4c4CZYIQH3AcWgbJoOTmlMtW+y3RBn7DYIYMZLLzLyOi6yDh55SWUaTFTGwxMPF3L7nP14+J4xJy0EQhcNo75pzC6iL6pw9OW8KE02k+E10r2TFLjtHjoe+sEzRXjkaE0eJnQl+YvNoGcAUHzw+SrXNfkMH8DKhXWCbl1cLExyEsnLIEqinthbaMk4YxQU+VcWX4bqB05+cKqSYd6yr1VoHe1jwKmTdATmQ/m18O7nfOVMwgYaBoTpaKzLA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(366004)(136003)(346002)(39850400004)(396003)(376002)(451199018)(478600001)(26005)(6486002)(1076003)(107886003)(6512007)(6666004)(6506007)(110136005)(41300700001)(86362001)(66946007)(4326008)(66556008)(66476007)(8676002)(38350700002)(52116002)(316002)(2616005)(8936002)(38100700002)(5660300002)(2906002)(83380400001)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: QT07olbXNkYTO++E/G1SfyrY7bQTJExMKpjoK5VlARRE8JRY2v5R7bjSr/UxErCbTt/JvNAFhn4qq/CWde8sLaYlMUxvX5AYE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gkpsY31+qWgVhVOchILWJBE6RcOOOyu7zP6+YAwwB1on2VBcXYYTjQJkU/HucX1V4/47GdjSEAv9ncoRHtoe9RkDxOf7mv8nSNF0xm8WVEWhiLwrN5xtPKLSlNYtPGIxFjcOHAQCfErhyQG/UcvXAZlPTZuQmcvZjOUvQpnoOYE150qk4YQhMurMxS5tIs581L4b1xrpjHiWcb7q20ENe9ApB5Vc13rspznIb1u/Bg/oGlqkCSB7vj+5J9P6kNXAkmWftZMD1DZmwDcIermvtpgZ8PTd5ehTvhq4RhC4wdz+vw/ZfCJdr256FuAfL/3npJ+dk7a6Wu5t/D0ffo8wXcormt9QmK9km75Fm8DkwKyEfb6xZgMhWnuMScYzPvD5dJcKbnCKfBODxUm4C1TNK9YZfOqaUPvuCkjo3ljxXtbP3Yy6NuA2Ij4AgGqDA3kVVtmqCgsKpWHce3S5BJRJJIK+vo= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 085f6f5b-2524-4c84-7c57-08db150c0b7f X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:08.1314 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ijVVQvakhusVPeQ3I8+ZFK4/ZiTz55Qd71vcnxLWlcAIun+a9j7j+VyOmbZFVK+WccmMGIoHdEcYfn5Y/sHBmJ4WfpiuhuFvyDdb/JUlaLQaKv27yWsyBiJUNWJbcrY7 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB3849 Received-SPF: pass client-ip=2a01:111:f400:7eaa::71e; envelope-from=aaron@os.amperecomputing.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/pauth_helper.c | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index a83956652f..c4ee040da7 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -347,7 +347,9 @@ 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) { - if (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { + if (cpu_isar_feature(aa64_pauth2, env_archcpu(env))) { + /* No action required */ + } else if (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { pac = 0; } else { /* @@ -362,6 +364,9 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, * Preserve the determination between upper and lower at bit 55, * and insert pointer authentication code. */ + if (cpu_isar_feature(aa64_pauth2, env_archcpu(env))) { + pac ^= ptr; + } if (param.tbi) { ptr &= ~MAKE_64BIT_MASK(bot_bit, 55 - bot_bit + 1); pac &= MAKE_64BIT_MASK(bot_bit, 54 - bot_bit + 1); @@ -389,23 +394,30 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); int bot_bit, top_bit; - uint64_t pac, orig_ptr, test; + uint64_t pac, orig_ptr, test, result; orig_ptr = pauth_original_ptr(ptr, param); pac = pauth_computepac(env, orig_ptr, modifier, *key); bot_bit = 64 - param.tsz; top_bit = 64 - 8 * param.tbi; - test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); - if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { - int error_code = (keynumber << 1) | (keynumber ^ 1); - if (param.tbi) { - return deposit64(orig_ptr, 53, 2, error_code); - } else { - return deposit64(orig_ptr, 61, 2, error_code); + if (cpu_isar_feature(aa64_pauth2, env_archcpu(env))) { + uint64_t xor_mask = MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit + 1) & + ~MAKE_64BIT_MASK(55, 1); + result = ((ptr ^ pac) & xor_mask) | (ptr & ~xor_mask); + } else { + test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); + if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { + int error_code = (keynumber << 1) | (keynumber ^ 1); + if (param.tbi) { + return deposit64(orig_ptr, 53, 2, error_code); + } else { + return deposit64(orig_ptr, 61, 2, error_code); + } } + result = orig_ptr; } - return orig_ptr; + return result; } static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) From patchwork Wed Feb 22 19:35:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149532 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5D106C636D6 for ; Wed, 22 Feb 2023 19:37:24 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuuY-0007KV-DM; Wed, 22 Feb 2023 14:36:18 -0500 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 1pUuuW-0007JF-MA; Wed, 22 Feb 2023 14:36:16 -0500 Received: from mail-dm6nam11on2071e.outbound.protection.outlook.com ([2a01:111:f400:7eaa::71e] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuU-0005XN-Q8; Wed, 22 Feb 2023 14:36:16 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fjGM/8mrXuhjdvxQ1v2nWnTswJsHVhEx4hsEGNSv0KIL3uVKTxWdE6RVq+zXiRJfcCBkDJ26PZ1nX2oAfoN9Uc+9Kf4Ho5gVBe83BJK7SbqKQTxIguE3+3GZ1xxoklvlmK1GtKoJbMw+vFDOAmShnEnj8YsU4N/2S6pFgzclTF0Jmfdn1R8gs/TLymwiP5IukAV5l2G+do/eyNIhSPK+aUeeE5P1bL6vbTdtA79WHKukUVCTVPHynEsGI0DIxq3nANSvRlM8NRo/VFo3b5f1S2r/Kh8GalHj+BdXOrNl96jaBdlTCLP7rRlExn9Rhxx/ipHCN2jDaS8oz95VoKu5/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=Pjmb5fEjzlI6lM4BE4tVMiXhgYmDukyGzS79tyk9r4k=; b=jv6+ik2FQSZ7+lz03yHy4ACzdrTtWZUZWEFRTRTrnZDTgtrXZHv1bQETRfVyic3mQ15kkKuEhGpjQ0qkf707ABYbFkkkhoq6hWUn47QvRPCjeNWVwPsjkAwjHxzEnOh9SybsFTy4kRUT1QxTNcY3+O1YYmR8Kn+HuJISRTZk9+x5TnIGYKhUbbz8UJ+mib1xIWvUaciTIIMW42wqxFJB3YFGL2rbi1Vq7Tbd1k+Bfv3X+zYPjBIzQLrilrjluexeNxkl+AJp0dPnzqeUzkh5FV/foRsbn8Vm3ilRIjJOfAfpeN88YG50N3wBzHgFehzevTMnXVzZ4rMFnF0bKILvIQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Pjmb5fEjzlI6lM4BE4tVMiXhgYmDukyGzS79tyk9r4k=; b=n5lwrHCbZqf/5vDghZCb0yUR2kvXlgYcscQydgk3p1sLruCKN+JivWs5ZUH+jl692oiQoaPEta3wHKEJ+w8076QJjEWqEBzzX8mRzBbFn6mBlPtCLptJP4Ep2+Mea3Bte+706aA6Cp9FGIsVrR94lcLtiURplBWevQg/QQBF8N4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by DM6PR01MB3849.prod.exchangelabs.com (2603:10b6:5:91::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:09 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:09 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 5/7] targer/arm: Inform helpers whether a PAC instruction is 'combined' Date: Wed, 22 Feb 2023 14:35:42 -0500 Message-Id: <20230222193544.3392713-6-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|DM6PR01MB3849:EE_ X-MS-Office365-Filtering-Correlation-Id: 9e635e40-d600-4280-9756-08db150c0c02 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: r5FywRgJKJXCDqma0EelD8OWzoWNNKLxGkgyQ8T4jHcpjRBXvy8MaZ0bD4JIT4+ygslUT24YiooRwlE+W8JGuQUhyQL3FYQrvYOnUknBxe+iCrkIFB08NJ5PlCK4Md+RMI0o6S5UDCAzKFR5XjYRUabHaUYnoPKJbMg+1xQ/9nqXXX5eBCNtJUQ74YO0G0Eugfhg36HooklVC5dut4kw5hQT1jlClsX6GeWsnS8KqQJAo+X5kZH0+q7TvJ1iLiW68FImXW6PAhcmLyucFQ7d7Dm5PqiRrDIDHispFiLpyPdMes/YbNzqGFffkYoA4LlxieP28uWO1Ig3ViD9fqlEd1GJZ+hplM35P5lMRTv0sTSNZHFBGOVA3qDjT8toMbzm25x28aNFWLcwpkOpib5o5Dn22NxNFUk00AfqKs6sec464UUnt5xgra5hb1IEvQwFD+aXa2ItOQ62b1ALl6APisdJDXHD609cPe47CPCPWMILmYQKPs/83CN2qRO+Yl6FE8Gvf3U9sCrWCdp4AoIoP57YuAj2Sb5FM9VkUB45kxkYWxNP5omg6VUbY6R94w+uornrdIQ0+BzseQeQmLnNscdYACS5pOwOX2pEEl6DLfMKZRcyRJXMF46n2BfQ6UOCXHgq5YuDX32kV1ypsGecm4u8Y8QYO15gXy12oi4Mk4Y3jXwFseVNuBH+f1aRiqYFIOohBwQgzZeMqD5R5ty1Wg== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(366004)(136003)(346002)(39850400004)(396003)(376002)(451199018)(478600001)(26005)(6486002)(1076003)(107886003)(6512007)(6666004)(6506007)(110136005)(41300700001)(86362001)(66946007)(4326008)(66556008)(66476007)(8676002)(38350700002)(52116002)(316002)(2616005)(8936002)(38100700002)(5660300002)(2906002)(83380400001)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: gE0Kvz5xkJztOdtHAwDN/FkQrMZHbc39uuwHoapgWP9oON9hpNJhpoUigZNM7pJrEaNQ5a093zwXK2rpRO8/oVYq3rDrCmjtwEds991BAM1AxcFcJprsFIXykvYWCdEAZGvLN+kybLT99inydv7PuUrwLDLyuWaP80A9sPEtNJNOcPkP+vDsvF3nT61tjpdWs3Eh2+NINYYq70Smogkvm9TLBgcPNTzqGVkP2O9w1ZQV1kaArGYOGx+QgV5xCTrKt4ZgdDSh+w/dH6WK1OL96+e/rHYcVHa0V0y1Bmnk2tGhS+rrmHkuiKMG+lp4u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lBN2YPpKwE55jYqf/g/Z5UFHjijXYPbCuAu79RxPHj0rKaPtpjbhUH8ZIDq1WGjdpFWIALVDoypUHjSPRb6ILoPj/PzmW12yHlkyy2FQkkpgoospnQDMZ2H8nCrG3e35Jtf0qpEJeM4Px99euNkU1WsQR9ij5uKRvCDKQ8ALbQ2t1k9FCAZHMB8jEJoOK6ncoA+wVWChkB4yt1aTrozfg+Fj5YHDDZ1G998nkbMA0Ceg6L885VhjxpoDI= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9e635e40-d600-4280-9756-08db150c0c02 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:08.9906 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: oWd7KykfnSaSv3mJocPZaZGf1di53l0+PHegvrfn03UhA2nI1LONiSzb3fIn5pwxO/dn9I9K+CjMuP8B40piP9i0IpOntYCCGB6Nvub2Is6P6MS9lCG/+aGg4CxnjDMs X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB3849 Received-SPF: pass client-ip=2a01:111:f400:7eaa::71e; envelope-from=aaron@os.amperecomputing.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org An instruction is a 'combined' Pointer Authentication instruction if it does something in addition to PAC - for instance, branching to or loading an address from the authenticated pointer. Knowing whether a PAC operation is 'combined' is needed to implement the FPACCOMBINE feature for ARMv8.3. Signed-off-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/helper-a64.h | 4 +++ target/arm/pauth_helper.c | 71 +++++++++++++++++++++++++++++++------- target/arm/translate-a64.c | 20 +++++------ 3 files changed, 72 insertions(+), 23 deletions(-) diff --git a/target/arm/helper-a64.h b/target/arm/helper-a64.h index 7b706571bb..829aaf4919 100644 --- a/target/arm/helper-a64.h +++ b/target/arm/helper-a64.h @@ -98,9 +98,13 @@ DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autia_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autib_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autda_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autdb_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index c4ee040da7..96770d7860 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -389,7 +389,8 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) } static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, - ARMPACKey *key, bool data, int keynumber) + ARMPACKey *key, bool data, int keynumber, + bool is_combined) { ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); @@ -510,44 +511,88 @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y) return pac & 0xffffffff00000000ull; } -uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) +static uint64_t pauth_autia(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnIA)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apia, false, 0); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apia, false, 0, is_combined); } -uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autia(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autia_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autia(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autib(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnIB)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apib, false, 1); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apib, false, 1, is_combined); } -uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autib(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autib_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autib(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autda(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnDA)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apda, true, 0); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apda, true, 0, is_combined); } -uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autda(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autda_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autda(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autdb(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnDB)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apdb, true, 1); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apdb, true, 1, is_combined); +} + +uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autdb(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autdb_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autdb(env, x, y, GETPC(), true); } uint64_t HELPER(xpaci)(CPUARMState *env, uint64_t a) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 52b1b8a1f0..37cccfda8a 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2318,9 +2318,9 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) if (s->pauth_active) { dst = new_tmp_a64(s); if (op3 == 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autia_combined(dst, cpu_env, cpu_reg(s, rn), modifier); } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autib_combined(dst, cpu_env, cpu_reg(s, rn), modifier); } } else { dst = cpu_reg(s, rn); @@ -2356,9 +2356,9 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) dst = new_tmp_a64(s); modifier = cpu_reg_sp(s, op4); if (op3 == 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autia_combined(dst, cpu_env, cpu_reg(s, rn), modifier); } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autib_combined(dst, cpu_env, cpu_reg(s, rn), modifier); } } else { dst = cpu_reg(s, rn); @@ -2404,9 +2404,9 @@ static void disas_uncond_b_reg(DisasContext *s, uint32_t insn) if (s->pauth_active) { modifier = cpu_X[31]; if (op3 == 2) { - gen_helper_autia(dst, cpu_env, dst, modifier); + gen_helper_autia_combined(dst, cpu_env, dst, modifier); } else { - gen_helper_autib(dst, cpu_env, dst, modifier); + gen_helper_autib_combined(dst, cpu_env, dst, modifier); } } break; @@ -3583,11 +3583,11 @@ static void disas_ldst_pac(DisasContext *s, uint32_t insn, if (s->pauth_active) { if (use_key_a) { - gen_helper_autda(dirty_addr, cpu_env, dirty_addr, - new_tmp_a64_zero(s)); + gen_helper_autda_combined(dirty_addr, cpu_env, dirty_addr, + new_tmp_a64_zero(s)); } else { - gen_helper_autdb(dirty_addr, cpu_env, dirty_addr, - new_tmp_a64_zero(s)); + gen_helper_autdb_combined(dirty_addr, cpu_env, dirty_addr, + new_tmp_a64_zero(s)); } } From patchwork Wed Feb 22 19:35:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149534 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EE945C636D6 for ; Wed, 22 Feb 2023 19:38:03 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuuf-0007R5-LM; Wed, 22 Feb 2023 14:36:25 -0500 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 1pUuud-0007Q6-QW; Wed, 22 Feb 2023 14:36:23 -0500 Received: from mail-bn8nam04on20721.outbound.protection.outlook.com ([2a01:111:f400:7e8d::721] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuc-0005XO-6c; Wed, 22 Feb 2023 14:36:23 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SMW1dK6uDoqVpKvsvFpLCvkVku3vxiQWo3RzkBUnkbKlRGln5DLSbvYL/MJEx6xG9AACAFh1syTp6jtx0wOhATG1SDR7WCBra2HGAuxEOGuqFlXOCvHQJmJu17doTeBySB0MorOh16OYBlH+RwfLv/OHcDDbHTC93pHngec41Q1myDx6IXTWHn1skhN8qdKDUoXJ1Jtvuh2mtN9CbAYplZyR8Rm5kICOl+giZO3PJ6RTMIs7xsXLEkfXqNAQXV5sExrHcGar3JvzYRjogzXtHnwjE59uyZ0VR1LnZP+gSgH8SajXf+Q2X+x0+5aSsDGXJOvBYZXP16nIMAuDow92Tg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=AI2C+02B7L9lyjRGa3KRtuInRWFeItdSqTpS87SbqS8=; b=AEFR6ru6iUleFBjkxE/HwInDnGOScA6sSIRJeDPi4H6hF4llJcm+rtzQ/mqJjogGyrAwJH2iH9UpUbMc5RFIZxOWDrR1iD+rqsFE6kYlV5u/PPyW+vo+VUyrs0OufVyteG5sMNsA+TRl6cE/TwPzqbGhQ7Xox/2bMhGpYrdJRg/D5Yh55qJ7WcKlDlml+dLnD4SV2ylrT3xPi08RPlimQrzM55w4UjqAdPxH7r/qtkqy3I5ZL48jdM8Zw5Dp6GGg0ZTPOZNbbOmOHl6Qq10qhnA2NaXGPFxiIaGs38e6eVang8g/5jYdcEnMvTKgLCiTcm5pYLkweWo7eTzWBEVFVw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=AI2C+02B7L9lyjRGa3KRtuInRWFeItdSqTpS87SbqS8=; b=Xhhm0V5iv49vdk7cOz3ng+6uPF1s/kNbE1bVZWp5tVg6Cn+neONugomCnK/7fHyy4Ww24+2VndsQOyW1l+wJ29EWHN593dthDdsAJ/Y6N1v1Tx13t/UpcxlWizrv0lycMKTmItouz+jQa6/mlKyfSEKD2Lt//EuFTnb64eExeYw= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ0PR01MB6448.prod.exchangelabs.com (2603:10b6:a03:29a::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:09 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:09 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 6/7] target/arm: Implement v8.3 FPAC and FPACCOMBINE Date: Wed, 22 Feb 2023 14:35:43 -0500 Message-Id: <20230222193544.3392713-7-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ0PR01MB6448:EE_ X-MS-Office365-Filtering-Correlation-Id: 9b4b548f-5035-42d0-1788-08db150c0c69 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZwjOwBsCU7X8HWQe+tri/M8mOSuR7gu90LeLGlHxKEzPWmaWPGVrlEzhR9gLS+UA3vgTMtbwh0p3cAhNE1LVCJwoA8H7GZaYXrhZUTKZOAFlVl4ZLNdbaU+N+A2XG8gOYixO99VZdpPIJ9johH+XKRnklJlqzyqlUFGV+r6WU2p6Ai+ZSMhFxJDk9tAphB0oZ8wKzC067a/CQY4DtcTnbZvpHSaHAftqZwVOXF0VjsYIIxhogcl2zzfTfEAOipEa6TVUbIhOMMWbqvPNXN+Hved4+fDBhHbNNdhlkyEEiA0x5xvsJyNWKM2E5etBnuMuOFcaHennUM8AlPBASqbuAwooBP9zCeW6OqheEl7hGlJaJzu4hg/ufd/LJmm3Szm9bhhCLhTxJjf0hwvvgOxsZ2JFyjiN6Zi4wTBsz16u/KM8duRmGkTLzdQYbLouT0kgz0DiZj/urMEAJWopAhsM+ht8JeF/Pf1ZzaZwdYXz49frPnfndJfBTpJhfWK2QQL6s67f5gIKQfO14rgAQfP2Rz0bTH8n8Zc6nmgcRx6Ot95O6k9/lfnuJ1Kes2ETkmjPCTHsIXrqgssGHmq0uFOaEIuV90KHMFYjT/R6ExKIqM56jY9fzaV9CLTFzerJ7FdJ5FTOrejUdit+Bv6FzYIJ/FRdlKPCS1+IlJSoUatCV0zEPH4NADYeHk2tAf2EcskRpM4GLvco7MgMGdlJRqaVMw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(376002)(136003)(39850400004)(396003)(366004)(346002)(451199018)(8676002)(66556008)(66946007)(66476007)(5660300002)(316002)(4326008)(41300700001)(86362001)(107886003)(2616005)(83380400001)(26005)(38350700002)(6506007)(6486002)(186003)(6512007)(1076003)(6666004)(52116002)(110136005)(2906002)(38100700002)(478600001)(8936002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 3Brh0UFQVcOgMEZIXpn/D1jPE5VYauO9+Vdh6ll4f0D7cSUc3Ie1OEaQuFsV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Fv7bDbUojX9PtL/HU/4KcqSGbHG7LHsTieXdIw0cLkLRAkY94BEUBZcZgg1aokBKC9K7A1+hfTQ4ZwMStnEAT6TrFETpFFRtsyLjLmm6irk/NkEy3ORSUeoQYXNgw8apnR2kcM88quAblyHFnQO7oY+4uIQp09pFGixg21FHTFpHoFUG2HAJ6iUkVVGyrvPlzlgK7FhlClPvFCPL+/ZqQ9Sf/q4TwR9DjCOaV328eZEnIfMCYHPW4TKylNpNjvAM8BqsGS2IYLarkKGDw9FDkZgMCHbPhst2NfaaO4aRlQIWkdltr8g70/dU6/XgrPA8LEUS4eBQaAzwIxcXr01rfBfbqaAtxf11+/S5YHpUZrwYGIcIt1QguztF6Bwc5Y7arcjoedrLnsnCqHyJWplWi7YkT0SclVld6CiQsXzBQzZoEiRTOXuw7bpcAfZjVVCHflDuEvxysljljlSwie4QOWY+en9WpboN64khRXf9Vw4cmQIsza7iFRRV1tk= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b4b548f-5035-42d0-1788-08db150c0c69 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:09.6780 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: j82LnVcuJtNjNf2QxWsjFY/OIAkTJzbCY/jJDfzhGXgqhQY1mw7RL454xB5QR4WLrmoby3QiWagP2qYo2lOPAQS4BSXWNxgGIH5/3aSfCoyrkX1vlG8fDJN71MQZXvh3 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ0PR01MB6448 Received-SPF: pass client-ip=2a01:111:f400:7e8d::721; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay --- target/arm/pauth_helper.c | 35 ++++++++++++++++++++++++++++++----- target/arm/syndrome.h | 7 +++++++ 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index 96770d7860..db6cf9b5bc 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -388,9 +388,24 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) return deposit64(ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield); } +static G_NORETURN +void pauth_fail_exception(CPUARMState *env, bool data, int keynumber, uintptr_t ra) +{ + int target_el = arm_current_el(env); + if (target_el == 0) { + uint64_t hcr = arm_hcr_el2_eff(env); + if (arm_is_el2_enabled(env) && (hcr & HCR_TGE)) + target_el = 2; + else + target_el = 1; + } + + raise_exception_ra(env, EXCP_UDEF, syn_pacfail(data, keynumber), target_el, ra); +} + static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data, int keynumber, - bool is_combined) + uintptr_t ra, bool is_combined) { ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data); @@ -406,6 +421,16 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, uint64_t xor_mask = MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit + 1) & ~MAKE_64BIT_MASK(55, 1); result = ((ptr ^ pac) & xor_mask) | (ptr & ~xor_mask); + if (cpu_isar_feature(aa64_fpac_combine, env_archcpu(env)) || + (cpu_isar_feature(aa64_fpac, env_archcpu(env)) && + !is_combined)) { + int fpac_top = param.tbi ? 55 : 64; + uint64_t fpac_mask = MAKE_64BIT_MASK(bot_bit, fpac_top - bot_bit); + test = (result ^ sextract64(result, 55, 1)) & fpac_mask; + if (unlikely(test)) { + pauth_fail_exception(env, data, keynumber, ra); + } + } } else { test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { @@ -519,7 +544,7 @@ static uint64_t pauth_autia(CPUARMState *env, uint64_t x, uint64_t y, return x; } pauth_check_trap(env, el, ra); - return pauth_auth(env, x, y, &env->keys.apia, false, 0, is_combined); + return pauth_auth(env, x, y, &env->keys.apia, false, 0, ra, is_combined); } uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) @@ -540,7 +565,7 @@ static uint64_t pauth_autib(CPUARMState *env, uint64_t x, uint64_t y, return x; } pauth_check_trap(env, el, ra); - return pauth_auth(env, x, y, &env->keys.apib, false, 1, is_combined); + return pauth_auth(env, x, y, &env->keys.apib, false, 1, ra, is_combined); } uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) @@ -561,7 +586,7 @@ static uint64_t pauth_autda(CPUARMState *env, uint64_t x, uint64_t y, return x; } pauth_check_trap(env, el, ra); - return pauth_auth(env, x, y, &env->keys.apda, true, 0, is_combined); + return pauth_auth(env, x, y, &env->keys.apda, true, 0, ra, is_combined); } uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) @@ -582,7 +607,7 @@ static uint64_t pauth_autdb(CPUARMState *env, uint64_t x, uint64_t y, return x; } pauth_check_trap(env, el, ra); - return pauth_auth(env, x, y, &env->keys.apdb, true, 1, is_combined); + return pauth_auth(env, x, y, &env->keys.apdb, true, 1, ra, is_combined); } uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index 73df5e3793..99ed4c7d3d 100644 --- a/target/arm/syndrome.h +++ b/target/arm/syndrome.h @@ -48,6 +48,7 @@ enum arm_exception_class { EC_AA64_SMC = 0x17, EC_SYSTEMREGISTERTRAP = 0x18, EC_SVEACCESSTRAP = 0x19, + EC_PACFAIL = 0x1c, EC_SMETRAP = 0x1d, EC_INSNABORT = 0x20, EC_INSNABORT_SAME_EL = 0x21, @@ -221,6 +222,12 @@ static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) | (is_16bit ? 0 : ARM_EL_IL) | etype; } +static inline uint32_t syn_pacfail(bool data, int keynumber) +{ + int error_code = ((data ? 1 : 0) << 1) | (keynumber); + return (EC_PACFAIL << ARM_EL_EC_SHIFT) | ARM_EL_IL | error_code; +} + static inline uint32_t syn_pactrap(void) { return EC_PACTRAP << ARM_EL_EC_SHIFT; From patchwork Wed Feb 22 19:35:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13149536 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 48729C636D6 for ; Wed, 22 Feb 2023 19:38:16 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pUuua-0007N2-2f; Wed, 22 Feb 2023 14:36:20 -0500 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 1pUuuY-0007LE-Qk; Wed, 22 Feb 2023 14:36:18 -0500 Received: from mail-dm6nam11on2071e.outbound.protection.outlook.com ([2a01:111:f400:7eaa::71e] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pUuuX-0005XN-3b; Wed, 22 Feb 2023 14:36:18 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fbuIQqXuamP5rCP4zXwAebLGEIsgZqD2G2xEYmFMHiisTlmABxHcM2Gt/LRFbEYHvPQTSU4LJf2/Fhj8cYM08z7ftL9WtWxqma3FNtxsFC8T8aI4U2r8BLDWg6XLhZtzjDSqY8DrTPFAm/N0HyzmJuvKcIggCA7mEWqypgjDqOulLIZNndXkSn+MQECvuYNwkIeGLZLFi/vrrFYKnpZRkIVehcdPDfS86ih0XJf+/05lMIgXT5989GxHxLQz3mxoa63IqeKLv40jcCEPn5YFTkXTeUwxZo9Nhs0dUbteE3k8VYpAkZxnW9B9zs/3cViKXFP0AL1PjPrTsUajd0BrpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=gAOk9vmIjZ83UBazKFcEE/mWCqaD1NH0VPSwJErQwR0=; b=cAQ6f2Uwx7mKBUXZbSrwdoqlTC39nmsaXuHzTE1AYb33aYtY6cl4mciXHVwJDuFqT9HJ+T5/5HKaDn3fVOnt2UdOssXozswrIkqSrhB90yVLsyfKsrx7qIlalM38BF7I2I/arH7s/NPfOJZzJWUJ/wmYmfV5A8Zsyx4yE/2XdEDlbkPsP7Sb1wh/pNeyLpBiTo18Q1UP96pIUH3IIW+IPkNOGybmk+M/0ck+eK536+ifjrdFJYP3+uC5L93zHeVZvecsx15Zy12p5NVJ3fdnPzzh0SI1npIymE53jXWHD0XHoTvIaotjBU91gOURw+27cvvB7lAg6zaSlnXE1XlTvQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gAOk9vmIjZ83UBazKFcEE/mWCqaD1NH0VPSwJErQwR0=; b=s9ZEe3qGTHvF5g7mw/KI/Tkgg+BMIlr6cGsjNAIOs6mz2MOEc8Xee6Yqb1HFgQh4ogxb3tDCpvRWlw4Dy9j95OXUgJGpAG7KdqoQieDXA8tltOE/9qZiPxEjMjKwJ02vJhClVlusXkdDVsru79LgQEAOYUHnAuhJJrLv2P7o+vY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by DM6PR01MB3849.prod.exchangelabs.com (2603:10b6:5:91::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6111.20; Wed, 22 Feb 2023 19:36:10 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%9]) with mapi id 15.20.6134.019; Wed, 22 Feb 2023 19:36:10 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v2 7/7] target/arm: Add CPU properties for most v8.3 PAC features Date: Wed, 22 Feb 2023 14:35:44 -0500 Message-Id: <20230222193544.3392713-8-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230222193544.3392713-1-aaron@os.amperecomputing.com> References: <20230222193544.3392713-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR08CA0016.namprd08.prod.outlook.com (2603:10b6:610:5a::26) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|DM6PR01MB3849:EE_ X-MS-Office365-Filtering-Correlation-Id: c69a887e-80a4-4fef-ae68-08db150c0cc8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YfV43tqgiwtYkMwK/JxjyEGfnIBEAZlmMxEhOEWXB172YClSGe78pwxPj0Mf9o8gci3jbKonzTl29SA4rwy2lvk3FI7O3OfuvYwdtOKkSgimEtJ2M/kbHgiR4XGqFpkAVaiStUUKCJlSgzh0XsSvs0UFvNZBxTso4uJuKlo799k0G3z3qO3Gfs7p1919ohT+dNspyDboP6VQ0QPsqjDBAnEAT5Am+NaQogp5Y3P4Fy2CF9Bwd5QVOiALYPtUgzeoAh+R6cx22AOFZZyIVdki/z8cvf+9s9rJpS0tBjyL52jjmlnj5Px+lNEEPoqUrPIjvDeqVycIREjBTBXSM3hmXM6WR19qJZ3ScVgcvbK/fdy5FDb/lq3j/amVTACDmHBPaNp57+rp8Lz1TXR0IrD8qqiHn3Ti95XU6XXWECz+wqs17a77GKkmDHioNAaAs2rwtU5g1TSnd1ITibx6LZhV4I5iW/mSvOGA2E5S+1GC9NeHzjFc/4WGs1UNjZqo2gSUMZ2+RLHvMCP6mZxb4Y8ImLGLsOuOLFx10nutokx802tQoo8LLuj/6/VIpUdPO8BuQWhtfusfqTduJsxPqY/wgh3Ofce7jxXLkmEWANL+opF74DCR36h3btOC6VrpGzuqoa2x1IbwYTsf9S6LuMrztK7M6XRdStUgIc1ibwZddOTWl4/XkVfNaRuKtGfqb5foKc6mkfJyzsyWxsnT6G/86Q== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:CH0PR01MB7124.prod.exchangelabs.com; PTR:; CAT:NONE; SFS:(13230025)(4636009)(366004)(136003)(346002)(39850400004)(396003)(376002)(451199018)(478600001)(26005)(6486002)(1076003)(107886003)(6512007)(6666004)(6506007)(110136005)(41300700001)(86362001)(66946007)(4326008)(66556008)(66476007)(8676002)(38350700002)(52116002)(316002)(2616005)(8936002)(38100700002)(5660300002)(2906002)(83380400001)(186003); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: r9mqetenoY0tV7+tA8MDDtvm9a0zDwkDn3NBPO0tF54vYNnkSOF/GPobfVQIac2FWnTcwIuvauhDcsEuMKkQDfuPbPliyNkv4khX10lyma2DUhpXxNI9T1unNEl9fPSVKbJ0PI1WsRdh1GLzp3YYJiBZJUsQInzzdCDInog6k5keIYhgsNtd56nzaHpUJVQa5GRTTZ4cQByXEbaldskM/dEYQS7rbPTKuwIr1KA+CKx8L3gSNcWttSct/1RmN2S/JcB3eIQxYjMGkkd15WOXs0N//O7DkPxOLuPGrC8VrRvpJiV/eRfUw5UQyXeHBbkry55lZo8zfcl5BbvZK6Dm50htgDKQicgACAVtQMu/w2b26bAWC5IY8YH3NINdqSgiOV8EQ2pCycY1EngO/RcNnoh610UCSnZLeralCKQXBAPwJ00Pw7trOmSKx63Zj0gBOPEZd6Vg7LTiV48+pN+E9XDrwKOKdTEIefcXDJi5xaZQDfctSI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0OdVk/JW41J3OYOdH4x5CYUBkNfqYtQUbUS1EjeJNoUQ/iPIj5XrLjTLNG3SOlWM58= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: c69a887e-80a4-4fef-ae68-08db150c0cc8 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Feb 2023 19:36:10.3201 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: /isZvKBXPWaUKfab6GheyqF1j+nUtVyWxw7Cq9wTD5cGTixKJ0hcRdTcHfK85K3jdvM1nGuI+aWew0+ythLirwTWphduo7JImDuMh4NUnlmGydMBIUcQ8ue28TMu91r/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR01MB3849 Received-SPF: pass client-ip=2a01:111:f400:7eaa::71e; envelope-from=aaron@os.amperecomputing.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham 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+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay --- target/arm/cpu.h | 5 +++ target/arm/cpu64.c | 81 ++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 72 insertions(+), 14 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 9c3cbc9a29..40b4631f11 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1039,6 +1039,11 @@ struct ArchCPU { */ bool prop_pauth; bool prop_pauth_impdef; + bool prop_pauth_qarma3; + bool prop_pauth_epac; + bool prop_pauth2; // also known as EnhancedPAC2/EPAC2 + bool prop_pauth_fpac; + bool prop_pauth_fpac_combine; bool prop_lpa2; /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 0e021960fb..315acabbe2 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -590,8 +590,7 @@ static void aarch64_add_sme_properties(Object *obj) void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { - int arch_val = 0, impdef_val = 0; - uint64_t t; + int address_auth = 0, generic_auth = 0; /* Exit early if PAuth is enabled, and fall through to disable it */ if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) { @@ -603,30 +602,79 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) return; } - /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */ + if (cpu->prop_pauth_epac && + (cpu->prop_pauth2 || + cpu->prop_pauth_fpac || + cpu->prop_pauth_fpac_combine)) { + error_setg(errp, "'pauth-epac' feature not compatible with any of " + "'pauth-2', 'pauth-fpac', or 'pauth-fpac-combine'"); + return; + } + + /* Determine the PAC features independently of the algorithm */ + if (cpu->prop_pauth_fpac_combine) { + address_auth = 0b0101; + } else if (cpu->prop_pauth_fpac) { + address_auth = 0b0100; + } else if (cpu->prop_pauth2) { + address_auth = 0b0011; + } else if (cpu->prop_pauth_epac) { + address_auth = 0b0010; + } + + /* Write the features into the correct field for the algorithm in use */ if (cpu->prop_pauth) { + uint64_t t; + + if (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) { + error_setg(errp, "Cannot set both qarma3 ('pauth-qarma3') and " + "impdef ('pauth-impdef') pointer authentication ciphers"); + return; + } + + if (address_auth == 0) + address_auth = 0b0001; + generic_auth = 1; + if (cpu->prop_pauth_impdef) { - impdef_val = 1; + t = cpu->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, API, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR1, GPI, generic_auth); + cpu->isar.id_aa64isar1 = t; + } else if (cpu->prop_pauth_qarma3) { + t = cpu->isar.id_aa64isar2; + t = FIELD_DP64(t, ID_AA64ISAR2, APA3, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR2, GPA3, generic_auth); + cpu->isar.id_aa64isar2 = t; } else { - arch_val = 1; + t = cpu->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, APA, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR1, GPA, generic_auth); + cpu->isar.id_aa64isar1 = t; } - } else if (cpu->prop_pauth_impdef) { - error_setg(errp, "cannot enable pauth-impdef without pauth"); + } else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3) { + error_setg(errp, "cannot enable pauth-impdef or pauth-qarma3 without pauth"); + error_append_hint(errp, "Add pauth=on to the CPU property list.\n"); + } else if (address_auth != 0) { + error_setg(errp, "cannot enable any pauth* features without pauth"); error_append_hint(errp, "Add pauth=on to the CPU property list.\n"); } - - t = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val); - cpu->isar.id_aa64isar1 = t; } static Property arm_cpu_pauth_property = DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true); static Property arm_cpu_pauth_impdef_property = DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); +static Property arm_cpu_pauth_qarma3_property = + DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false); +static Property arm_cpu_pauth_epac_property = + DEFINE_PROP_BOOL("pauth-epac", ARMCPU, prop_pauth_epac, false); +static Property arm_cpu_pauth2_property = + DEFINE_PROP_BOOL("pauth2", ARMCPU, prop_pauth2, false); +static Property arm_cpu_pauth_fpac_property = + DEFINE_PROP_BOOL("pauth-fpac", ARMCPU, prop_pauth_fpac, false); +static Property arm_cpu_pauth_fpac_combine_property = + DEFINE_PROP_BOOL("pauth-fpac-combine", ARMCPU, prop_pauth_fpac_combine, false); static void aarch64_add_pauth_properties(Object *obj) { @@ -646,6 +694,11 @@ static void aarch64_add_pauth_properties(Object *obj) cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu); } else { qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_epac_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth2_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_fpac_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_fpac_combine_property); } }