From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372408; cv=pass; d=zohomail.com; s=zohoarc; b=HUDt8gT/+rSX6aW1D01CO03JTxja01zVsaNMuSU7i4SwNJcZNxdXx08dVAxYHhJm2FTQ5wWhMWLSukSmzA0VdmCoRwI5ftp8bIWd1uzRpCuJvXmByieQ1w7mufO37s2eqVuz6T9yz1vke4ASw9t1uwQYSwX+j0Hsqsl69C78dnQ= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372408; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2ggVSG398l48Y0MR9RvG3WggSRZvJsguuq5RUbquXF8=; b=IGi6igkrN82UFvP3vslw6yh/Y8273bIWdhZ9unBH7mw9ZPO16CnCTeqoQ7v1ctvpp0xDm61Rp1ZsUtUBeSmJ6I5gey4t5ik0p9ej/c8CTcdPY7+qMUWE95FKWunnUPlUkjNJS7eYCqabeD5Ir7Uj5TBfhpjeQDY/mdPa3k/74Dk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167537240813642.702280953563445; Thu, 2 Feb 2023 13:13:28 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?0THVEoJM4vpi6uGOtsSiS9AYd3nFYK//Yg9M/R9/lsWd/CcCHRQLpmH8gaKU?= =?us-ascii?Q?ZCwEgYscyLw3Db4pMgt5s0SzlMQF+t4xFsN4t4HxbPmITTlY9YHhbAmAMUDo?= =?us-ascii?Q?1wiPHBXVRHlPp6QLik7EzSzSAVDAyXotweH224cySD/O8BZ22Q0zUFgmT5RF?= =?us-ascii?Q?ofjRcvR7Z10f7ou9Zo867l2LuOqqmYjIsen8spV4LyjNxlrlvL0wnN/B+3ur?= =?us-ascii?Q?idnbk5VOmH8gEFQ8kXu5ik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us-ascii?Q?mBxL8oDla8+nYFqKZQjDKkfGBuzMPeYt8RIc9N2fhkQwYb3zko1v6h93oL+G?= =?us-ascii?Q?IkfdIqhYSyLssVv7mdfRieU2Bclkq5Hzsuxun5NRWTPAfFrdTOVkM/9Z4340?= =?us-ascii?Q?VdSEbHPpACQ4BciE66aTb0IIOKspnHqU+o7paPVwC+59GFkmcsHAoardFUVS?= =?us-ascii?Q?F2OCWzqoymolXcPmyDiCpqTOPIF3Ecadi5tVbEFy2sm4e3rr9BWPJPVGanQn?= =?us-ascii?Q?EFYQ1BFEDk/myCEaeRN2YWkD6BlF6GpFOc1y3YVtGDgfbxhwIuQ8ePtK4HGK?= =?us-ascii?Q?TBDt2u1abribWQKy3jeN3e2TkZXAuXCA5ubHNYxHObMXf8HfRxUuskTTt4E9?= =?us-ascii?Q?4k9fmJ/f8XpTLMIMk+cbLQtC4Yc42/WfOll7qB1xwpz1YpE9lM5IH9qtZ/kV?= =?us-ascii?Q?p9qa/jWOLK8B4cEqV9yR6g+9ui9hkYXJyFM73UK/AopBTjqcQ9279R3cn1s2?= =?us-ascii?Q?bcBF8nhvEd3oLDTU8DPXvAg=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372409805100002 Content-Type: text/plain; charset="utf-8" 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 AR= MISARegisters *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))) !=3D 0; + FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) !=3D 0 || + (id->id_aa64isar2 & + (FIELD_DP64(0, ID_AA64ISAR2, APA3, 0xf) | + FIELD_DP64(0, ID_AA64ISAR2, GPA3, 0xf))) !=3D 0; } =20 -static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +static inline bool isar_feature_aa64_pauth_arch_qarma5(const ARMISARegiste= rs *id) { /* - * Return true if pauth is enabled with the architected QARMA algorith= m. + * Return true if pauth is enabled with the architected QARMA5 algorit= hm. * QEMU will always set APA+GPA to the same value. */ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) !=3D 0; } =20 +static inline bool isar_feature_aa64_pauth_arch_qarma3(const ARMISARegiste= rs *id) +{ + /* + * Return true if pauth is enabled with the architected QARMA3 algorit= hm. + * QEMU will always set APA3+GPA3 to the same value. + */ + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) !=3D 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 ARMISARegister= s *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) =3D=3D 0b0010; +} + +static inline bool isar_feature_aa64_fpac_combine(const ARMISARegisters *i= d) +{ + return isar_feature_pauth_get_features(id) =3D=3D 0b0101; +} + +static inline bool isar_feature_aa64_fpac(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) =3D=3D 0b0100 || + isar_feature_aa64_fpac_combine(id); +} + +static inline bool isar_feature_aa64_pauth2(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) =3D=3D 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) =3D=3D 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 =3D PL1_R, .type =3D ARM_CP_CONST, .accessfn =3D access_aa64_tid3, .resetvalue =3D cpu->isar.id_aa64isar1 }, - { .name =3D "ID_AA64ISAR2_EL1_RESERVED", .state =3D ARM_CP_STA= TE_AA64, + { .name =3D "ID_AA64ISAR2_EL1", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 6, .opc2 =3D = 2, .access =3D PL1_R, .type =3D ARM_CP_CONST, .accessfn =3D access_aa64_tid3, - .resetvalue =3D 0 }, + .resetvalue =3D cpu->isar.id_aa64isar2 }, { .name =3D "ID_AA64ISAR3_EL1_RESERVED", .state =3D ARM_CP_STA= TE_AA64, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 6, .opc2 =3D = 3, .access =3D PL1_R, .type =3D 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); } --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372391; cv=pass; d=zohomail.com; s=zohoarc; b=dAd/3iMgoH5AWaQ5jHkbhSsR7J3+nR8d8fvI78AaUyHg8Xz7bVlmXVOS2BMA6TUX4lEtKvfcnIH+1sWDJuog6Jn6eE4pqNGCZ5vLj1GgqquuzKFMupIu4SHUBPnhlFQknGR7kyH/N1Usx2LaVDyVEZJpDscyHI7Bp4k9w0DIsT4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372391; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=an8pEp2vpzLK6xYyszENUQGGSGgCnVDVCGrWjKty7vs=; b=Eo3WmGte9q+2CiWdUTju5DD88LR5KzzDzZ6SWgOU6O5iPKDVQ4wvfwVjbj/ItjmoiT+4G0PLp19yY8c86cfPkvn1QCetFCBEpadK5tND06D81oCF7Le1abFg4gdqT9ypa6ovluzsi3nAqhZ/yH0L35TL3SqMQk4bUxD5iuy+3nQ= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675372391103216.65294490750648; Thu, 2 Feb 2023 13:13:11 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?9wAvj12D/cM/AhVEr1IxKSh7NmVz1KNv1/PlyEuUf89GCzzsrGybDa6054G2?= =?us-ascii?Q?R5LN5Kwq3QC7ZgLkBpkR3dbl6MGxbFt0Dp5QrPeANI3+bjInTZJGLuCEhv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dNUU4yv8loCc5exOqM1YFcZguJVWH9bBTxPR?= =?us-ascii?Q?dSLUAY7tS4ODjC0W9ApN5avAVThUog1FIQczNlg0FI3R5TZHmyqZNAJhHUav?= =?us-ascii?Q?5GsfgJRf5Jz4QT8aePW5ZyXC9/nf3wpgwHRf8tsa2KjdGaMjQ8gPfJQqHlKU?= =?us-ascii?Q?dExuXjJRbDd6oscn+3zh6AV5OJiev0/qX/23bbHmAIWZNiCPSogfJSTC6rjf?= =?us-ascii?Q?bsy1I/W328yPPJMJJeWgx5E992RTSsujAEtv9yrhK1v3b4wKUNSdWchm0HFu?= =?us-ascii?Q?FvIzOdBcQk7HLglhcuBVCEZbpTwh1Y9J9zWcn9KDvDulr8HQiErL4Khu+KqN?= =?us-ascii?Q?+wvdlFva9algkKiouquH3DtreSa62oChx7zIo4nbQIVBYurdHk0xnbuXlbkL?= =?us-ascii?Q?c6RZIvcgfZ3cKhKPxBb4SaM2c4I3pSkJ3DnXFxEEawTdPpGXKtPFfsSePlKV?= =?us-ascii?Q?NY0pui4AwFkN7Z950kzUIXtIA//RJGwpGC5GzktvwaN9g1jKNOgVqo36RDts?= =?us-ascii?Q?Yn7998SnaxR0uAIK1sP3bf5LKQjvMZ4N6ubsguWEPENhWm0OGmNZmQrOx2ZG?= =?us-ascii?Q?pzEA3H44kOoc761hmLlMCP9bUzgIBOFqPDuYu6QibINJPzEQtBxgc4li8pp5?= =?us-ascii?Q?aPItIQUYTMmf2nWeMVO/8+U=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372391649100002 Content-Type: text/plain; charset="utf-8" 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; } =20 +static uint64_t pac_sub1(uint64_t i) +{ + static const uint8_t sub1[16] =3D { + 0xa, 0xd, 0xe, 0x6, 0xf, 0x7, 0x3, 0x5, + 0x9, 0x8, 0x0, 0xc, 0xb, 0x1, 0x2, 0x4, + }; + uint64_t o =3D 0; + int b; + + for (b =3D 0; b < 64; b +=3D 4) { + o |=3D (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] =3D { @@ -209,7 +224,7 @@ static uint64_t tweak_inv_shuffle(uint64_t i) } =20 static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modif= ier, - ARMPACKey key) + ARMPACKey key, bool isqarma3) { static const uint64_t RC[5] =3D { 0x0000000000000000ull, @@ -219,6 +234,7 @@ static uint64_t pauth_computepac_architected(uint64_t d= ata, uint64_t modifier, 0x452821E638D01377ull, }; const uint64_t alpha =3D 0xC0AC29B7C97C50DDull; + int iterations =3D 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 d= ata, uint64_t modifier, runningmod =3D modifier; workingval =3D data ^ key0; =20 - for (i =3D 0; i <=3D 4; ++i) { + for (i =3D 0; i <=3D iterations; ++i) { roundkey =3D key1 ^ runningmod; workingval ^=3D roundkey; workingval ^=3D RC[i]; @@ -239,32 +255,44 @@ static uint64_t pauth_computepac_architected(uint64_t= data, uint64_t modifier, workingval =3D pac_cell_shuffle(workingval); workingval =3D pac_mult(workingval); } - workingval =3D pac_sub(workingval); + if (isqarma3) + workingval =3D pac_sub1(workingval); + else + workingval =3D pac_sub(workingval); runningmod =3D tweak_shuffle(runningmod); } roundkey =3D modk0 ^ runningmod; workingval ^=3D roundkey; workingval =3D pac_cell_shuffle(workingval); workingval =3D pac_mult(workingval); - workingval =3D pac_sub(workingval); + if (isqarma3) + workingval =3D pac_sub1(workingval); + else + workingval =3D pac_sub(workingval); workingval =3D pac_cell_shuffle(workingval); workingval =3D pac_mult(workingval); workingval ^=3D key1; workingval =3D pac_cell_inv_shuffle(workingval); - workingval =3D pac_inv_sub(workingval); + if (isqarma3) + workingval =3D pac_sub1(workingval); + else + workingval =3D pac_inv_sub(workingval); workingval =3D pac_mult(workingval); workingval =3D pac_cell_inv_shuffle(workingval); workingval ^=3D key0; workingval ^=3D runningmod; - for (i =3D 0; i <=3D 4; ++i) { - workingval =3D pac_inv_sub(workingval); - if (i < 4) { + for (i =3D 0; i <=3D iterations; ++i) { + if (isqarma3) + workingval =3D pac_sub1(workingval); + else + workingval =3D pac_inv_sub(workingval); + if (i < iterations) { workingval =3D pac_mult(workingval); workingval =3D pac_cell_inv_shuffle(workingval); } runningmod =3D tweak_inv_shuffle(runningmod); roundkey =3D key1 ^ runningmod; - workingval ^=3D RC[4 - i]; + workingval ^=3D RC[iterations - i]; workingval ^=3D roundkey; workingval ^=3D alpha; } @@ -284,6 +312,8 @@ static uint64_t pauth_computepac(CPUARMState *env, uint= 64_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); } --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372349; cv=pass; d=zohomail.com; s=zohoarc; b=mmPuYujI+fE9vIL2cnkmLWtXYaGujmj9tLKUbxAIBmWWAq4bVv02a2H2kujzUA3xfP1nZGEJsj0hJZgGrN66cPOZZxaATe5RkjEaEswYNPW6zqRgxrXftbJYmkH86UFDLClC9CXJ8W0znZmnU3beTOjJ8YXmjUXSOXep+GM0hdE= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lbUbO5AHMuk24EecXxY2t28R3f0zDqCkEQ8AmX/pscA=; b=KM4T8S3XjdLGW6PwfOfx8h35JfLNFHxo3RpHMwLvafOLP6KYaUmHgKqpOqDFLIF3HhEYsl+uUtH66vswlPZNrIJ2iLua8Z4O9TKb3FWlorSZgZvyO3JC/kAYCnAXatW5BordCmAC7u+8dFBNR2UsDvbewx50dw202k1Q/Mj0AoU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675372349610157.90819216740533; Thu, 2 Feb 2023 13:12:29 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?xjkXRaUTjVF4Sroqjg8aR0VpSMt+2Z6ybog0LiPHXRDuyD9yXATvqd4beBWq?= =?us-ascii?Q?apptV9dSsjm0kjnQWS5OQUQoigK+BkBe8OIHPMxeLhOs2uRzU8Zk56tPns3G?= =?us-ascii?Q?vdoNDd+JGlFw6ORCekI9e/SavTjOm5QNKZ0PvELYJEM5vFwpz7GxXPorgY7S?= =?us-ascii?Q?vz3EXzsHAuHELOTM0dk9n6gMIVZxmDpk9ZkWSHyuj4tuChGaL6s26A0WFEac?= =?us-ascii?Q?tGv6Z4NgvuImvwb5slXBGaFtuOC6PM7UUIQhGEc3MsnpwUNyRwlvR9OP8J+V?= =?us-ascii?Q?XzItePYlttCRzh+HuzMHvDi8cyKToDisxwFICRzE7YAx4Zbf2Rx3afMf/B+k?= =?us-ascii?Q?KyuloFCWz2cTOCgC46qo1bjozJG/GTysUuYvjj56DqpJEpYVhushzEItu9Kc?= =?us-ascii?Q?z00fax1xWyJwq3x5F21JYyljXCqwy2bG2PiuCCxbS4byFRYrJJwHJKf/DJ+4?= =?us-ascii?Q?tkOhN5+aFbhhlMTrvV1UWmwMxiJFQnOS73YIGM0KePMe587dCVUPRj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HrJv6fZi5jYIhdvlCo54j+ekiQ2rh4XXGKI?= =?us-ascii?Q?tPWwrWO6+qSo3QAAmQ0HzV6H6VPngkjjBQsdAgt8lKOW9EdMmyVabA7vQAqd?= =?us-ascii?Q?GNGmEEdabemvVbZwjoCvkSdC3xvyfgBTuxJAEXl8P2V8yqUpcUUWyATN2heC?= =?us-ascii?Q?HqNj2HY9MRzvG0SZ+rC1Z7XwJTkrT6hKgkx7ve43mclMxp0aDCFpoQDbFSML?= =?us-ascii?Q?zXXMxsJjzovyYfyuQV0RK3Q=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372351807100001 Content-Type: text/plain; charset="utf-8" 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 =3D sextract64(ptr, bot_bit, top_bit - bot_bit); if (test !=3D 0 && test !=3D -1) { - /* - * Note that our top_bit is one greater than the pseudocode's - * version, hence "- 2" here. - */ - pac ^=3D MAKE_64BIT_MASK(top_bit - 2, 1); + if (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { + pac =3D 0; + } else { + /* + * Note that our top_bit is one greater than the pseudocode's + * version, hence "- 2" here. + */ + pac ^=3D MAKE_64BIT_MASK(top_bit - 2, 1); + } } =20 /* --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372402; cv=pass; d=zohomail.com; s=zohoarc; b=TrN8rjWvWZuhHdOySOeDO8J0pwYD2+GHAVfWjo+OxF/04ljK/8EmBCXnAkmJvOeiARDPkSTVkhoWVgFwP7RUwDWRAo/mZgCVorRprMKNJRiMfiI7t3fpeztJEkAHNDN4f3oJKs3fPZzcxbZahRuKDlvQG/+TxZXWx1MF/sC3Jqk= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372402; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=IuuPrACkW/zAW9ecEcQCjhaI5IhAKFH6ymGl93xiiuE=; b=OhTQxP3Jx5+fFRqsypOL6F+wxPJTd89uG0nV/1AGB4k5ImidltH92KIBs/FtIxrnarVZVU9vjOeRHUFvoP1f1Lc0izHMw9pM5xpGAft0lrPPCXg1tQHA0qwOgR5fPo3MLT9DbYWxoqkYHWXP07suwHqM2sttI3H9ofE1KWF3ygk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675372402531476.4511537455587; Thu, 2 Feb 2023 13:13:22 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?pLlT3/Tz4WJqsCJoWqscH4kYJmSjhjkZizLV3V0PjbMmdCm24zSAOgqctNLp?= =?us-ascii?Q?wMmTFOO8JnDDjEaktouf9fxUOlvNhZobPmROxGRGz7YndDRS97t9HpYvXkx6?= =?us-ascii?Q?1l2r5EZptWSd6YnEUqXY8HdQFMGObKiR1k+vo/LDYNdDFojlG+TwE33TJ4a0?= =?us-ascii?Q?eha6wL/Cmx7zuqcpj44OcumaeRRyGIH84fPglO3aRQDO3BOExSb5bbjWDsdT?= =?us-ascii?Q?SwIjKQFjUlrdD403IexJ4ofyVpJMv9vrCVtqfx28fOHe+Qww16hYXTp+dXI0?= =?us-ascii?Q?9zeLAqpK7nh+5mURiq3htyocfxpBVoHHxT7YLdvHaEKZ8cMvFTFJ7P53/J9Q?= =?us-ascii?Q?w3ILIDMBT9c4D3BDpwj1mt/+qyHR2rkayF0A5oYMmIp5h5xwdAkWxoic4DvO?= =?us-ascii?Q?mSeBrVsBrlMfPZSJqiB+ElVjEeedHHtY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Q?/z80BecvZKnazqeot7oqij6hSE8XVSNYhsQzP86AegmoqbgLVbl4A5bWsctR?= =?us-ascii?Q?QrTLLugxFuVCurF6AdagPP2diKj0LRfMj3ztpvrF0fQ+LWCNsEE4pE3bYICv?= =?us-ascii?Q?5/eJvdEyhrB+S6gUFRmwPSTFQoZPzv+O0Ox0nTp6haPuQCOHJXAu1DRLy1X5?= =?us-ascii?Q?w7bywV0kSNtumUqAuVKaau0pWkC/62pC/O/iVKmj51+M6BkIkXLqAVLTWBh9?= =?us-ascii?Q?jvH4FfoKHbPJfeVhEtuerNq0zj/4NfxR7w+oyCaSxRLp4mSiQveQ6yNIbanS?= =?us-ascii?Q?M8/oYwzW4fj/erjNsBKK3Yw=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372403674100001 Content-Type: text/plain; charset="utf-8" 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 !=3D 0 && test !=3D -1) { if (cpu_isar_feature(aa64_pauth_epac, env_archcpu(env))) { pac =3D 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 ^=3D ptr; if (param.tbi) { ptr &=3D ~MAKE_64BIT_MASK(bot_bit, 55 - bot_bit + 1); pac &=3D 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 =3D arm_stage1_mmu_idx(env); ARMVAParameters param =3D 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; =20 orig_ptr =3D pauth_original_ptr(ptr, param); pac =3D pauth_computepac(env, orig_ptr, modifier, *key); bot_bit =3D 64 - param.tsz; top_bit =3D 64 - 8 * param.tbi; =20 - test =3D (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); - if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { - int error_code =3D (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 =3D MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit += 1) & + ~MAKE_64BIT_MASK(55, 1); + result =3D ((ptr ^ pac) & xor_mask) | (ptr & ~xor_mask); + } else { + test =3D (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); + if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { + int error_code =3D (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 =3D orig_ptr; } - return orig_ptr; + return result; } =20 static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372366; cv=pass; d=zohomail.com; s=zohoarc; b=A38OlhaJglP8/FP2cJJVLcqcNoR2LbFClxiUuaSrD4b4ssuaFHl16VtCw/KFc06sU1IHNJ5XWWnU43N5BoNT5aA/KPYh9HC8aE8DeY1EOZPHbK5VJ6GIftcQsQPlQx1zZJfEFNiOI1368earhLuvCnuUi4EsALngO8pIGSwizhc= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372366; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6B86tQD3qVQQPFg/8XUpVsvrGJOptPopLAp9dyUwUHc=; b=nke75/Gj32u4DXve/y4gRJyq5NNUlfLWCQBTYP9zFyZPMFXUE1wMPl6J7m3JHwV1SGBUj8jqIlUNSRMRKN0iDJeiCx497Qo+MiwC4ajA/ojURaYZ8Tvi/DvrMXM6hlb9VOUSQNQeQp4GQeMZY+T0vqQ1QZmUZIxRBeI7dgLK4dk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675372366520339.8012069320737; Thu, 2 Feb 2023 13:12:46 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?A/hWqnjo1GZfT/JcnjFxjDyCvkU5lbrX4wQgL3GnAw1t7J9s7Mueg13xCHck?= =?us-ascii?Q?IhoAw7SfKO0d55SFnpCDKXNhRl/5Dk1K8p1bFfCo4YJ83fzR/xOMqE5FMVTn?= =?us-ascii?Q?rU6w+ozxVTie+AGLEbevJrYv4YHjwAK3kEpclRZOCX23hssmF1Soxzqdjw4v?= =?us-ascii?Q?wCoXZA0d9kb57PZC/rWMG+4qM+pK52o0QfD8Ql02jPJVAlOu5leHAjjeLuFi?= =?us-ascii?Q?LAAtCcBJ2ikvLC9PqOt/553upaufPHsvlgWmvNtjRZfooU4H9uwPmetDnyDV?= =?us-ascii?Q?sBiyX3CL9VZRrOYtTcZuOU4CbfLpThq2Mc/OWn+0WiqT6HNiK4BxuhlWhKGd?= =?us-ascii?Q?dBTauw0YRlmau5hGIcPg4uiZgn7hcmg4Z9kUeNNBLVYWHrztNu5wMSE97Jwt?= =?us-ascii?Q?H3QPteYJuU8KBYh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Tlg3PjPWD5h6KhjshFg6YfYYIHnhzcUgLE9cW9wOy+73ZwJ8ZJkyWPCQqn6P?= =?us-ascii?Q?OSZfyoSjEPpcQb+YTtBpx3R5QZJL/aDfu2KClK+uAXWkESJwLo6jWHiExQSJ?= =?us-ascii?Q?q/26KwNEVdIyaCp0o2RaC8j3kNlHOCR224GR79p8B8KAYyktBRGUcIznpk5n?= =?us-ascii?Q?5/KyMJrSSFRBbxiM4blbt8CnCQjQH8WmvgapOTcoMTfdLNcPEFg1Doz/cy3R?= =?us-ascii?Q?yk/OKr0mpMMOUkcctKTN/zkh7cSTqFQ1Fo67OJy2GxqPDjCBeS6cOAT9AdQD?= =?us-ascii?Q?FSY1B5aOjLaHo1Ud4zGsTS0=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372367627100002 Content-Type: text/plain; charset="utf-8" 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) =20 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, ARMVAP= arameters param) } =20 static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifi= er, - ARMPACKey *key, bool data, int keynumber) + ARMPACKey *key, bool data, int keynumber, + bool is_combined) { ARMMMUIdx mmu_idx =3D arm_stage1_mmu_idx(env); ARMVAParameters param =3D 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; } =20 -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 =3D 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); } =20 -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 =3D 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); } =20 -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 =3D 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); } =20 -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 =3D 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); } =20 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, uint3= 2_t insn) if (s->pauth_active) { dst =3D new_tmp_a64(s); if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifie= r); + gen_helper_autia_combined(dst, cpu_env, cpu_reg(s, rn)= , modifier); } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifie= r); + gen_helper_autib_combined(dst, cpu_env, cpu_reg(s, rn)= , modifier); } } else { dst =3D cpu_reg(s, rn); @@ -2356,9 +2356,9 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) dst =3D new_tmp_a64(s); modifier =3D cpu_reg_sp(s, op4); if (op3 =3D=3D 2) { - gen_helper_autia(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autia_combined(dst, cpu_env, cpu_reg(s, rn), mo= difier); } else { - gen_helper_autib(dst, cpu_env, cpu_reg(s, rn), modifier); + gen_helper_autib_combined(dst, cpu_env, cpu_reg(s, rn), mo= difier); } } else { dst =3D cpu_reg(s, rn); @@ -2404,9 +2404,9 @@ static void disas_uncond_b_reg(DisasContext *s, uint3= 2_t insn) if (s->pauth_active) { modifier =3D cpu_X[31]; if (op3 =3D=3D 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, =20 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)); } } =20 --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372414; cv=pass; d=zohomail.com; s=zohoarc; b=I4llwTYZdvZGCyc0FafGt8wixdjcny5xdDoUKnr+pwAn8Ub2bIYDAkSWzsw2ITuJ2LPzv4GUlxJJgXHOktvD7D95WzoUkY6Qf43ptF6W0N8T2k1IcLgGsvdEvYQVi8vSQkUPVmwyL14L4E8BrM2wfxz4+WZrnTf5QkNZzLxNIXg= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372414; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=G8Jib0CT16EgJgspn4kyp8jbFpu5y6fJmeqI7MTZH9A=; b=aB/j8PbDaAGtdilggdgiG8+w8u/DYi43noRXECblrSx6lrasHgppTkA7sykq7NAUo99qEIe3RRs3QGmnxRWOixOm0eeYCM29VN2+Zs0rbq8Nujxpx/MOWj9T3dlgdWgzXbLWbjuLSEQ2pqZOHj98p+qulBXBdTrgNQ4eK9UrqMY= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16753724144072.9842067760846476; Thu, 2 Feb 2023 13:13:34 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?ARvyoRyECC9yqwPEmNJ5pkOdWNsAawHltBV9tWa0yyWcINBAKB5pmHGBimHB?= =?us-ascii?Q?VA4j5zsIvumc3792o6R5X5sr4A1x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3X2O?= =?us-ascii?Q?bXJq/VoqW0aobdGGY2Q3+uP6JMV9XLqfyaqNDDa8zW4bTqn1SlVtkFmgFsig?= =?us-ascii?Q?nDcjdBIJ7pbgDOoaccSIm6o5lvFylHWZEFm1s5vXDjRAL8wgPT5TdVu2+3Dy?= =?us-ascii?Q?HSqknNEgUDENaQEJfX28cifWjsmCdCjS9sRbihsVZQAdoM7Tqq8y1pDk3GPI?= =?us-ascii?Q?+Dd0yN9UTpTyO7NrdViR7dLceam0cH8zAegEVD0MxRMHYf7+ZRAYHLWdNS4/?= =?us-ascii?Q?8BWLtTX2QRoSOo5SQ59vl7zomXU+dtxAneTLAImkV0a55PVm8lYsMgR+eeHf?= =?us-ascii?Q?OqcLpS13BrqMj+7+6nZbdsDdzO7is1MxzDEcMladdiRwWMTHtRWv8V3Prvln?= =?us-ascii?Q?yD88cwlczDaNMgoyRsEGJnUjV7gpYbURuJSltnuW9pAcbWU49FoVdrSM3OgP?= =?us-ascii?Q?m+z3hkA8oS4zP5wMvzyWO/8F1/ZiUE0FgOjjkgxfH4qpKyP9twTxSqo37faB?= =?us-ascii?Q?l+i5e40oCUxZpUWm+27Z2KmxhGZ+8LyFrMt0kCOSz2kl3LAix6ymvx77Y7BD?= =?us-ascii?Q?PehKKxdNuY3YWAXrSab+rNTarpFm9zD3Wkydm3UPvGJsWe84tNUEs2OBB9M1?= =?us-ascii?Q?joUGbjwdfsOw/HT7eKvk08jzqhw4mu6nJBaxFZCjmxx6KMFIETwDsen3arOK?= =?us-ascii?Q?bRDfZAlqLFIAm93jI56DdaY=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372415750100001 Content-Type: text/plain; charset="utf-8" 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, ARMVA= Parameters param) return deposit64(ptr, bot_pac_bit, top_pac_bit - bot_pac_bit, extfield= ); } =20 +static G_NORETURN +void pauth_fail_exception(CPUARMState *env, int error_code) +{ + int target_el =3D arm_current_el(env); + if (target_el =3D=3D 0) { + uint64_t hcr =3D arm_hcr_el2_eff(env); + if (arm_is_el2_enabled(env) && (hcr & HCR_TGE)) + target_el =3D 2; + else + target_el =3D 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 modifi= er, 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 =3D MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit += 1) & ~MAKE_64BIT_MASK(55, 1); result =3D ((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 =3D param.tbi ? 55 : 64; + uint64_t fpac_mask =3D MAKE_64BIT_MASK(bot_bit, fpac_top - bot= _bit); + test =3D (result ^ sextract64(result, 55, 1)) & fpac_mask; + if (unlikely(test)) { + int error_code =3D ((data ? 1 : 0) << 1) | (keynumber); + pauth_fail_exception(env, error_code); + } + } } else { test =3D (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 =3D 0x17, EC_SYSTEMREGISTERTRAP =3D 0x18, EC_SVEACCESSTRAP =3D 0x19, + EC_PACFAIL =3D 0x1c, EC_SMETRAP =3D 0x1d, EC_INSNABORT =3D 0x20, EC_INSNABORT_SAME_EL =3D 0x21, @@ -221,6 +222,11 @@ static inline uint32_t syn_smetrap(SMEExceptionType et= ype, bool is_16bit) | (is_16bit ? 0 : ARM_EL_IL) | etype; } =20 +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; --=20 2.25.1 From nobody Sat Apr 20 09:43:08 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass(p=quarantine dis=none) header.from=os.amperecomputing.com ARC-Seal: i=2; a=rsa-sha256; t=1675372349; cv=pass; d=zohomail.com; s=zohoarc; b=VDAyKpuiuD1DaMAOb6UrLcjFncL3S97B4ZTbgONeMMmwYK+XDyJzoE7Xi/9JdtCkBPWkmiwUz1MGITbMCrtrCjaBATdn0WvXi3Vz0M8FQ3NJLNzV6ZIaVC2PaSKP4JaxPO/7IfQz40bPTaFp21CzNTnPKkj8lCGfBNrX7RybQwI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1675372349; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=38m9nYlQ+DAi8DkbGdDAwPqVFQp4+eGNP1ABUGvoewM=; b=Xr+BDp7FBIrhODdvYkXXUg510llh7oilBrQoIBxyqzBJWF6HdR3RoyeZvCYog9+QmMKuUZB8arL1uY1PtLDXK8YZ/siviC1CV3+76pSspDDNfHjvMK7R+PVm8V8UcOXeH0HtyMIuOgKQWMpXL3i2acN6nlZTTxDynUHXvO7ynY0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=os.amperecomputing.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1675372349867472.48741235781597; Thu, 2 Feb 2023 13:12:29 -0800 (PST) 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 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 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; From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?UTF-8?q?Alex=20Benn=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> Content-Transfer-Encoding: quoted-printable 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: =?us-ascii?Q?MrPnDXp1x1o/T+Pdq3kLftzjIfRfWVdUw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ag/K/q6RdVVVPT+pgCQ2E7OPKK4KhcbfhFHCUyI1IFQdxBKiF8CUTNBW0gfo?= =?us-ascii?Q?eNM9BgzqJMArEI/9muZbEwVVi/yyNOgVyKdpL3z4L2tFJEFk6lHDJQi3qRjn?= =?us-ascii?Q?zc8xYtdM3onbjEm3xX1pfeMPVVkadTceh6ff4GxnRnIvBCYVKtuFxmj6OQni?= =?us-ascii?Q?td9Dlt97uZfIrdD46vwf3lUO0d2Kes4dulQjYKCmAx4sGV6fU3znTJuSGscS?= =?us-ascii?Q?eZq2C8YK6UhPG8XlLmiZ5magjn04AFBMl6oX2o4Bxjz5oVhc4gwTWD7mLYxE?= =?us-ascii?Q?gwj7JZdMdzW/Lntz3AnIBCyOtRamLMaJ9jqbeYNwAU7PvHM9IYAlRi0jNOFG?= =?us-ascii?Q?T/Fv5F+mF0HkNQQvX6oFjEw/IRQfZarApm4rTHQ8dms8kGknNhajod8NbHV1?= =?us-ascii?Q?uvypM/NItEJ3Pbqn9Hg0amW9pmvaMdEx0OH9uBpBowcLpTKazBsm17zlNe/y?= =?us-ascii?Q?rfQ/KUfHDNGaO0hE+uhDln/otzGbXxKKfUKchXYihJ9Rp4TvF8JrZMpXHQch?= =?us-ascii?Q?BA313wOiowQLZSeshMTUOmPLz7VDtmKDRfznC6Ey4gR6TlI55F/D6rVVVKpl?= =?us-ascii?Q?vTeFn33oBYWLog1DzJsoIJBagmLqm3auI5HIPKNxVrd18PArJa1IHb9HaFyi?= =?us-ascii?Q?bwI8xggLXEusdc33c757G5+8xWvmaoFYcqsW00Mb1G3xL3Y93uaPqDuNk/8V?= =?us-ascii?Q?yDH+ESyY0M+rapGl7VhvydA=3D?= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @os.amperecomputing.com) X-ZM-MESSAGEID: 1675372351829100002 Content-Type: text/plain; charset="utf-8" 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; =20 /* 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) =20 void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { - int arch_val =3D 0, impdef_val =3D 0; - uint64_t t; + int address_auth =3D 0, generic_auth =3D 0; =20 /* 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; } =20 - /* 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 =3D 0b0101; + } else if (cpu->prop_pauth_fpac) { + address_auth =3D 0b0100; + } else if (cpu->prop_pauth2) { + address_auth =3D 0b0011; + } else if (cpu->prop_pauth_epac) { + address_auth =3D 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 cipher= s"); + return; + } + + if (address_auth =3D=3D 0) + address_auth =3D 0b0001; + generic_auth =3D 1; + if (cpu->prop_pauth_impdef) { - impdef_val =3D 1; + t =3D cpu->isar.id_aa64isar1; + t =3D FIELD_DP64(t, ID_AA64ISAR1, API, address_auth); + t =3D FIELD_DP64(t, ID_AA64ISAR1, GPI, generic_auth); + cpu->isar.id_aa64isar1 =3D t; + } else if (cpu->prop_pauth_qarma3) { + t =3D cpu->isar.id_aa64isar2; + t =3D FIELD_DP64(t, ID_AA64ISAR2, APA3, address_auth); + t =3D FIELD_DP64(t, ID_AA64ISAR2, GPA3, generic_auth); + cpu->isar.id_aa64isar2 =3D t; } else { - arch_val =3D 1; + t =3D cpu->isar.id_aa64isar1; + t =3D FIELD_DP64(t, ID_AA64ISAR1, APA, address_auth); + t =3D FIELD_DP64(t, ID_AA64ISAR1, GPA, generic_auth); + cpu->isar.id_aa64isar1 =3D 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 witho= ut pauth"); + error_append_hint(errp, "Add pauth=3Don to the CPU property list.\= n"); + } else if (address_auth !=3D 0) { + error_setg(errp, "cannot enable any pauth* features without pauth"= ); error_append_hint(errp, "Add pauth=3Don to the CPU property list.\= n"); } - - t =3D cpu->isar.id_aa64isar1; - t =3D FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val); - t =3D FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val); - t =3D FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val); - t =3D FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val); - cpu->isar.id_aa64isar1 =3D t; } =20 static Property arm_cpu_pauth_property =3D DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true); static Property arm_cpu_pauth_impdef_property =3D DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); +static Property arm_cpu_pauth_qarma3_property =3D + DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false); +static Property arm_cpu_pauth_epac_property =3D + DEFINE_PROP_BOOL("pauth-epac", ARMCPU, prop_pauth_epac, false); +static Property arm_cpu_pauth2_property =3D + DEFINE_PROP_BOOL("pauth2", ARMCPU, prop_pauth2, false); +static Property arm_cpu_pauth_fpac_property =3D + DEFINE_PROP_BOOL("pauth-fpac", ARMCPU, prop_pauth_fpac, false); +static Property arm_cpu_pauth_fpac_combine_property =3D + DEFINE_PROP_BOOL("pauth-fpac-combine", ARMCPU, prop_pauth_fpac_combine= , false); =20 static void aarch64_add_pauth_properties(Object *obj) { @@ -646,6 +694,11 @@ static void aarch64_add_pauth_properties(Object *obj) cpu->prop_pauth =3D cpu_isar_feature(aa64_pauth, cpu); } else { qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_proper= ty); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_proper= ty); + 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); } } =20 --=20 2.25.1