From patchwork Thu Feb 2 21:11:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126742 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 08AF0C61DA4 for ; Thu, 2 Feb 2023 21:13:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgs6-0008H6-Bm; Thu, 02 Feb 2023 16:11:54 -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 1pNgs4-0008G8-W6; Thu, 02 Feb 2023 16:11:53 -0500 Received: from mail-bn7nam10on2070e.outbound.protection.outlook.com ([2a01:111:f400:7e8a::70e] helo=NAM10-BN7-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 1pNgs3-00088y-Ag; Thu, 02 Feb 2023 16:11:52 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=RgjPNaEgF6aDfTGAwSRaP1YFq8MH4E9/lEHYEBf2UnxI+MAnUEIsaatS+m5TCJtuenxmR4Wk0FdJLva4IfhnPmMmMGKIDvp+9AUOxkcc8xOgaNpsZ12AyTiZMZDeoiFi30bSlSyjnRRYFwllqjpvPeVzbMcnl+tt8CjdL8QcHeZXq05mlmH0n3xzF4uRGNgOueMo7LF885FQIwwbgb2beMSpGr7NAyVq7XRfvshAYUIteJR1p11i2TMT8rdNBUvHab89PyH7F8h/x7++UUS7rgQx6cdFrut9TU0iuBgPput8UjrdY2IUiTVjdasxucLLHCcRaqOVP7vhyysDgD3bbw== 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=2ggVSG398l48Y0MR9RvG3WggSRZvJsguuq5RUbquXF8=; b=AAK9rgGg9OeUYCE17umsHEp55FtOVQawv0fqUAQP3QaVxfa5GdEqZhmPcupE62YiebI1S23ePPiafFQDivA05Cw2Lanki2OQc5v4TBYXX6tgBWXbq8t9n8d6p8CM4/51LFcoH5RissbXAqXTEm034+SW6I0DYROCppZ+RO9o9+wyjsyWJKZF174FcVXEyKz5+NTytnLX3lmVVm1pyY9I6XcCkZKzEGiINJMS0pZSAHDflXc3Jk0GRH7XuMGAZA3nNoFtvsbhpcwepObVj1cOo88ryEovg+HBTJSotUNrCJki/tDM+Kx4YiUIrtYfv2NotNO8W3CGQqa4/mJX7bfsZA== 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=2ggVSG398l48Y0MR9RvG3WggSRZvJsguuq5RUbquXF8=; b=di+Od1Ia/FLu2QnZ7GHu6PQrYA6aZSSKLARzUmfrKPSGnDzjdChVC6+dTJwdLcvqNhatOLL/DyGrpgKSlYZ5fpESUmhta3YV+lekuvV6wATwEHlUpPu9CmRlkuY8k3GvaqzIGRL3y/O0ceQLBB17RES5FDzl+BpVV3o7/yJ9+S8= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:44 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:44 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 1/7] target/arm: v8.3 PAC ID_AA64ISAR[12] feature-detection Date: Thu, 2 Feb 2023 16:11:23 -0500 Message-Id: <20230202211129.984060-2-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: 71028f4b-22d2-495e-3ea0-08db056215ea X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 39o1oX64JqtsN0HyJ9lSFtAOF4s+h9V4xDQXS8JGCKkAvBYc34n1t6V9EwkZB2n3bL16ip/qc51aL90EarTstSO9RoHJtgJzOg3ZtScsYqGtdJUn//yAR29uAbUq8z09cmkI62UnLOow7pEnMFQKBlgn1xKSFdP/iF0QOcF/j2r3FWsXROKqaJgVIcP3WChH/Qcz3WTAdiMLhfofszj5NEs5gz6NOe2+2LUQDPQcZXNbmBCPOzsx60jsUv2sSUpofEb79Ovs0dw2e6RkiGJ2unBskWYK3geJvj8K8Pb7K3454+h8qPVKpiAIkPuXjpzU9hCiuLOhySgW1na/XwoqIl/ybfTrY8bjaUgLuoXflxrw4JhOD9HFuJiPs5W8OSTOEGpoHJjfQM+a/5EOEQuhcPrVvs7Yl32NlbSk23P04cVROtMUo86LG0Tg35f2km8aJ9jnv55JKxv/U6NJ1PH4UFNDI01gV7dUr7kBXW5RlIWX1TCnQszjno74UpH3pg1JWxGYVzdhPB5L5aTGapmI5rccU+EhJJ3k/YtLFYJcf+EZLDBWv3HlWN6peZV2Btr7lH5yAcRJWZRSJRk6FKZ5GgRx3PVY14Wxl3QjFC+ofV5U+o4b75Iw8ESPx9wwMhw5fhFnBaRStwAOUcZ8P4yr4RhaPfJmgQsLwyHsqg1mL9JnJg4rpaujhE1iTvgAycMPBVnQaUfqsYi+v7a0+7OSgQ== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0THVEoJM4vpi6uGOtsSiS9AYd3nFYK//Yg9M/R9/lsWd/CcCHRQLpmH8gaKUZCwEgYscyLw3Db4pMgt5s0SzlMQF+t4xFsN4t4HxbPmITTlY9YHhbAmAMUDo1wiPHBXVRHlPp6QLik7EzSzSAVDAyXotweH224cySD/O8BZ22Q0zUFgmT5RFofjRcvR7Z10f7ou9Zo867l2LuOqqmYjIsen8spV4LyjNxlrlvL0wnN/B+3uridnbk5VOmH8gEFQ8kXu5ikljh5eeKmhRV8j8clvE7tbzotlS/ANZ183NTE575pWCRTmYdYu+7G9FSp+T3BBpg+An/QQAAfMOQBRQUdH2eSWaJ5rAAyzpMlrBZ7QMIxw5jNb7X5M2X8BGS+Xh4GAfKugrv6RZTyWx0armRqXSIGbp6/o2K2n42QRF58KWKf+QwadYEWxiYTI3xKF1Y1XEaMRbeFHuXX2FXZgm4ANkRoLeMX91Fod5m70XLhGRaAbBcAoitO3dkVrZDdpWIRudhoVcpLfGb7jt9KRyyf8JCrl8ttiATSdR0/l7xxc9Uj8S1RQs8tbZyibjQo2GstnzoXMeWRuJWiDAVYazmSGtNxKQP32XXGFhFboLcYb0/DBCIvMvfdqdHR9QH/i+wzqvcQpqAwBJdtlQjfNZE+FlPJ9EciBR1y2RfJqcSPpVSWn8Qeye/OEXdAGKFy6D9mRX0324sPw4fjb4H5O4LhsCuwkAexeYOCiW0/e9IyVYVPOO8BSqnKNQ7I0FbDJuZDUPFxY5QMLsDx89//bky0IH9QV7GJZD7ffct8oE/kvplAxRFz/gFkvtocbQzRwSmtKyPEycK4csMFEO0Thve87P3+OlqkLeCvUHHCT/vV1XHg/AS9iaixplThcjyHvLFOwegVzs1hFYcvGN0GCCiveOriAcYzzAi6t9DJH1ncctEM5HyvOY5XL2X3drVta9JWg7jBGzw/ww337KV5ojIn6XFq6+yHWepYv7/sLHVAUqKweFVlTzgwtzDBzZL4Yb4Y+hZMfishR1VBypOt/SFEMMrYw9Nnp/u4FswKmJ19aoqX5Oo1aBxGoKT3kaqpCoTiOiIhacJ6+vSiihnOALdkGGO9Bjept3sWimKkzGuo9vmeP4qTfMmBxL8oDla8+nYFqKZQjDKkfGBuzMPeYt8RIc9N2fhkQwYb3zko1v6h93oL+GIkfdIqhYSyLssVv7mdfRieU2Bclkq5Hzsuxun5NRWTPAfFrdTOVkM/9Z4340VdSEbHPpACQ4BciE66aTb0IIOKspnHqU+o7paPVwC+59GFkmcsHAoardFUVSF2OCWzqoymolXcPmyDiCpqTOPIF3Ecadi5tVbEFy2sm4e3rr9BWPJPVGanQnEFYQ1BFEDk/myCEaeRN2YWkD6BlF6GpFOc1y3YVtGDgfbxhwIuQ8ePtK4HGKTBDt2u1abribWQKy3jeN3e2TkZXAuXCA5ubHNYxHObMXf8HfRxUuskTTt4E94k9fmJ/f8XpTLMIMk+cbLQtC4Yc42/WfOll7qB1xwpz1YpE9lM5IH9qtZ/kVp9qa/jWOLK8B4cEqV9yR6g+9ui9hkYXJyFM73UK/AopBTjqcQ9279R3cn1s2bcBF8nhvEd3oLDTU8DPXvAg= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 71028f4b-22d2-495e-3ea0-08db056215ea X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:43.7226 (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: YCcYLm6+2o7PwSAgu3LQZBWbN07tlhdKKvt5PD3L40dAcXk38syyJ+T+L9v4yrS2v5SDTgDUTopgIsoymmRB8MyK1BbbXL/I7sxO98111rBwhcFFSKnr02wKwXeC6lQD X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::70e; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 | 57 ++++++++++++++++++++++++++++++++++++--- target/arm/helper.c | 4 +-- target/arm/pauth_helper.c | 4 +-- 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8cf70693be..9be59163ff 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,68 @@ 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) +{ + return isar_feature_pauth_get_features(id) == 0b0010; +} + +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_fpac(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) == 0b0100 || + isar_feature_aa64_fpac_combine(id); +} + +static inline bool isar_feature_aa64_pauth2(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) == 0b0011 || + isar_feature_aa64_fpac(id); +} + 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..a0c9bea06b 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -282,8 +282,8 @@ 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))) { - return pauth_computepac_architected(data, modifier, key); + if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { + return pauth_computepac_architected(data, modifier, key, false); } else { return pauth_computepac_impdef(data, modifier, key); } From patchwork Thu Feb 2 21:11:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126740 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 D5ABAC61DA4 for ; Thu, 2 Feb 2023 21:13:10 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgsE-0008Kk-17; Thu, 02 Feb 2023 16:12:02 -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 1pNgsC-0008KH-43; Thu, 02 Feb 2023 16:12:00 -0500 Received: from mail-bn7nam10on2072b.outbound.protection.outlook.com ([2a01:111:f400:7e8a::72b] helo=NAM10-BN7-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 1pNgs7-00089d-CK; Thu, 02 Feb 2023 16:11:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UF2Bu5LEVysjJJ3x4Se7IMwS0jALFCySJlvcv/PX4RY0bGSWxPd16crHOI0d4C3cpgi7K/ts9QTPHFeO021Hs4alajk/B9Ex4i2nBqcC+8PSGRFBbsFef0jxScvFFkiP+QwFHFg3udLDYOWL0cfq5zLvayWwMnYqKjxCVYk0Y0GUSC/ZVhQaQ4ooBAK4OMi4wJTnDrbU423CZlZDwW8cZ65I+QBjFXs7ArGexaHMeSqL0HKLhQ2/z/SCXKjRk43VMF9SoqdmyE8hVUFEP4BWwFnlIXPhdBbWEtbXytHPktKz+DyIFO5dqIimtp40147XHGBrPvHuhij6AeRZHzfOEw== 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=an8pEp2vpzLK6xYyszENUQGGSGgCnVDVCGrWjKty7vs=; b=m9KFt3Xj9TOR4A6XVkkrmcpZI4GfMy+leRCjMZpWIT5e0MCseGP49Vole6YMW3SeAmLOa1KrTl3fGP5QNgw6wODAAjvCY6/ntiXI7i/I8qlEab21tUCLChpLxUAkAx1PXTHhGezNpUoLwhcy/HQuLkqizT7Racu5pcPac1hqTMWHmYxsmdKRHki0N3k2aWvQg/68rv+ykHWkl3oFaw41mQQb7vGNy4Kg+i0p9Ptb+QERZ0DMATHCczU7pele/7UQ+gJ9KoN7yeSeOvjsEGyb2QE9r4fJU+fFOulQaQzs53SplQmzRFJ1Jy4rDlrHzvaC6iGC0oNeYsqrN+zvOa9BxQ== 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=an8pEp2vpzLK6xYyszENUQGGSGgCnVDVCGrWjKty7vs=; b=PNe4OIvG2q11U7tqrmKBkRUiM5BVBfwDLiDbcTOH186z2swJWXAmD7LUw8vBOjxgsTHV0Iwog6YscBVOjp0Ko+Rx8hm7t5wTbd8NkOFAN6O7ELJGgM5wF2H57QQtWGWKixUsvaJ1+OVJrPs6HEPQsmwr+B/aj8GhHEmGL5AYOUI= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:44 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:44 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 2/7] target/arm: Implement v8.3 QARMA3 PAC cipher Date: Thu, 2 Feb 2023 16:11:24 -0500 Message-Id: <20230202211129.984060-3-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: 6bf00309-5b60-4ca9-d3bc-08db05621644 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: b6KSQeUAs9RV14MxOYqDzvsMRHJu+yx/GESk1toP3+tsYxKIq5NC645qIKaDWRJYoe7n6kvtAeG7YgTedFmtKixH79olV6l+qQjJiqBxZgxiyii4VkVTNCy4WtWz3168koJxoT3hxkeJvJgA7448QGdALhrEGBY6EZzJK5kQd4zfae1Pqbv5yfG4SMdoO5iDYcp6NAMlJRS1pyE7vyvvL89oc/klfhWMdONzaMcrabmjFSnoHRDPrqZa1zwMpyRwmWo8/aO0vdWEbvFxTkZ/9q8hCqOurHiM/H3SRdkvo2lfAmyY18OyFcqRUeljwM/od1ZQkcvjA6qxiIRwr0y0yOpB2R68onzv9bwOMskxkoiGVptw9YVphYL8q+7GUbVJ55LKJQ2DNuORfhDMwVONYTBFofCbJEN2hOQtOfLn6L/VnUMR0F9F3EaS2sBH5oCE8bT7U+AovPnytReDCrQMsiR6RlcM4NRSTOIkc7IB5ZFtvzZfxIYE45iJ2AARzYgOnI34Y7Xf+OV9j2cPJqfMkUBpiYaYjrPNIbMHUZzo5olje+GLxolLzgmIYWCQVyWro1W9+sG4vfqJFryf7p8/9o75MzQrazrfnns52aZpeqNGn/ot8oY72oExCoHkUgAKXh/5QYoN65pw/z3RZtXPQMbz+kojyeKwkBqF9Ivt7sBq49Ykkf+XfOe4kaV5fECTfBdpRdil1xmMSCln5VbAfw== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 9wAvj12D/cM/AhVEr1IxKSh7NmVz1KNv1/PlyEuUf89GCzzsrGybDa6054G2R5LN5Kwq3QC7ZgLkBpkR3dbl6MGxbFt0Dp5QrPeANI3+bjInTZJGLuCEhvXYRPSrz7KwFPwI/wKO75U+HfjjfLnvdompc2dRV6/k8CHIXXoNUBmnZhMV1FxMwTPVpLhQoCqvV/Ecgxwlirh3gvr2RgVUfpkxuDclY40qVIiTP2fLq3oH4EHNFj9ymTyeaG71ymrrtnQfJG6IFf0Agg/2OUOYmAufmDyiqx+/3z0VxUgWi+hrt9SjTg+Ap7AKB8xpprR8jRJmY6g6mItjHVaFi1MGe79Q/D/IbLD7Sob2LlDwxFoHr1B5iLf0gl/P8VE8Vm3VCXsOtN8ubuapBBq5YXvqs8N25muJI47kvMjfkYhtb8UHvF5y9OO2U6+ehWgPrWUUiSYywGgsPVeKB/zMIGRqAC2VxkurhmfjEBqvvkmSBuBXNZGbXeCBsctJzXaRO9O36zCnLVihtGLwI7NHv3Vr7Z0ehJX0EdRp4YlERArega5uIvG6fqU7LjPuOn5YzSZekSAoyJ/TUCDJfw1Yc/itrNKr1LoKCLDr1nni/W03Q8zLcCQ1ovcY2yU6sj88ji5F2p0wvpsYawNm+1qNZJ5+K/eTqOOXXeclNaZee6d/RihrrgfY68MqSV5FW8l7veY/zCPjx6vlitUz2xNcfjQUuafrEFXEG2VDtn1bdqA4AUxlTLSQCziWl3EjU7paS2u67o+zxnkPkQ0VvKpiOIBLUQxBIexex8EY0z731By9Y7Ht8KWLdyNaRMUeX+C/YNpUunx9VgjYgyklCfjZ/bt/RomdTfzwXU1UyC/W85clay74ZZcaGO/2osZefCPQgjLAz8OmsSIfP43wHJZ9QxSuZ2JOcFPOsFcE+UfomjcpykjJ5zwMZd0SgcNXXA89QIrZ84GUbLOPdPNGlRrVEz8NPLYfdNUU4yv8loCc5exOqM1YFcZguJVWH9bBTxPRdSLUAY7tS4ODjC0W9ApN5avAVThUog1FIQczNlg0FI3R5TZHmyqZNAJhHUav5GsfgJRf5Jz4QT8aePW5ZyXC9/nf3wpgwHRf8tsa2KjdGaMjQ8gPfJQqHlKUdExuXjJRbDd6oscn+3zh6AV5OJiev0/qX/23bbHmAIWZNiCPSogfJSTC6rjfbsy1I/W328yPPJMJJeWgx5E992RTSsujAEtv9yrhK1v3b4wKUNSdWchm0HFuFvIzOdBcQk7HLglhcuBVCEZbpTwh1Y9J9zWcn9KDvDulr8HQiErL4Khu+KqN+wvdlFva9algkKiouquH3DtreSa62oChx7zIo4nbQIVBYurdHk0xnbuXlbkLc6RZIvcgfZ3cKhKPxBb4SaM2c4I3pSkJ3DnXFxEEawTdPpGXKtPFfsSePlKVNY0pui4AwFkN7Z950kzUIXtIA//RJGwpGC5GzktvwaN9g1jKNOgVqo36RDtsYn7998SnaxR0uAIK1sP3bf5LKQjvMZ4N6ubsguWEPENhWm0OGmNZmQrOx2ZGpzEA3H44kOoc761hmLlMCP9bUzgIBOFqPDuYu6QibINJPzEQtBxgc4li8pp5aPItIQUYTMmf2nWeMVO/8+U= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6bf00309-5b60-4ca9-d3bc-08db05621644 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:44.3162 (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: TTdN9pu+WPmLRhaumw12OmH/ZIGQeErcyUnbIWPQ+MB8DmN/xWYmHGNPSJSCBZMITNWIzFyE4d/5SnFSb+yCAW6GbNrNve0dmaNvtaiVgVMkgwLg/6XIxw11H6Yn9mSW X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::72b; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 --- target/arm/pauth_helper.c | 48 +++++++++++++++++++++++++++++++-------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index a0c9bea06b..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; } @@ -284,6 +312,8 @@ static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, { if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { 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 Thu Feb 2 21:11:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126736 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 78807C05027 for ; Thu, 2 Feb 2023 21:12:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgs8-0008Hy-2A; Thu, 02 Feb 2023 16:11:56 -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 1pNgs7-0008HK-0E; Thu, 02 Feb 2023 16:11:55 -0500 Received: from mail-bn7nam10on2070e.outbound.protection.outlook.com ([2a01:111:f400:7e8a::70e] helo=NAM10-BN7-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 1pNgs5-00088y-Eh; Thu, 02 Feb 2023 16:11:54 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iSHi/8Ae7mNuqyjLVO9F/aD4EssUSr22aoq370SnxQ44ecGhh2t+mLIvYeomRWtBqnVL5nNezCNJ1lWsR6qJAefxJKQ1WZdsVWdWhf7N+Tk9Hsig4PYYr1x52WbXphL6YdER2wv8S4AzxcHdLe1dI4VBZIbB58dswEtA1OYjkInRcN80Q2iOXFeU5ywk7ywlD0gFvygJST53K8DeOq5oX6Yz8rbA42o1QgfsLs0kl2wEfPaa7jPkQlyffoPo6mASHNhxzRZc0HrewDuiOShfUpVPgLlMXuiBZsQAentwQj824s+6S84pI3azWEMPtPy+rahsJ1f+/6eydqSWHcNi3g== 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=lbUbO5AHMuk24EecXxY2t28R3f0zDqCkEQ8AmX/pscA=; b=afH5zJd/FJBsEWBiS4LmaPnQDR8uRK8RGGdUzjhyDTqoP1BE0TtLKh1B1X7tHS0tKQN3hs2bMnVIBFYITLndo+NAcFCn6kPCR0Rjk9jyqU4E2mGGLQPZgpGJ5m0kLxS8ud3hUu0xGVKnTZfFYxeqn91eAXoS4Z9heFnhoP1zpzj18bRDwxjvXNFJuVkRht7zta3kOUal+aOG8TAohNcdL4h+d+WghcZqHVKFltUtrKsAp3YaWjHu95jqtCaM9cfZ6wqT0nAZSsplNCW1ho6wTiXNpIuzkvVjphz5oH/hBhKre3Z86nE8zapeVOo5fdesA9f6xzIDlo227SrN38PhFA== 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=lbUbO5AHMuk24EecXxY2t28R3f0zDqCkEQ8AmX/pscA=; b=MkppCwJvegwP4j03+2+axWzG27hRfWnRsKoLyZ6/OZAYHYMvUGSn1cZrfLdZMlu2MQRu2i5JTUk7xRWjr9WEtr56pos0P2r8/cYHXThW0a51EZEsniIiRFzg8vra8bcHSLpMxcZ0t5bEFEHiXens+xDLaeFgbQ/eRr4doU4oEc8= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:45 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:45 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 3/7] target/arm: Implement v8.3 EnhancedPAC Date: Thu, 2 Feb 2023 16:11:25 -0500 Message-Id: <20230202211129.984060-4-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: c25a5c46-9366-465d-1c96-08db0562169f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZMA2wPZFF/ZbHGT6ktFbAXeJlZ/hQ7kn4aJCpwur7DXAvyOYUPBUNT5se6nAbS3B9bBAQolnoPJFSMXd/NGxxMQ7AuTFYli6dnmJbln/huT87sfMMgxMKdaP0UmcOVFWyXO47ZkKvZZMnba49VAcBTvUvOWNqVh8kFBCOR1w5XBW8CE4yXBG4YC31L/xYkBpm0p+pVYezvbwA3FDHh3QppCZa5qrh4HFyjRBHGvpmRWXNJK3pvoyqUZ+OuSRroW7bUe7Byxn7c8fS6P6X0kNUTP76TplhVu2PQmpYWDD3+5lJpmq8bUo0kqYTkZicKdxmJJX+oGsQdvsdiO8Wa2t0lKRaPXDr8Vvfg/ECKpchNQ8glWCvLEYralmRWrTKFRk+4RqXeMxy63CMrWhJGq2t3eiD0REuFGh+hCuSAZv8E+hMFp4UEOvD57pA+VmDKtuSgDG4ncmgGPFjGhXrvHkCgLXMT8Mq/z00luJZVzOTssG4gQcnq4mFjkgfPSQX4wOwY0scaT6sFuORg8QaYQFu0CQdYwN1oi2nhKYxScpmeWAiYRVrr3LATwfR8batw0+3LhqeFblVcmkb50ouPEAwuCGziJnwzAD1B2A4BP6BSN5xpmpgSPYvK4K3nuVNssVF+v6Yj17H4p5ung5459NIKGM7pUoJCe+PwFt8Kqwf+yM3dZBGvoO8Zw5c7PPXKFZHo2isClX7DYdy8Jhqq/htQ== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(4744005)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: xjkXRaUTjVF4Sroqjg8aR0VpSMt+2Z6ybog0LiPHXRDuyD9yXATvqd4beBWqapptV9dSsjm0kjnQWS5OQUQoigK+BkBe8OIHPMxeLhOs2uRzU8Zk56tPns3GvdoNDd+JGlFw6ORCekI9e/SavTjOm5QNKZ0PvELYJEM5vFwpz7GxXPorgY7Svz3EXzsHAuHELOTM0dk9n6gMIVZxmDpk9ZkWSHyuj4tuChGaL6s26A0WFEactGv6Z4NgvuImvwb5slXBGaFtuOC6PM7UUIQhGEc3MsnpwUNyRwlvR9OP8J+VXzItePYlttCRzh+HuzMHvDi8cyKToDisxwFICRzE7YAx4Zbf2Rx3afMf/B+kKyuloFCWz2cTOCgC46qo1bjozJG/GTysUuYvjj56DqpJEpYVhushzEItu9Kcz00fax1xWyJwq3x5F21JYyljXCqwy2bG2PiuCCxbS4byFRYrJJwHJKf/DJ+4tkOhN5+aFbhhlMTrvV1UWmwMxiJFQnOS73YIGM0KePMe587dCVUPRjIPVozo2Ek7cofl9x6HhwgXWamb78b8TiqlH2knw7vHmIRMax53MwOYxv7Z0bPdDdhn9nFPlBaEy2O0GMUsq60WjAAjPS0G0LAr9K4vAkqdIQCZWfVdtiSMdYc1bJPJiqIx61364v5BOmS4z76OZ3SRa3UAFOd9NVMThPb9JFeSfZ+GzjbS5QfDVOojsFTZRlvtixj1kFxqoxHeUZo1VvIZlUH+36zOp9OPWfm/ShOFL0YG+HjOJ691CHdpJdC28o0ygysHwchsVnT/4mrFFwJ79r1eJWpZblGvRGLmQ+/t/j9kCYKAybo3dBOteFctBQxWLvWJBRzuwJ6MUVs3O9goWw057EEEv+C9g6X64kZWQCPu7x06XU8er3qrXrRd7ZOkY/ldE6yeC2vGyi0belphUtRQLGKe8nl0XD1oPiN1pAYZ/KsECkNv/R+Zg8zuZFDhAQp9MlTCtyX9krrfePYB+XSKd8wOvocl6W1DmyOBJY+Vu1F4nkFuAHOj39T0lVq2/nxKGq71Y9pmEJssaD/cihx9N+SwyXR+V1/DQD7F4c5FIqHoMmkerHPza/vvFVNpRcrb0y8thpw4NzW+eyPn1zOMfiUzhvygpZDeUtM0aWm4AbeI5Vj75wws1i7hwX8PwGUwtaaKiwe+Qfekjm57Ujcy26qjok9xEpWgRxw0dlaYIYzUyo/3AbG6hhVEWjOdpdN3X1FfKkPJb2hYM2ufJ2djI4v7vW9yy/Cakz4cH8q6r7tFLrNx5fG5Xh/VPLHOOCwNzgsO3nPraa66pieDuhETpqTSHEkNJ5caXOyBdcQ+CjUpovs0DAvqTyDd8ldagLTw4CtewcqYAeOtSPPkHtiQIjzAQb58U1b5eHrJv6fZi5jYIhdvlCo54j+ekiQ2rh4XXGKItPWwrWO6+qSo3QAAmQ0HzV6H6VPngkjjBQsdAgt8lKOW9EdMmyVabA7vQAqdGNGmEEdabemvVbZwjoCvkSdC3xvyfgBTuxJAEXl8P2V8yqUpcUUWyATN2heCHqNj2HY9MRzvG0SZ+rC1Z7XwJTkrT6hKgkx7ve43mclMxp0aDCFpoQDbFSMLzXXMxsJjzovyYfyuQV0RK3Q= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: c25a5c46-9366-465d-1c96-08db0562169f X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:44.9704 (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: TpjtMPxetquxs1xEOck9mxJXU0swvwq2uG6bTc/jborfXmHXAyO4cUGCUCsjNKrnyNLhrK2RI9yNXssgDeM5ffBm8jZvpQc3m6MXZL3ukpeVp1/6nsyLWaDC6geEP+Ts X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::70e; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 --- 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 Thu Feb 2 21:11:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126741 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 43D7EC636D3 for ; Thu, 2 Feb 2023 21:13:22 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgsE-0008LP-86; Thu, 02 Feb 2023 16:12:02 -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 1pNgsC-0008KG-41; Thu, 02 Feb 2023 16:12:00 -0500 Received: from mail-bn7nam10on2070e.outbound.protection.outlook.com ([2a01:111:f400:7e8a::70e] helo=NAM10-BN7-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 1pNgs7-00088y-HE; Thu, 02 Feb 2023 16:11:58 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nbwozvH5xwWfmJJzru3fSC9437geBkfp4vQ41kjjIcgylAY8YjJlYw4sBQnKc9fQ5wsgmOAvw/LjfL0HHnog9RPAgbpUk4+BFUoHEgsy80fUWJ3wGt2vPYgsDhGfms1vi/SC1ee0la1TTueXdiBJ834tKmHgD1o0Bh7z6p53nuu4+UZdFjRnVYE36eHCpQOiZIKdUQLf8bwuckg/lw6KelA7akzm3OidoYlmi2kglMMGHt8h9ImcA4OdiplrDvDUGnvv1q0j1y8qnnLoqaFaZOisr8fZVpUVA2aYG1UZX5EE74hye48rQ9l1ZrmFB3AliD1H6oN819R+w2FnJHxQag== 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=IuuPrACkW/zAW9ecEcQCjhaI5IhAKFH6ymGl93xiiuE=; b=FCZuifmurjvRHxrbzN5N0BwdkCmXiWnILI4BiwzjxQhMo560o3iE0F28sMigh8gnEbHbmXcTZ+EXJGwUpmYR4GWKjk7dlgQA+HcxL1bS3BSO5ktUJg8ZOfZuwcUKYnhGjTL1W+8fQGoVPMSOPUEHaEAvQwYpEAaCfTGUwi7SbBs4umEiG8Mo4ptPVnzOCaNovJjLuPfGxIJmA/AsYfG31peZvywKXl3Sx17Oa2axkLnR891+RnIXTcVThYv0K8T9QLTS0Z9UiN5qCAGjn9gyuqLwyhHyT+cxlWBXCf5jIqVWJbfQnDSyIAAR5p5bGmdHO+3qNSCD4bvcCoA7/4e3zg== 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=IuuPrACkW/zAW9ecEcQCjhaI5IhAKFH6ymGl93xiiuE=; b=GuCbJePZDTv+8yuYqLgtEA5DosLu50QheTvYwbS1GHNIVn8mVZ+Rr3rv/d7lK7s9AWu+xpFfFFxv8yZ1RiOJ8u36kPodxdO+jLp4DvvDesXHDJW0RFflQ0d0C2+SjO5JWEfDRy0YzswvTI4MBx4ihTX/3FAuYcjOp2i9ayEQqOs= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:46 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:46 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 4/7] target/arm: Implement v8.3 Pauth2 Date: Thu, 2 Feb 2023 16:11:26 -0500 Message-Id: <20230202211129.984060-5-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: edf4e859-101f-4da2-b44b-08db05621711 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PiYJGsA2G738x61F1SEhXNbBFSQh0/3ubI8EUkGKzOnlwNOBNROpv+fyUwdmwcJ+vv1RLMtttNSkHyIwstA1AcwMb7bxpo6WEl+K4ETwuX2YiKKdmDCLI4lxij+FAnGec5OtFrXG23oZeQ0xvtcWuHLeUwS/cZvczuzd5ptyw26buUNhJ7IlyUU9HhKkkAy86QDO4atweM88qdWjICQLbN+ifC6xJo0XkDLrYbtcPiU36EqidIh0yNV7gSEStyU+nMhoglBca751e6QIC8us516Eb42LsJKwhwaEJxvCrkOpK05cVEUlU1TvcMO0fZJQbgg9Svi5SHyUbKagxRzJjmxOLEuQvKmiH4Fhcgt1V5jxV9YCXQKTu2mrKdWQepBPcKArbAZNMqchFQzh5BH8Q8haXhrobRJaCOD8NZs3lB8VN1tTDUsS26O1I+3iiTejmpt8aiHoPqk95r+BBY4YMs5k5B2UcOEiDDd3rWHb1zAPPkKfEtKQL1KBLRlEtNo6h9wwI+ISYpVTRa4oRTuniWE/tLMfQlztVSLjWTELNLYHjpK/wYkgB/oUxCJL4CYP5tnBMMecW4NH7ibSLWsPo0aFBbp12xydR2CW89oCNuZEdeWgNuju88UljhHD2yKGJ+Z2SlRcO1Mk0MCCNZurhBkuddIwEie2msDnRje+jxlF37bk+dYNM8SOAal2qZqD4AbmI49/6/yimBLi5X0UWw== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pLlT3/Tz4WJqsCJoWqscH4kYJmSjhjkZizLV3V0PjbMmdCm24zSAOgqctNLpwMmTFOO8JnDDjEaktouf9fxUOlvNhZobPmROxGRGz7YndDRS97t9HpYvXkx61l2r5EZptWSd6YnEUqXY8HdQFMGObKiR1k+vo/LDYNdDFojlG+TwE33TJ4a0eha6wL/Cmx7zuqcpj44OcumaeRRyGIH84fPglO3aRQDO3BOExSb5bbjWDsdTSwIjKQFjUlrdD403IexJ4ofyVpJMv9vrCVtqfx28fOHe+Qww16hYXTp+dXI09zeLAqpK7nh+5mURiq3htyocfxpBVoHHxT7YLdvHaEKZ8cMvFTFJ7P53/J9Qw3ILIDMBT9c4D3BDpwj1mt/+qyHR2rkayF0A5oYMmIp5h5xwdAkWxoic4DvOmSeBrVsBrlMfPZSJqiB+ElVjEeedHHtYzuHfxbZ5CqMnfe9rPzbd+66EbkVgQJ0q9BONFPKCY5rkg2IKifKgGs8eltoNpkutyZdaI/1dQOB45CZMgZcANfj+gc6ydg4IS7kN3IdOFHw5W+PeouNalSowYCEcxwMcrzbLo6oNOLaBqGQ2+hQCnWdeKkTf9uUab7kkSJMvHCRpsVZM5ASW/yeFjzLWwLQnMl4omH1A/MK2Sw9eK6coiu4cC089+X4uBBC6xmckRrPVIxTSkUPOWMnB5Tmd9oxytW7xRaGlLpunkULbyZ2vaZr+YZUV6qcozap93oNu9UNADo8cx/PffwaO1mc4JQESXIBIgLzbFpe45HbbBbGxUEeGxsWxPZOzunPqudsMG7Pxq0I4rCP5FayVzrWntC5NBpE1mh/QjrXMdohAu1kHSMq3ArlnCS4d0xsTJqcYgG7D4r8XExUrMUXL/mQUnnrjg+UL+0twsWkgJuvLxF4w024/t7Kjzd77eaKEpgMl3rj/1NjPbpJ0EnZD0fOMMHbP6iJ1zJq8ouf28QqIFM4KlAhI0TSn3+zxhT7kOd+ff+ZZOheMSAW5JG+QdylshNAGkkCs4PM13+ctP+m7nMmCd3zO2Jc5VSwfZm/vDBhfkw9R9e7ZPhPhPXzjpYYI+lf9to8vef2EpqYdhP8YQjtT54AsJhj2Wtam5MQFpH9KeOQ5o6jGHP6NVj3mUF6nA3hoZQhg9IK+oIFCl5bmd9HfjuOFiFQu5oTowDE5G/NRf51AFuImnuLnNw+IzTCa/dLPcV317cqKcWyjDyzQb0rQoAg8wXbbaNwdqgW9x66dgkdjxfG+ertHcYIOtgKNmHllt/Wh3vrU3jPG6YmBW/KEz5OdBqQXySTjGqD6/z80BecvZKnazqeot7oqij6hSE8XVSNYhsQzP86AegmoqbgLVbl4A5bWsctRQrTLLugxFuVCurF6AdagPP2diKj0LRfMj3ztpvrF0fQ+LWCNsEE4pE3bYICv5/eJvdEyhrB+S6gUFRmwPSTFQoZPzv+O0Ox0nTp6haPuQCOHJXAu1DRLy1X5w7bywV0kSNtumUqAuVKaau0pWkC/62pC/O/iVKmj51+M6BkIkXLqAVLTWBh9jvH4FfoKHbPJfeVhEtuerNq0zj/4NfxR7w+oyCaSxRLp4mSiQveQ6yNIbanSM8/oYwzW4fj/erjNsBKK3Yw= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: edf4e859-101f-4da2-b44b-08db05621711 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:45.6277 (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: A/H0z7aIBPnx0fU6fBPL3ya9tyvN7777E81aohQjhLYnBazUnZpkbyrRH5bmJQ+iCcinJuibk3OyY91OfgSA1A1yfxXlLinusuGHB9Z9zSn9QTwCotvU0zqzGuIz/RBX X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::70e; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 --- target/arm/pauth_helper.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index a83956652f..6ebf6df75c 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -349,7 +349,7 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, if (test != 0 && test != -1) { if (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { pac = 0; - } else { + } else if (! cpu_isar_feature(aa64_pauth2, env_archcpu(env))) { /* * Note that our top_bit is one greater than the pseudocode's * version, hence "- 2" here. @@ -362,6 +362,8 @@ 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 +391,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 Thu Feb 2 21:11:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126738 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 D0DAAC05027 for ; Thu, 2 Feb 2023 21:12:45 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgsG-0008MK-1N; Thu, 02 Feb 2023 16:12:04 -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 1pNgsE-0008Lw-Nz; Thu, 02 Feb 2023 16:12:02 -0500 Received: from mail-bn7nam10on2072b.outbound.protection.outlook.com ([2a01:111:f400:7e8a::72b] helo=NAM10-BN7-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 1pNgsC-00089d-Js; Thu, 02 Feb 2023 16:12:02 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EcWiJnLfnH/zRjxFGMW1Nk8D2N3FUyF5S0v9K4eQj5vjWmyYAQ50S/joegtNKNtlk+G7ACW4BmrZ/N+Y+h0bNsD9Yi4c8ItMctRG1uoooGrsm9QlE9mn0hHfQDCyso0xJLNjbEiyQMMyhUOooXBbeTXXoU6FysBfDJx4nj/nw88pMiCawghY9uskVRbFI2PWCMSTbM6E4uLYfBEmQGiCABU3ZAplFeUunFrxbG7Tf1f/mJeP5tbowHUP2vo4pMqTn2Qb3WWCbxlxsrCIfyGudz6GQfKMiQICYa8UICs/WOaqZ+ts6GOsgNoNETiKJ9H4B1XQc8IjOvmF4pNjMkxV/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=6B86tQD3qVQQPFg/8XUpVsvrGJOptPopLAp9dyUwUHc=; b=Tnv5U2DcEwFxlGNEEuO/CtBovCoBes53SHSiDD/CzkW2ry0gQmxRVOr2+u71l7RxfqOGmccRnQliaKNYgfg4HRRQJQL2a6j+rZ625EQtA4LnsbQtdPbNEt8TF/JnAH+GXiyq3GAAAf9epGVXYbcF9L53EF0wkUEf/kLRvznlpQqPOClTuTOJHUTESu8EVYrjj+OO9VgC4bTomCNWzHd5lcS/+rp3CCX/V18DlwWLe8sP+y/HAJPwABlDQ/iSyCQqjW08rFBrA6yaCa0TLgSpqXky5X+y+/gufJOXl8s/0J5hCwoKcSc8cy8GIut+bbq8iUVNMl1i6y4Ql/ZTM3I5Ag== 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=6B86tQD3qVQQPFg/8XUpVsvrGJOptPopLAp9dyUwUHc=; b=gUGSCsBhbcQMYmQzEaumM6cEUobBsTHbtXLNQIKixFxv4M/rNGG/vOnQka/vY2B0YCYh67s+wXge5YbyBgboiN+5bTrXfP/bTcf/eVrrTvE1h0vCsJwaSymDaqqIF/0JHYxBRBV8YDSe9Yo0xawp8hSyJuCwQxMIv4QLM39w87A= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:46 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:46 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 5/7] targer/arm: Inform helpers whether a PAC instruction is 'combined' Date: Thu, 2 Feb 2023 16:11:27 -0500 Message-Id: <20230202211129.984060-6-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e577bf7-cee5-47d2-84d6-08db05621767 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QiktIAZR2rrgPATbWnB7UAetruOsIoIwmz6mmMT+LmGa2TKggjpLqWqfXTkapfgiEGzSKH+Rqy1zkCWs7o9fG3no3DZ9RmFw54Y2C7Pb0iU79AdFbRi42OD3qBLyoSJwxZRCAT5eN9BBU8537N4AR1UKBCLXKuNb8MD/pgtyHpBM3QoBHmkZQyb05KCRfG2bYZGgFUFxOWUpVxpI0UfZdOXviECFl4PCeSOdHjgUSAE9ce9qqU5Ij+eC9x++3okl5KzdXrj7y6QdO2/q76uZlZBm/U9Q++33o480stSvfm7CZTUmgis1i/aE6ugk0LRUSUSgFnpnssPKTy/cMu49mGZDsbNuju3SqKC9dp4zhp2EH6Y2eptwABmCWlSJr690IA2AKgUGpFgHfWDczloP6ks0mG6ETu/b/88wjFEIdHj3CK5uN2OmncDqrWfNi/MCUPkiNO07VM1hzSPXYMYASfarFexZViuUnAJgHkPFce4Pk0JsBuYjdn8ASyNZ6mvdRF1Z+YCjmPj/NrcxCONgQ/xjj/2MC//0GdH8qz8W2ezn+/lWWWaLWOXzPdvQKAKCY4QOnW5PppWQip94u0F02/aQcpVDACmrF6xwi1dfZ+jipZEEo60bKmCOTDngtA98/ZDdAJ7htT9r17HttLZnlbxXP3cb4rwqfNBbyewCuaXgSZYvYmMyrlYbUVDPhW5odLbyd0PlDV1XamP3ffpXZw== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: A/hWqnjo1GZfT/JcnjFxjDyCvkU5lbrX4wQgL3GnAw1t7J9s7Mueg13xCHckIhoAw7SfKO0d55SFnpCDKXNhRl/5Dk1K8p1bFfCo4YJ83fzR/xOMqE5FMVTnrU6w+ozxVTie+AGLEbevJrYv4YHjwAK3kEpclRZOCX23hssmF1Soxzqdjw4vwCoXZA0d9kb57PZC/rWMG+4qM+pK52o0QfD8Ql02jPJVAlOu5leHAjjeLuFiLAAtCcBJ2ikvLC9PqOt/553upaufPHsvlgWmvNtjRZfooU4H9uwPmetDnyDVsBiyX3CL9VZRrOYtTcZuOU4CbfLpThq2Mc/OWn+0WiqT6HNiK4BxuhlWhKGddBTauw0YRlmau5hGIcPg4uiZgn7hcmg4Z9kUeNNBLVYWHrztNu5wMSE97JwtH3QPteYJuU8KBYhOiHhr/6yDvnF5wTii4PkkeerpU3kA+QICoa47o+9os3DX0ruxMSmR9KLngoN7FpInFTwkh0+FXrG/MxoLx5DL2stTWshLa3fudapQPJWsahsOYv9cMGpsGJS6WK2boKZiL4JvetUiicta39uOtvhINfx3H+IBz/yUlz3oM4poZT0rQLgIA9hh3DjEqjLbw+hhKYotiMIzm/jcjcjJ6F819+fMW81/vzmOP2fE0KZWsttg0Zr8E019N4zcDf+vcgMnun/fD8qVYpAZ0kGxazNLMcGjOik5eM6WqeSCOoNX7eTJ7WMBrDD68NQ0wl3ML2oCeSJ1dVGbzGgRe9ILryQzMDxvd/xyh9HA+ktTzadJpfXCdaKioS6PJ7OiQ7HC1/UdNc2W02cJDr71OJwzr3JuLghozIrsJ6LcI0XhMTdY2HDgQZ/7Q8L1l3xgWMnipOysjNWsjgFdCdId6qyBbmHj4r/SekqiNl9UHLaegXFryF0zlCqDIbZZeC9efNHWsKThgXSeq4WA+/fcmuXn4IgRStEdSm7zSEmwtYzZHifeIaZ0G7VdBfZtzkcRQVdj8kh+btXQdLMAkiTvmjgPvilRARlG0VysCiEuV8HjUm8HbPqfJj24nIad57MLfM5TFD4UQ+lDpKAQTcwm/RDLLGx4Srcy83s4fCU7TNLd6A28ge0Li3NHslAYcSZ0CBUW3zaeggEhfpVbLd3P+m1uZoqE2cNXFW8mcrauvC63qjnEX4QJs92rUOTEiVrpwyXYjsX1oxnYh+jMyakS2GxeiuLCkkplzax9mc+MiH2bE+6mfecxfWjQ/6FG4M1D3X3kub87ImywACRFLgR0H76/LWGxTZKdE9EOZqwELbaT4m1X/10p5uuUj6d0Tlg3PjPWD5h6KhjshFg6YfYYIHnhzcUgLE9cW9wOy+73ZwJ8ZJkyWPCQqn6POSZfyoSjEPpcQb+YTtBpx3R5QZJL/aDfu2KClK+uAXWkESJwLo6jWHiExQSJq/26KwNEVdIyaCp0o2RaC8j3kNlHOCR224GR79p8B8KAYyktBRGUcIznpk5n5/KyMJrSSFRBbxiM4blbt8CnCQjQH8WmvgapOTcoMTfdLNcPEFg1Doz/cy3Ryk/OKr0mpMMOUkcctKTN/zkh7cSTqFQ1Fo67OJy2GxqPDjCBeS6cOAT9AdQDFSY1B5aOjLaHo1Ud4zGsTS0= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e577bf7-cee5-47d2-84d6-08db05621767 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:46.2369 (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: FjdxPfGo9Q1s/ltny7PfURgvDBU8UDfJE9TXJEy9Bhi3Co2lOQfd2SlL/tGAPoSyRYVStw5vtKIi/zD9o/UEbme/FCzuapxeTIRQNtoeTV/idPcYd6eZt3x9ZPtrBqnM X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::72b; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 --- target/arm/helper-a64.h | 4 +++ target/arm/pauth_helper.c | 63 ++++++++++++++++++++++++++++++++------ target/arm/translate-a64.c | 20 ++++++------ 3 files changed, 68 insertions(+), 19 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 6ebf6df75c..66dc90a289 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -386,7 +386,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); @@ -507,44 +508,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, + 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); + 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, false); +} + +uint64_t HELPER(autia_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autia(env, x, y, true); +} + +static uint64_t pauth_autib(CPUARMState *env, uint64_t x, uint64_t y, + 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); + 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, false); +} + +uint64_t HELPER(autib_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autib(env, x, y, true); +} + +static uint64_t pauth_autda(CPUARMState *env, uint64_t x, uint64_t y, + 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); + 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, false); +} + +uint64_t HELPER(autda_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autda(env, x, y, true); +} + +static uint64_t pauth_autdb(CPUARMState *env, uint64_t x, uint64_t y, + 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); + 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, false); +} + +uint64_t HELPER(autdb_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autdb(env, x, y, 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 Thu Feb 2 21:11:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126743 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 53C91C61DA4 for ; Thu, 2 Feb 2023 21:13:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgsI-0008N4-25; Thu, 02 Feb 2023 16:12:06 -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 1pNgsE-0008Lx-O8; Thu, 02 Feb 2023 16:12:02 -0500 Received: from mail-bn7nam10on2070e.outbound.protection.outlook.com ([2a01:111:f400:7e8a::70e] helo=NAM10-BN7-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 1pNgsC-00088y-Js; Thu, 02 Feb 2023 16:12:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=koTgsjxAE/xwrB7dL4Sri4v9maL8dd39ZZt03u2vqW19kRCsZrMsn0fwnlGlPTrAbvFW8JkIHtyyY84yDmcf3mBw+obZSOFcuP9vqnz4lIqfXptrMnlXaQ9YifGO/9trJI9EGphChXHD5KLd06FbkLJhLxag9GW687tMhjxmJ9CxS4Hvzbwuxuz/n3tXuy83gde1w+cCpglOcjHSXVpoV3owLBZNc2xLe9t4ElANIZikt+WJ7f5gVwAD1L/foA7NuyybKLPPPEgM1/mYR9TNjce1I80H+W7Na/lotPBrq68AWRfMwCjDnaQ0tLkrLhxuFGxXe+lmmNqFXaCkvB6SZQ== 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=G8Jib0CT16EgJgspn4kyp8jbFpu5y6fJmeqI7MTZH9A=; b=gt7ukJEAVWG4TWSGyCyGd6stEFpLPbVEpoSRCpC7+2gz+A9go8U0Xp9u9pQ0lGVg0VxFrfhcqtuXnE+a0ylaxSF2jpCg+7Qgp1lJlV77mXEa0Z0Ww/KZ75ECPZfVXwXYWDd0/2AAWtFbL+QhBkQamk/ZaAvAlG+TueQxC4SS6ABxPGsZ843HIV3ImshbO8keNYWbajB+zbC2/LDT57XxPw1X2Ti3uupvjttK3n/6WzIpX3Fb3wONgRzD9Z29wXQjVyouR8iW+AFyYKPWTQRYHrUUk1KSXGueY4ek6XrC0RdLmkYy3S1rJx66yMsQnVc44gv2z2ASYpRCT2UaD9iziQ== 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=G8Jib0CT16EgJgspn4kyp8jbFpu5y6fJmeqI7MTZH9A=; b=El7jEKFdSfIkeHw9QejHY+JCHp8T5glK2RQQwNMrlXjt9yZguyQKnuCsQY+smB88p62egDcpaR2+MmesoR4qkXU5iZxUPVVhvAWKDZDHqtJ/xjWChZADcaT0KHYk+lgmZilXpPzfQnWHNMYSxLRGOpcru0pHO1Kfq72u/zwnHL4= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:47 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:47 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 6/7] target/arm: Implement v8.3 FPAC and FPACCOMBINE Date: Thu, 2 Feb 2023 16:11:28 -0500 Message-Id: <20230202211129.984060-7-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: 4361dd67-294b-4e69-0512-08db056217ce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hImQ7mphiN+pdqh/0MEeZdj5b7GjG+m70o0DdmL58WtSjY6L6YAVgvpd74rmm9eAWb9kl3yd2BuQ4p+H3AEwGq4cDDdP600eSDXIP6t9/J2y+XZPNb4TBzsb51HKvsjo/P8KATPYh0OsH9AaNHzROy8Qy6EL1MBJ0en2yDnrEscHD7dstZOyjWAbk10uU20jo2eyisD556GpcAn/247pT9Tp9Yc9pREM9lVWEaxWdBAjcH9DQ8Xc561eFvJPGk6ghtlaQTpr1zu04zjbtanTxena5VGXpzJQzyLlAvOw/bqZ0wYkGsKnRWlRvPDo7Ceysay0OocSm5jcPGkRlL+6TV0MOX0YrLF7anGPG6WQ3LBtcyflDz5SZS747gTLnh8T0Cp5YG0wYcNqyX0CzhpMYqRShFVO6WB3LsKzdZIo3qJ5za8BPq47A3VZ9AdiHg5cqLzql1WRQT7A7suRiR6y7am06XGK+bYfHv2V8JvNSnLzZwFYP8ijcKCRJ5cinSeTKyu/Y/JW5d4i+GzGTBBNfF4K2v6o16JSfOgy0CYcQ/7fYkaQJuEyxx4/z467Rug4UAhLmvIdPvjwpEzJ2g5+4/bjwZZmlswmjuHx616rUZ8NNRxLCqIKUxciOWJwXRa7M0Y+Ed5cFvWcFGtpAkTwpNtOA2Dskxg68Zd0ujIon2TTSHw0FKIFbimO5rBL2Kf8wd+30CRHCHsDgvjTGVLz/A== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ARvyoRyECC9yqwPEmNJ5pkOdWNsAawHltBV9tWa0yyWcINBAKB5pmHGBimHBVA4j5zsIvumc3792o6R5X5sr4A1xQEyDnZb+4EZTNFYxxqkshUuG8Ycai4mYEKetVwkHexWr2zKyJ5bdEeo9D8zfGreMK++hSGwrebcQH1kICH1VrtRkeBkXFHbiPOND9IZAiReqIT/HUTcImuSdxhz/eTnNB/0rcTPLW+6iClmzjhvwVR6HPHNnSwTE9sSFWbcVcWYJNcB4NSh/9M1BHu+8/i3/wEe/4MmHLSS5NagcxlAli8qhEOfgM7fssVi+4RQZAwvBAA1Acr86oR1MZQLOvCZNJfFYDobl9mZEDBcJz1uT8TZvboqa5QygcGogCsJFCNqMrSZkCn+CkaxfIrIr8p4HJCAvU4KFwe628w9lJd9hoPU3S/Zx9IcrkvSwbEuPoaT3ZJu+tRx80/o8sfw4SBqv/q75+mWDEJLeY3N9HnjlH7M9LTZ0oY18QutiW0hj4dzVn+8X4bz2PZHFyEbjy9jHsoU4/N7hdGwJaS2mtJz9nPewuPlVPKLQ7eTiQm5LNZnuTOSsLkj6saPOuPOYbbLFNdE/EC5gUAjRh9VA32+98Q5B5Bw481JbMCHiq3+UjPXKAx0Hc+hPdqSS9sSczZa7yD7Ds1+c/b04mDZFLVWtLfbhk4RKdSKFHgwAeaMGOOW0hhVVQ/c7fmglGEHk5JZgx/Ce6EgFZA4yiWzr9j1TCQ+9WZoj1r0x3V8daq8LiMy1yhDM2Uy53++QqvqJ4YM+hEz7gd6fq00e7Rvm0J4hLnbgCt/OrU9ntfBvL9raiVgSz3w6k4XuMN7L1k2dUADipnhY+AHB21YayDz8Tsj9t4Ww+uWKf9D1VAT34wIwSb8FmUd74kQNkBVwciS1Luc4rpetab3nXTc0npq1xDXlsMx5SXyD1MeMY0/a3X2ObXJq/VoqW0aobdGGY2Q3+uP6JMV9XLqfyaqNDDa8zW4bTqn1SlVtkFmgFsignDcjdBIJ7pbgDOoaccSIm6o5lvFylHWZEFm1s5vXDjRAL8wgPT5TdVu2+3DyHSqknNEgUDENaQEJfX28cifWjsmCdCjS9sRbihsVZQAdoM7Tqq8y1pDk3GPI+Dd0yN9UTpTyO7NrdViR7dLceam0cH8zAegEVD0MxRMHYf7+ZRAYHLWdNS4/8BWLtTX2QRoSOo5SQ59vl7zomXU+dtxAneTLAImkV0a55PVm8lYsMgR+eeHfOqcLpS13BrqMj+7+6nZbdsDdzO7is1MxzDEcMladdiRwWMTHtRWv8V3PrvlnyD88cwlczDaNMgoyRsEGJnUjV7gpYbURuJSltnuW9pAcbWU49FoVdrSM3OgPm+z3hkA8oS4zP5wMvzyWO/8F1/ZiUE0FgOjjkgxfH4qpKyP9twTxSqo37faBl+i5e40oCUxZpUWm+27Z2KmxhGZ+8LyFrMt0kCOSz2kl3LAix6ymvx77Y7BDPehKKxdNuY3YWAXrSab+rNTarpFm9zD3Wkydm3UPvGJsWe84tNUEs2OBB9M1joUGbjwdfsOw/HT7eKvk08jzqhw4mu6nJBaxFZCjmxx6KMFIETwDsen3arOKbRDfZAlqLFIAm93jI56DdaY= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4361dd67-294b-4e69-0512-08db056217ce X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:46.8774 (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: kXNdUFPUPTKZioNDik4Ji7GUs+axQYa2IBgT3ihWrXqUv66XfzMori4VkL3LEa3pyhECdhNJt49FlD0Dw0+pbidtiyUQpzQ72IGibkUim84MZXnPxTB1TqZXMPTtNT9T X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::70e; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 | 26 ++++++++++++++++++++++++++ target/arm/syndrome.h | 6 ++++++ 2 files changed, 32 insertions(+) diff --git a/target/arm/pauth_helper.c b/target/arm/pauth_helper.c index 66dc90a289..3a2772de0e 100644 --- a/target/arm/pauth_helper.c +++ b/target/arm/pauth_helper.c @@ -385,6 +385,21 @@ 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, int error_code) +{ + 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(error_code), target_el, GETPC()); +} + static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data, int keynumber, bool is_combined) @@ -403,6 +418,17 @@ 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)) { + int error_code = ((data ? 1 : 0) << 1) | (keynumber); + pauth_fail_exception(env, error_code); + } + } } else { test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index 73df5e3793..885a85735c 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,11 @@ static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) | (is_16bit ? 0 : ARM_EL_IL) | etype; } +static inline uint32_t syn_pacfail(int error_code) +{ + return (EC_PACFAIL << ARM_EL_EC_SHIFT) | error_code; +} + static inline uint32_t syn_pactrap(void) { return EC_PACTRAP << ARM_EL_EC_SHIFT; From patchwork Thu Feb 2 21:11:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13126737 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 8FD60C636D3 for ; Thu, 2 Feb 2023 21:12:29 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pNgsK-0008Pl-AR; Thu, 02 Feb 2023 16:12:08 -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 1pNgsI-0008N8-Ek; Thu, 02 Feb 2023 16:12:06 -0500 Received: from mail-bn7nam10on2070e.outbound.protection.outlook.com ([2a01:111:f400:7e8a::70e] helo=NAM10-BN7-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 1pNgsF-00088y-Ur; Thu, 02 Feb 2023 16:12:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j5M3h2eVFthlDEy2UcGPqk/E9xN8emmz46Jjf8xb0XUowPahwM588CdmR42GF5FUBsiidzcbwA9nuhV7+wBBzcWBoqMgLnGEhX/2n952gzgZGQewNKCCLAs6GrzhWVfVkCdWauLe8hH+e7kUFdYjRhmwrNKRu20H56ttGdL0KjECSiDnfMBOz+r6eCg7s0bKK+5aH+6AQ92AfJ6iMuNbGIrlDRvbOJ74C3WQfrYvG+2mszeE48HFFiuj84tVX/E8GrWOkP6fsDhQQQPz927aXmgFBV4bXE/B7hHTGY6cBZF2XC9C2iMBgekWz6axfw5ifkjlDwIVqL/bpBjPxsAGXw== 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=38m9nYlQ+DAi8DkbGdDAwPqVFQp4+eGNP1ABUGvoewM=; b=WiD8t4lcOtk066N1j7dpm/yu3p1YEdrscVFvU9tongdEDZAS3mPl1bsq7jQ296BvKGjot0hBwMWs2aZyU7uTJWS/CwhiDluMt27SEX4wGUot3Aa+PCHsFhHJdJVJF64hRiP3ftHPsXtpl0wPd9YKm6k1rtVxZQVpNVifDrrDo1PG3mX6nTk6Qf12YLLjUcYv7syN5bjKI+Km4lzzSiVlY/qQxYM3Fknplso81NAenh8GPcUQGDjBjS06rYt0yVOtRVT75v0+FEqFC2ddsu37yKurQWBs1kbNK0GJD3bWqu5WQhiWKo5oE7Me6f+z1sTzcrFJUsDvfEdiW9eK4OKW2g== 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=38m9nYlQ+DAi8DkbGdDAwPqVFQp4+eGNP1ABUGvoewM=; b=mXpIIRwYikmREz2hU+0rKRTC8MTKm6pha0qGye67d2M8sEHI7Gm8DKQ4uZ+iCKpK8xiegGGOcNR8GvUw+pSYWLXLQkAfW7qjT7bvfQKjxP7VqsbGiTb1k4eU0L7ui4JjVJKqA38i0VXQZZcOunrF/87oP0GXYk8MZk/RmPNHDa8= 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 BL0PR01MB4801.prod.exchangelabs.com (2603:10b6:208:7c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6043.38; Thu, 2 Feb 2023 21:11:47 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::c6ce:a93c:6bfa:2ec8%5]) with mapi id 15.20.6064.027; Thu, 2 Feb 2023 21:11:47 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= Cc: Aaron Lindsay Subject: [PATCH 7/7] target/arm: Add CPU properties for most v8.3 PAC features Date: Thu, 2 Feb 2023 16:11:29 -0500 Message-Id: <20230202211129.984060-8-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202211129.984060-1-aaron@os.amperecomputing.com> References: <20230202211129.984060-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH2PR20CA0027.namprd20.prod.outlook.com (2603:10b6:610:58::37) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|BL0PR01MB4801:EE_ X-MS-Office365-Filtering-Correlation-Id: 7b4aa971-32e1-4ca9-f128-08db0562184e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xyOEJz7mWCtz2U400drlep3YZihfmmn3ERkkHPFz5Tob80uSEi2qcS+EX6hbyzPyNdUWQRiRs513TDinciNTztCOTEw36xfrhP+jhokMyNxWmDMn5ji2CS9kvMuN4V2QLJmZGvcZvFRkQLMG/TewocnYOQdMzk0j0rPVh6aQC1qApuD4HEAnHbeddd9skWo+Ma6APfS3Z5RnR3KjEi8XuIS2wk3B6u/v3xni12GnVDpe2EeN/umIugNuoeW/gQIRzE1VLb6JVG8rpzPBfAyoPunXwC4N5BVWr/qr0ccSepNKQFBS82SrIM1xTRuwiYEJWKl67/79XX1BvYIrT9PX9XukcY3CaKJAEnHsBROfAKA69PY6guG5fNeJRXFVty1UzfJufhPJbqeBvZJFw7iTlj/I7bu2+fp5oB9PVD+a4WcZ81E4k4RW10qYobDyk4/rDpDicngit0125A1wsoKUVreOxT1nh2JYrVWxDRgjBXC+YVWfL3AqhYdHO7IcUJmd9zhX2+S6/ZjqoBzkNbHAg+ms1W8eCw89uHZZRQk7QJT3ahs0FwqlPEGCqFj4prixsKTd6gFwHZtZYQzo+MmjjtpeeQMVCpWb9bh6LUH0h+rWS84kSvSDUzzHlLrCqA3OOYTW3L+2PF/bgUJmIthMFzzwTqLfrJWxivl3j/TJ79BCJO3NxenNHReMjSDsOO0zFRli4xUa0IAvLS6lCm2sWQ== 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)(346002)(366004)(39850400004)(396003)(136003)(376002)(451199018)(186003)(4326008)(6512007)(26005)(1076003)(107886003)(6506007)(41300700001)(8936002)(5660300002)(110136005)(6666004)(316002)(52116002)(66946007)(86362001)(38100700002)(83380400001)(38350700002)(2616005)(2906002)(8676002)(66556008)(66476007)(6486002)(478600001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MrPnDXp1x1o/T+Pdq3kLftzjIfRfWVdUwjhvR07Xi11tarHJvMHDv1O7La9aBufIZHuWVkRLrOKvL0CikdAjTsOuhDfMNHn9EqgK0sxQgp2UnHqTTNS8pmW8K9TOPbJDWiGEwPd8RucjDCvAYrxntFUmSzBPQLx+LOExPRMcnwudo5oN6EYdOQsOUyw4UtEAvFe3LquXkr+LA+WLfwGe567vLvp8j9hSlnLVPJHw4xGM3b7hj1npVfzSS/qV5U9hB2IkTVkIpAeDlWOIdS/yFBo5WQLy8BWwHQAjoxDlunX2qMHJAAFN74e99+XHhLfgEngyOnAwewjUY4+qiOCriyi3RhcwwDD7GHsTVcPTJI5yuZ4VnajYL5juOGbgKEW2RPV6+8g8dGCoo+Cc/Y6ofYSkB1C0JuFF3Z3tdYAOF3gzpYwgkGJAJh3gF86v+AwXhnF7cuMdW0WPDs8xUWY/0pXaFcsiCRS5W9oP8jkI9BAoMotUd5J1LCZo9h6xUouDccfuF6VaHRJmOltD5flZ9TKgY27AmmHhljYlRpPnVPWNujPk8A9eRJXgdxo+g1Ap9UpATaKyF0wCx6tW/Vo2jkVTcM055QIrxgjaLZJSg0l6w8yGBs3ili+iZEOYVminoY8I1ykN1dK5iCN9rx9baE2n3XF42KSx3gkdT0NS2kHP3AoG12paTdzOY7rQnyCMZYWEc3CePqIGKo8tFpKfTR4QemVlRGyzBkTaoEeiNmjYzfGKiOhtuzm7ooPZ1VAXbDAsLwVipuUPAumVdJQ096RTytXJ3b4ws1MUl/0j4IyG7z8PxSGPbRerFAELVtZ4QkAKgj7hadMcGJHYZxKTI0RZlQ/tzPqBqmw/kw+uBn3mQo/lyXv6lWknuFkjY8gEVYNRag/K/q6RdVVVPT+pgCQ2E7OPKK4KhcbfhFHCUyI1IFQdxBKiF8CUTNBW0gfoeNM9BgzqJMArEI/9muZbEwVVi/yyNOgVyKdpL3z4L2tFJEFk6lHDJQi3qRjnzc8xYtdM3onbjEm3xX1pfeMPVVkadTceh6ff4GxnRnIvBCYVKtuFxmj6OQnitd9Dlt97uZfIrdD46vwf3lUO0d2Kes4dulQjYKCmAx4sGV6fU3znTJuSGscSeZq2C8YK6UhPG8XlLmiZ5magjn04AFBMl6oX2o4Bxjz5oVhc4gwTWD7mLYxEgwj7JZdMdzW/Lntz3AnIBCyOtRamLMaJ9jqbeYNwAU7PvHM9IYAlRi0jNOFGT/Fv5F+mF0HkNQQvX6oFjEw/IRQfZarApm4rTHQ8dms8kGknNhajod8NbHV1uvypM/NItEJ3Pbqn9Hg0amW9pmvaMdEx0OH9uBpBowcLpTKazBsm17zlNe/yrfQ/KUfHDNGaO0hE+uhDln/otzGbXxKKfUKchXYihJ9Rp4TvF8JrZMpXHQchBA313wOiowQLZSeshMTUOmPLz7VDtmKDRfznC6Ey4gR6TlI55F/D6rVVVKplvTeFn33oBYWLog1DzJsoIJBagmLqm3auI5HIPKNxVrd18PArJa1IHb9HaFyibwI8xggLXEusdc33c757G5+8xWvmaoFYcqsW00Mb1G3xL3Y93uaPqDuNk/8VyDH+ESyY0M+rapGl7VhvydA= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7b4aa971-32e1-4ca9-f128-08db0562184e X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Feb 2023 21:11:47.6911 (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: 7mtItzXDnx1AjQPVcwoMGf00bzH9zsYFHjkiIdPw1CGXlGhFK0L1Ml1qp+yERQ6iCTsvAqp+uCjk+L+3hKzYShN5VxN6BEtqm1iB1+HC3jfA/CoKMK/tNey1yzWVqQjI X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR01MB4801 Received-SPF: pass client-ip=2a01:111:f400:7e8a::70e; envelope-from=aaron@os.amperecomputing.com; helo=NAM10-BN7-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 9be59163ff..a9420bae67 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); } }