From patchwork Fri Jun 9 17:23:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274231 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 00901C7EE45 for ; Fri, 9 Jun 2023 17:25:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqL-0006za-04; Fri, 09 Jun 2023 13:24:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqG-0006yJ-Ib; Fri, 09 Jun 2023 13:24:04 -0400 Received: from mail-bn8nam12on20703.outbound.protection.outlook.com ([2a01:111:f400:fe5b::703] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqE-0004mw-VH; Fri, 09 Jun 2023 13:24:04 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=evDJpxaUsn1OHKHax6zBK1cJ84bwP3Mj/X/wC3ec4YJjZKJSch16ygiCarFkYLXBRr7sRCV0/ZOqLpsLSSdvfVs9jRo6lHEUW1z2n7RVw+hecnBNLwkbGxIrOo7vKrTK9R6cACPoL/vlRIavDtVb+xHW7yamIyOiukDnIn9YR80+pViyvnQvYKWzijetoGIkGX7qobv3501jW6YII6HU+C0H85KToS+/gAACm6s3tYz31E/SMklPjx6UVlv4yOszp6ansvIqdtKp1jP2odYY0JRVLpnh9MvVzYSM0zVtM/EiWQoKegy/DMEOqM+PDvcMdwyUaJWcF8Yd2I1ve4hphw== 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=u5O0U2P+y5TeFeDFmULhjEX93KahaFs/lwrUMg4Yx28=; b=Xfn6TaiktibldD12M0fEzAAHp+6+KGHcmFS5pc9p19xc7NXs1qtQgDxdYrbzTceeq6SZl+splbnlIVXi6vdh9Sgq6HgOX9RmAoNqeE8283xfFgB2C4gBNbF8pd6JPz/57iL13gSOE6k4modm74/LMRKBZg0pil4SaVrO7KXzsrUNzlnSG8L2EoT3nZyHeQM1/CX5EBnPwLkkivBzsmplif0xSiziJml3ZBmoL9wCgcPqqgrNt5Fk67K7YiPTBBGZ7+xF/gGOog3ucnz43J4MEkz8jU6Fk9wHNkwzJDsus9qZ3F4sl02DiQBv2p8GF2s0Rs5R60zG4F3ZHPLvQ7XHvQ== 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=u5O0U2P+y5TeFeDFmULhjEX93KahaFs/lwrUMg4Yx28=; b=MAUi1dpUTCGZw28Zjrb+ggFZBeUtqV+uVN7Q202pZ/DS1xYrj/RRx5AUuj+HEfIHbkRDZeo5N/16zLJLaqb5nz63dQIS2Ugd+P7hV38eFdlwzls8vIZSQZKHgh45h85wJbmHYi/QzAKXvPfYnzNFvJSm/mfP0k5gWIfecY+5Iy8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8481.prod.exchangelabs.com (2603:10b6:a03:562::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Fri, 9 Jun 2023 17:23:51 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:51 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 1/8] target/arm: Add ID_AA64ISAR2_EL1 Date: Fri, 9 Jun 2023 13:23:17 -0400 Message-Id: <20230609172324.982888-2-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8481:EE_ X-MS-Office365-Filtering-Correlation-Id: cc3dbb7c-885b-483c-a05c-08db690e4b0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uZYaD/WcjYhDJ+mJnATGDShqfJ89vq8e6O2X87JlW99DuguvO0451M1e8u71CL+7OCXk5d6T0+pWDinMtSTaoT2SGiki0jQt3Yya/iBfRW82UamxJ/NGCLZZsPTFMh8USC49HwnFPwzoYvbKqn9TZWG1YhHVqsX24WrfUCZ8AoFSQcWLIofSYXwE3lsYd45o6spzRcUw/u4mEj27VDNwQrgkotu6f2KUp+plWFnjOuH3K87UqCccfmpRsd9sqXRrdDk1J27CXTYPZLXILVniRk3/E1gbUal5lbEbHUK/TYpUAQTucXZ89tJjIxtKUNyyC9kjbG5QXbr1tVjwP7ETIMjW03xvx1uiYP6+0xN58oSCnW1tYVdgSPx9iIhi6er/Ys8aJzZUFdelURiC34VFL1pdY7d3UFppLY9U7GAA46ylKQ+0kZ9ZKVFdb6zDJqMTtvfjgsWA5uIxcUHbWlIGqDXSIQUCk+/IbxB9EH8yTe1K3rwfsPfGGIl2+YDRzsuALsMcG6Qix8ZHZSdoFVGwwrlLS6CoCqpOoZ9nSE2QBZjfZQ/Fwk2EJLlqpHARGOluOlnOC5LoFasiyRADLhTrM9YllJG0Wr2cTJTIkXwJjKvMxbY//ZM6acXHoJ+gcqkS 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:(13230028)(4636009)(366004)(136003)(346002)(39850400004)(396003)(376002)(451199021)(2906002)(83380400001)(26005)(1076003)(6506007)(6512007)(478600001)(110136005)(107886003)(52116002)(6486002)(6666004)(8936002)(8676002)(41300700001)(5660300002)(2616005)(66946007)(66476007)(4326008)(66556008)(186003)(316002)(38100700002)(38350700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cRyTW02TTksbgHE62ysLiN1P7V54diDQfn3cJTnbhTnITPE/398Q6b9m7ecpOSyh2ncY6M9j9DesA2ZnAr6aR2W3JvNaS27RQCa46T5EYimJfF2RJAaqhiF68XNOL91TZMzs0EexcHNznohX1oKhfr/0utqxkV0VMEaxxlYblkYAyIEufHAWmoR+5PribqdmzFsnOMPJzaOXr/hj+UosGA/xck1QThabGOHW4+qrdgE9yJ/STAHW6Y4SyH+4UFkve7yhvfMsyN6CakG5ZmAWKbj5eZpnqWgVsd2KpB7UjsLQWCrdWb0tTzi6ecgtDI77+goghul32scxIl3qqWZvyRLw8WMm+pROzn+/hw2RFKYfmuT7bzreRP3/OaZ8DvlDAGwQopbwX7iVmxl58UJNVn8uqZV1ksl9WauY5Q1oGuQHBzXvMYJP/CSZ/pnr3BfhG8xiKGPwK2HOB3JGZ2YdhqfdZPbPXHbLfaHNZKGPMHVxDj0VjllWYhBcE9dZODb5Kvbvp6VVRa8D1grOQJEkPK69Eq3xJBHr41PGlR6bSLJYr2t8adkM43G/XM/IE0laKzVDtlUqijNnVjqQQlcjLWM7jnbYOTtd50gqYogvbazEngxCDzQ4dEfWmK18iWMTGrFq6b+Vt2jnXjvsak/0YRgsPUt0q4qqX4JY0ySa8QejGepVTGBNEiX4PxBFb9o0YfbUFmvz5PTJSscl6X173oD34kZv8umIAaMtStGDyaYwFt4lvPvwyBZWc7r/4uFAXiSyby2J4ZZCo4fwYdO4hAeWpYdmd17uz6vcLR9Pjrcv+sxWGHRbZ3lfHyWV5g0sHQ1dFAjCFcjII2x6GT3Dos78meliTYqAmlAIw2DOXsYNlxKCGtlVxJsEismCd3hqe8fK/sO/2ov/Tta8tQ+SQwfIOreUJhrRrQ+xj2+UoEpPMblPEwFkTkU9aUaPRn2kpKEZqGyo6zveKgX9uoJ97CT1fP+YNvDjBoUT+wq5Qi4mQ0qccAQDzW0MDlEyDaWrpgJBkhzwu9qFyTT6r0ioelrlMiLEJ3xnBXRW7ptilYnDtSnNj4ZRroGD3sXpwGGpkNaaYBG+pAPTAyCtC9sL4K4HXkhFgKsKD5o2GTQdkAj0Ra2MQMlu5aaccG+V2fL5kJNmRMK+zDqXrEMu398e0rOgKVPiA32y5mvCNF8QHTnkI8Big9238OOKZCT9gjPLdSvXIteI8sVebIYoHg+iWUbZUA+3IBu1ZwKxhjDhhzZFxgAPWba7IKoof1VTy/qs56WcDs/Cyg809WB0a9GGjP+v4WJ7sBaz0gL2NXAlCYfACdSohRlY+rNF7wvk8FvF1pi963tV2n47O/y8GU9KL5W9qpaDA8OTGA6W95z9sYmW4lh1g8SFOUDjNa0gwEXb0cLDNrv37XYup7DaI1cuKYqjOQqnNv8SbZNQ2y8D7T0LHCpjTT8feIItnlCIbe3NJOXlE4Lii8z2PahMk5yALnsmxqAtn7OPFslIJA4i8f3C3kxPNy3XNUXS/e8kC4+7V2Zjvei6He+3uZ2rbERu+mzky2GB82mNEWq9XJSWVwfpVDbAwLvfaBtCfeULtzhWDKmX6s20s6Gdu7JRbmSxQud1nJQSkeq90woTB3mT2eE= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cc3dbb7c-885b-483c-a05c-08db690e4b0a X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:51.3966 (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: eS8FbJCu6xd1i7sIR0qVWmpMz4PUt+Tq5j73lBpuJCwqpi/kI3ZAJUDXvqRHEd2uVrWuB7vUm4oEo38OiO09DBgkRBGxAWaqcDRWE8QmTsmCX8VgHP0SXe4OP+0s+V6Q X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8481 Received-SPF: pass client-ip=2a01:111:f400:fe5b::703; envelope-from=aaron@os.amperecomputing.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay --- target/arm/cpu.h | 1 + target/arm/helper.c | 4 ++-- target/arm/hvf/hvf.c | 1 + target/arm/kvm64.c | 2 ++ 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 36c608f0e6..df04c9a9ab 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1023,6 +1023,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; diff --git a/target/arm/helper.c b/target/arm/helper.c index d4bee43bd0..4ced2f71e5 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8204,11 +8204,11 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, .resetvalue = cpu->isar.id_aa64isar1 }, - { .name = "ID_AA64ISAR2_EL1_RESERVED", .state = ARM_CP_STATE_AA64, + { .name = "ID_AA64ISAR2_EL1", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 2, .access = PL1_R, .type = ARM_CP_CONST, .accessfn = access_aa64_tid3, - .resetvalue = 0 }, + .resetvalue = cpu->isar.id_aa64isar2 }, { .name = "ID_AA64ISAR3_EL1_RESERVED", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 6, .opc2 = 3, .access = PL1_R, .type = ARM_CP_CONST, diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8f72624586..bf567b24db 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -847,6 +847,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.id_aa64isar0 }, { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.id_aa64isar1 }, + { HV_SYS_REG_ID_AA64ISAR2_EL1, &host_isar.id_aa64isar2 }, { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 }, { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.id_aa64mmfr1 }, { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.id_aa64mmfr2 }, diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 94bbd9661f..e2d05d7fc0 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -306,6 +306,8 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) ARM64_SYS_REG(3, 0, 0, 6, 0)); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, ARM64_SYS_REG(3, 0, 0, 6, 1)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar2, + ARM64_SYS_REG(3, 0, 0, 6, 2)); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, ARM64_SYS_REG(3, 0, 0, 7, 0)); err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, From patchwork Fri Jun 9 17:23:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274234 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C9C02C7EE29 for ; Fri, 9 Jun 2023 17:25:34 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqd-00074W-CR; Fri, 09 Jun 2023 13:24:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqJ-0006zZ-Q2; Fri, 09 Jun 2023 13:24:08 -0400 Received: from mail-bn8nam12on20703.outbound.protection.outlook.com ([2a01:111:f400:fe5b::703] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqI-0004mw-4Y; Fri, 09 Jun 2023 13:24:07 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AAQCYmObKq3tkFaPueS1V1V14q7Pbe3bjEGZ4ZGbYuDLnNtvP5Xac4MtmlVIiNYg4j/HfSlloyx4WHDA9/IbBmcdeec0tfM9LaIy9sN+aB5NxvSuL99y39M6mfWTy21Jiqee6PfAORywyRLQ7Goa2eIvXFqfcREHQ0KdxMeCGvuSunJQDnmWwlD7JAgksfgysKWxi0JXRkRsoquwHGmciZkAXHXcnJfFOkxW/WxzkqOuoWkWZr+R7U5z41biwjrLGRZVLXH4LiY0PSCENjkAbsTyJ1sDwe/yGix1w0ZxzAESMHAfFtzecab9aRCWWgLzSoWjzzYTq0hq7bJjzkM6Bg== 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=xcJxsvx6FUu9stgirpLFuzIgGEys/dzaCRNKasjZZQo=; b=GIB+ynUIhLPU/uxHWhylIZ9QxT3aflicR5U2quYRts9T7YOvbKKh3s5LhOZJS6i2CjLPZfgntik0TZ4VHf5qC2oDrso9wi5rX49A/iwW/+IVwaIwTylc4TplCFt48NFuaUDa4K4+dkXHAYC38Ni908Y6l69oxNnaNsjdDHxo9wTksdPr0xMmjrn4hnqiOmnx31T19MMooYwluyNp3aTbguhw23EZ4ffsqfECyKnySGc0Hq4bPu8ySyQFct33Ej1o3FvRTV5dkTxRttlxSiaYT3DFgz+HczL6kS9zDP8kbqA4yAYnhrtz4A4lqIREpne1U4lQ26Z1nwxdR9Gc3nR8Mg== 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=xcJxsvx6FUu9stgirpLFuzIgGEys/dzaCRNKasjZZQo=; b=J638GnXErWVNGkiFaXEWYFrJpZHuCBMSsQBvvYeYbCAcA/h5S2tRJcfb8TL7YQWf7lf6Z3n0qyfh4hbm/j/sUQ2HZrR7+uhEFBi51Qf5FZIUCOKcQjk88/rqqqzoDKEF3nEFOSn5pK58QKY4Hz3MjQZdx0GQfV4LodogbRYvUVE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8481.prod.exchangelabs.com (2603:10b6:a03:562::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.44; Fri, 9 Jun 2023 17:23:52 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:52 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 2/8] target/arm: v8.3 PAC ID_AA64ISAR[12] feature-detection Date: Fri, 9 Jun 2023 13:23:18 -0400 Message-Id: <20230609172324.982888-3-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8481:EE_ X-MS-Office365-Filtering-Correlation-Id: 6d0c2b5d-86d2-4332-4a36-08db690e4b59 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: tGFe8ABmkf8AOjLlZx1N6Yiahn6bVuGRwt5gPzCrs3gwgNM8R3MNPxIgUsy/Lk89b0Z0b2tNDs1U5pUyzRYh8g+WfShZMvBLDXiAowKtyYxBIbz05fGdpvwm8QzB9jB3j50pu/GKXJBR74il6B8bAvpvMRrfqko66HEdOGd2kcNWjXCXDTB1FukG8nz2F53KbTv8UVMvkXgaPKC5FBUZC7AiTrTIo9pvuWYmGuG+Bhn+NwDTTy1Zh68qWrCaVVQVVo8+274J9IBNu3crnd9pOgHwebs1Jzv8bamTGcAgZIMW1oM81DVfhhsuiQu3rZyX7prOk11cqs3NJPD8DDpP0UwJUGgJPvyRqFViJDW45oOZLnLZkVqIskmpA23kPxtZTRjCU4/jKLpfLMJtmnTOEJCqWR8Dk8Y4kRacABq6yLDWDecbkuI6tvhV1b0t6eDSBWQVUpWcCrBGhrglYLsGlRsgNtHQeT/ysqFw3H/HGFJ7uk3F8wv7f0qq1JBgRXHb/TdlTp0yFCiYEouBRLrBEGiAdlCg7S776ncMgFdBZjuieM9otd1HAjt3U1HSLiH5RAVoLUu2pG7FwAdmz9gAYL9tFT8xy4C217qFVITuYVLFqZ1Ff2YtQkvUuZOI4d+9 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:(13230028)(4636009)(366004)(136003)(346002)(39850400004)(396003)(376002)(451199021)(2906002)(83380400001)(26005)(1076003)(6506007)(6512007)(478600001)(110136005)(107886003)(52116002)(6486002)(6666004)(8936002)(8676002)(41300700001)(5660300002)(2616005)(66946007)(66476007)(4326008)(66556008)(186003)(316002)(38100700002)(38350700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XBeQqbUup/3S9llsBFMJt2ScH3tZvVC3u9HGL31TBvyWycL8Ua6RqcMGRnIr+6VW0KI4gkDxWbFluzboROxyHre480VTXlkjUPfHjwY1JujF1ZJ4bTTux5zGeBNMn1oRqSLShInbWRW6isaAF+QJZsE758aLyLYv9OI7onnQk6Rd3Ba35WcXsGXjnzIu1DDEXJ54IKiS6aoa1ppswQ6C5fWMT8dwaxI5lj+S+/VtZfiyOSIgHqjN1OjfjvgmW9GTnajA0abuIUhyQu4/3Xy8IpiVOStLhxhUI3xMdGBY2Y9s9oi1W/lKUHKwsgweZPkhsrFdAxGv+Lq+vH4fRyiVG65+HivFncUGm7YWOXVOSRPqZgiINP56fy1mxkdWcbYWM8aus+scLvGsugT/EvSIbWbQBPxPqzuCripDN1y7cLTfFhs4xH3Vu583qJ84mu50v+ZM12MozcEPIN8jbircqbOX1Dj+qVH8x9VBOdOqAy/AA8Pmg86Oa2eM2P26xIhNgnjgPEkBt74L1HtRMkXgmD1ZF+EmNt7o5+w96J0Xp/ncoS2UYkyddL/o3McFndj3+lZMYCHrPRs2E4im41OD9cKVoPqEttufGwRMlIsQM95sRMT8FAXkUIuVkHoRO++C3WOQDcz7e8PnX1xzuy79zqOEhM1/VqJ/E7+CooKkaVEGEUyOiAZf3mE8aAYz0usN7cXDiVJXcrF/qrskoU1Mdb9X7e9Fk/AJvY7JIV+nLvBVUK521SxfA4EIEyqrKK69CiRjxAzaf46HxIz8nvxXothExQN6bQ35KEmUsgwFGgj6vFL49kajKBXwZC0TxgRCMV3CqIoA0iynCVrhk+x6OY/IR+o7pKAvq4kN6VbeJAJI4SnLt45pFrZqQVt9slU0I+XBamiG+46tzuhaLCZjOfsmj7sFgK4ijCHrS4a7wVNHx3kk9vX2oNssOnZZK8wqGzwyhTqnTGsePvTESldp19WXfvCX69FeYAAjft6aHG50KCO1NKhNq4lAYP5d5RLAb7x7N0OuPBDIJ+UFNcX0AsbELnoTy0oclp4+8lVhMdA9663NVkbD21nT5McJe40efS9N2z4QDQ+92DgWRbrT3cDJmSJrQ5Wgcd4rHXgTOem+pOafWry5e6iv96rnWzetwb9i0jxZtKkF6xYU4CWGHYkWWtdjMTLOAeqIU0pdU963nND4iUXjDyEAAb5frITk2VHBBeUKVwvBzw3o0xB7Lkt3FGlAKSj0HbUkxUSEtKqeTp+imZkeks9PqIh+gXAQx/rNfDmbhiPpwfwNeWGB14wTH3xwgebwuymm7MC2L1IX2+NLxqie8ytH7mO9viJtFC5WLA5ll8ZUJ7waHnV4otuorsHOiTy7wC7W1V4AGkBao9tpmHP4oxMZD1CTZRDPLZxiBLFIfKU7sAeD9RAXaUZIQN81KOTMoDza+xbrGKhMZE0WPCenaR2iuIftAOZ6zVpgPpAKaEUQnWV8aT52BncYR5H0QyG2Dt8gVA7fhV9sK/ML4EzasdNmK3ebgzXtHRCMN15NgxLImNm+a69sjQhTmbsDq5lkPyZeHQ7GRUwanwM0yeC8W0oE2jiJR1aqLmLHTrp1kjIyiVTUqvN08QNiD5PKDgAldkl9QwQ86yg= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d0c2b5d-86d2-4332-4a36-08db690e4b59 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:51.9173 (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: P9e1UFooJ0Sld+v0HpPbac5cf2K8ACpqUWQNFAX31q2DZxZhXF3JigSJcV2FQUSHF9DHdA0Ic/Ry/wYzMQkCLQW8X1N4gmuVI2K8owezHL8W++5onI0tzdKT6r41e4aU X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8481 Received-SPF: pass client-ip=2a01:111:f400:fe5b::703; envelope-from=aaron@os.amperecomputing.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay --- target/arm/cpu.h | 65 +++++++++++++++++++++++++++++++++-- target/arm/tcg/pauth_helper.c | 2 +- 2 files changed, 63 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index df04c9a9ab..22dd898577 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -3714,18 +3714,77 @@ static inline bool isar_feature_aa64_pauth(const ARMISARegisters *id) (FIELD_DP64(0, ID_AA64ISAR1, APA, 0xf) | FIELD_DP64(0, ID_AA64ISAR1, API, 0xf) | FIELD_DP64(0, ID_AA64ISAR1, GPA, 0xf) | - FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0; + FIELD_DP64(0, ID_AA64ISAR1, GPI, 0xf))) != 0 || + (id->id_aa64isar2 & + (FIELD_DP64(0, ID_AA64ISAR2, APA3, 0xf) | + FIELD_DP64(0, ID_AA64ISAR2, GPA3, 0xf))) != 0; } -static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +static inline bool isar_feature_aa64_pauth_arch_qarma5(const ARMISARegisters *id) { /* - * Return true if pauth is enabled with the architected QARMA algorithm. + * Return true if pauth is enabled with the architected QARMA5 algorithm. * QEMU will always set APA+GPA to the same value. */ return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA) != 0; } +static inline bool isar_feature_aa64_pauth_arch_qarma3(const ARMISARegisters *id) +{ + /* + * Return true if pauth is enabled with the architected QARMA3 algorithm. + * QEMU will always set APA3+GPA3 to the same result. + */ + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3) != 0; +} + +static inline bool isar_feature_aa64_pauth_arch(const ARMISARegisters *id) +{ + return isar_feature_aa64_pauth_arch_qarma5(id) || + isar_feature_aa64_pauth_arch_qarma3(id); +} + +static inline int isar_feature_pauth_get_features(const ARMISARegisters *id) +{ + if (isar_feature_aa64_pauth_arch_qarma5(id)) { + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, APA); + } else if (isar_feature_aa64_pauth_arch_qarma3(id)) { + return FIELD_EX64(id->id_aa64isar2, ID_AA64ISAR2, APA3); + } else { + return FIELD_EX64(id->id_aa64isar1, ID_AA64ISAR1, API); + } +} + +static inline bool isar_feature_aa64_pauth_epac(const ARMISARegisters *id) +{ + /* + * Note that unlike most AArch64 features, EPAC is treated (in the ARM + * psedocode, at least) as not being implemented by larger values of this + * field. Our usage of '>=' rather than '==' here causes our implementation + * of PAC logic to diverge from ARM pseudocode - we must check that + * isar_feature_aa64_pauth2() returns false AND + * isar_feature_aa64_pauth_epac() returns true, where the pseudocode reads + * as if EPAC is not implemented if the value of this register is > 0b10. + * See the implementation of pauth_addpac() for an example. + */ + return isar_feature_pauth_get_features(id) >= 0b0010; +} + +static inline bool isar_feature_aa64_pauth2(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0011; +} + +static inline bool isar_feature_aa64_fpac(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0100; +} + +static inline bool isar_feature_aa64_fpac_combine(const ARMISARegisters *id) +{ + return isar_feature_pauth_get_features(id) >= 0b0101; +} + static inline bool isar_feature_aa64_tlbirange(const ARMISARegisters *id) { return FIELD_EX64(id->id_aa64isar0, ID_AA64ISAR0, TLB) == 2; diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 62af569341..3ff4610a26 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -282,7 +282,7 @@ static uint64_t pauth_computepac_impdef(uint64_t data, uint64_t modifier, static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, uint64_t modifier, ARMPACKey key) { - if (cpu_isar_feature(aa64_pauth_arch, env_archcpu(env))) { + if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { return pauth_computepac_architected(data, modifier, key); } else { return pauth_computepac_impdef(data, modifier, key); From patchwork Fri Jun 9 17:23:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 39F4DC7EE29 for ; Fri, 9 Jun 2023 17:25:40 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqd-00074B-2L; Fri, 09 Jun 2023 13:24:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqH-0006zI-Sm; Fri, 09 Jun 2023 13:24:07 -0400 Received: from mail-bn8nam04on20706.outbound.protection.outlook.com ([2a01:111:f400:7e8d::706] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqG-0004ny-8S; Fri, 09 Jun 2023 13:24:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kVlgWAzMHMh1dLrwMyYWp+re5lrm3n2E/F+YUbhw7sR6ldNUvShWWTe2GvNU8f8C2P3Ym8fOmaG4z9jKUJyHjboWdb72V4cigBPPf4foHXFOxENF6Y28nLjk4AwGj29PTLry+2jE2m1naxseAFiJPIyttwr41qMMT+qXAnHeLN5x29ojt9uq+EBRFTteR89E/KBqpLz3BNCS7/FG/divn6TAbV1Rqgm1XZuFwCsms6riTJoztqlFbAlQf2I9JjO6dZ8JCqgEIlaTAPjC4ev4TX3eXJBPFvqqVpxG5FbPqZhysarJ8Kzhz2ZuDfE/fNWUNsSO0MWWhh6wScDIhL8N0Q== 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=P1kbDTRaTIHfeSas9aW3ZAgj6q6/NhKSeWXCBp/H67U=; b=hw2/RgzNLhAlbNC8iwTYRb7Feb6HQw3PPHT287twGek9vfBXjuMesXoGkhW0oSbyQB7s9LrVwxa5FWizKKhLK00RXGmfzKrnAqctNxZSZgCv5EEnWsYriF/ZuUKjETmzioLPqvTkHdct1/g5sOrO3Vvhh6V9pS2JK/k7L1ZK7VgsBel4Rx9Tm/DWZESYkJ1gwTIC+V4zE5C5gE30dgHUEZKIYFcD2b3RtNqHboV+aCMelkbuy0w/Bhwl4D06zJ3NzTQP6JJhMJcd9HlqW1WFJ18Ur5D3ZE8NrgLZ2Mgkd3QU89gtLmu6OozJ3FXQSAqZI5iBpTxVzy2Yg+4JLTl4NQ== 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=P1kbDTRaTIHfeSas9aW3ZAgj6q6/NhKSeWXCBp/H67U=; b=pYW/iGtg6NhokDN5dOdmcLYfRvr6nHQff/1KLDHXOfi3Cgu9ZH5P9dSlJyt04aC2f7YCrmI8IeNHbMB9KGtWnhLNDBHPHYFxa4LLUkaX9VV+p76U8PCAcB0Dbf7K8OAaRlkdSxwuI8ZnBJQNLO5AOYaeenwmbV/69N6Rq1kVx20= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:52 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:52 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 3/8] target/arm: Implement v8.3 QARMA3 PAC cipher Date: Fri, 9 Jun 2023 13:23:19 -0400 Message-Id: <20230609172324.982888-4-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dc00ce1-6099-469a-cd29-08db690e4ba0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aWBaEougsNhOWxROyOW/o6PZNrtbYenS9fvycjml+1C3XCviaJ+0pWZdb5VhNnk+3tPNLYNAxypgCU8g6zN43bykvD+15YDK2KFft0lNb5beEdL5nPLTXlD3ppWkXtdUWpq5ZzptGDyt6YaLwzWodublrtPbqDUiwQugERa2KjyTXiokr+7eR+tWkWyIOiVVcYRQSZH6/Xyn/M6mDt9EnUg2xw1eQ5tm7w6vKpyzuWFVB68/QgGg0b0tsGNUyQEAyvL4Y6iOKvYIi8pA4MbNachoxbne69QZKGynAzCs1ns+w4Gco/Ir87QuiqZHQFW8aA2tdHS3pDbro+Ptco6suc5ZPPpZvjnROWbl7K+KDrUebxPrhxu75a7zIcC30vi3wmGe0v2QQFauWkPdtXPDYlx4mjthbuePqTSZrRcDudi19H6gvSeLJYR9r40tImFVrC7CAu//oTV8j4OaqTfQXdaQKq62m0+aLFfzMzB0V8MZksPnCqpb52P0U6RZfE/uNfFN0C8YupT1BpI2eIJW93sUuFA8wNwtH56yRYOdi3NkE2GmX7nwNPam4OU5c6uZwEJIU2seyVpOlbb5sTRqvnJkUJIm9YtpVHhwr1f9AS867bPP2V3i6ObERiFayQoY 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2dfq56jw9ihIbeLkd/azurYiEfn3ZSVkA4X44pWb0oqfrWq0Plo7v9WSb0YSx2eaBLby/x3F9hirbgTdljF24PjjFfxpSl45nNUerdSNVS1V9ymA31u8LHz2yf4tlMfm9xz6+DeKHaA51E5R5rhwv3IeEm5S8iUheFYrQ7LKtgmtIaUnJPDEat+vPduF3wNsXbp9KH2sHxQqFGk+0SXms9UnH6vOe33iqXHQfBaUb3QFhTe1o+g1hdFg5VEg4QAHICAUwIWeV6jjSnqt0tX3KO4UunhXrzDwR7IlXBlR4Rkk6fjAcHyZAj1BFwRse2e3D3JYONbVBjcWGnGdhTshHG2GxalWGrgkyUB/eocA4Lme0oVfV/DL51t//GyAg6Sh4B8dRV1N/F9G0U4zI1OPO34C+gjPl7mZ/PegYRd99RMFMzQSd1Wg48yH+wsEY/e8r+coMbx8q9DklGopMY/dnkPDeFicWIILoYQ0sfVSJZmzXHZdQuBy/QR/y9SDTgyPNJFGISG5jh8t9ti3JP9IMMCCosJpGZXvXepqqcYsak5UO5Xmsdh4pC6HvFZJD9hI0ePsnJK/ZADYEjrGjsxuecwYYyu/nQ4+vKdVoej/G3nuNoSSnaAJQCdsegl4J+APBGiWmi9aNbEWymf5Wa+jfxi58DpHbNgEalAxNnf3HmlulF6l8TAkHy7JyrJJgfIhHp+IlGrzTIcposLS7ubqmv2d8ogLNAdCaHmXJvhXJYR2SnU97W6hejpoC6rDUNNx4VU1REi660N7/OKK1GievV2ZNqZ4Lawf7dtdWmwJ3MGc2EPDIzo3k1XKhQTEuEYm45cqsHTK4tni7jO0ThFAOOGTj6uCpnOSW7XIMTW+iHqvI5dTQHeUSdxgfEfBZf456KccQnlDVC/M3fayiJd1QmvTs6r1MBzw1dA8WdVp6zfq92wIt64PT+YC6GEB55g9hpruHGS2P9/lQuMorONROnJ9N0yqQTle7ctcbv3uNvRuT8M7jjEpcmskTY3mPBezIWhU2hKgOIeHvYKWaIhUGEIgozKb3cFL7Wzj1+zfZfoVSdKFzeqGLG400exj3naVHF67uiSY0N7HBTUoV88Qb0Z4oGo3QH1DFOvC8fCR9iNwJw2pVFR2nmIR4ujpHLHQDrGNFSHW/GLwgtRNCyqhOvx5KgqidrJrzbicqESvB7xN4KPG9hf7P9j4zIo6OT/QbdgDfr9S4skm5ivBJk6ZS0Paa9Zo5sJmTFZDZAbl95aRFB6FVTT9Ctyf7FDgk3D8wFJOHqKAipgo8k7Y7SHabqLqlK50hAg5vpTeKkjPiEb6ocvbwsM/ywxgcyGOjQVPM36WVRa9Fqia9y27i0ZZZSosvA4787cf74RcM5XUQMQENnnSgOxeLI+3+Jr3ybWPmmaP8i5So4k6SzoMarLmov/IGeewOuSp22uYlBrPc3Z+gfID3P5qsJBfyS+1o0syDAG+f9Mrz1RT7xkMCbMcX1iBb63VgNnfZdshe9/1PYqzNaZ3S6lGR2OORm96JvaK5XWOBAlDy2cazl6nASTSRM86BQcRbUcssRC6PZX/gsx/MylLdF9082Zg8yPbn2A/UBLGQ5yNtth1cb/AedxnEhH0Sr5MNgzBVKFTTyZ7RCE= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0dc00ce1-6099-469a-cd29-08db690e4ba0 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:52.3614 (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: 9Poud8ELomvAxpzBXY+7uaaSbmTL5ugvOdSAETx7dNyN8L+CbBNMECFNb7F1vaJKSeAErdj+AjVfs7abqBx5rJxQJ1/FiiaVU4Jh4qzwT0ipZ/6F8FUApW9Od4Sj62s/ X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::706; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/pauth_helper.c | 54 ++++++++++++++++++++++++++++------- 1 file changed, 44 insertions(+), 10 deletions(-) diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 3ff4610a26..68942015e1 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -96,6 +96,21 @@ static uint64_t pac_sub(uint64_t i) return o; } +static uint64_t pac_sub1(uint64_t i) +{ + static const uint8_t sub1[16] = { + 0xa, 0xd, 0xe, 0x6, 0xf, 0x7, 0x3, 0x5, + 0x9, 0x8, 0x0, 0xc, 0xb, 0x1, 0x2, 0x4, + }; + uint64_t o = 0; + int b; + + for (b = 0; b < 64; b += 4) { + o |= (uint64_t)sub1[(i >> b) & 0xf] << b; + } + return o; +} + static uint64_t pac_inv_sub(uint64_t i) { static const uint8_t inv_sub[16] = { @@ -209,7 +224,7 @@ static uint64_t tweak_inv_shuffle(uint64_t i) } static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, - ARMPACKey key) + ARMPACKey key, bool isqarma3) { static const uint64_t RC[5] = { 0x0000000000000000ull, @@ -219,6 +234,7 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, 0x452821E638D01377ull, }; const uint64_t alpha = 0xC0AC29B7C97C50DDull; + int iterations = isqarma3 ? 2 : 4; /* * Note that in the ARM pseudocode, key0 contains bits <127:64> * and key1 contains bits <63:0> of the 128-bit key. @@ -231,7 +247,7 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, runningmod = modifier; workingval = data ^ key0; - for (i = 0; i <= 4; ++i) { + for (i = 0; i <= iterations; ++i) { roundkey = key1 ^ runningmod; workingval ^= roundkey; workingval ^= RC[i]; @@ -239,32 +255,48 @@ static uint64_t pauth_computepac_architected(uint64_t data, uint64_t modifier, workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); } - workingval = pac_sub(workingval); + if (isqarma3) { + workingval = pac_sub1(workingval); + } else { + workingval = pac_sub(workingval); + } runningmod = tweak_shuffle(runningmod); } roundkey = modk0 ^ runningmod; workingval ^= roundkey; workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); - workingval = pac_sub(workingval); + if (isqarma3) { + workingval = pac_sub1(workingval); + } else { + workingval = pac_sub(workingval); + } workingval = pac_cell_shuffle(workingval); workingval = pac_mult(workingval); workingval ^= key1; workingval = pac_cell_inv_shuffle(workingval); - workingval = pac_inv_sub(workingval); + if (isqarma3) { + workingval = pac_sub1(workingval); + } else { + workingval = pac_inv_sub(workingval); + } workingval = pac_mult(workingval); workingval = pac_cell_inv_shuffle(workingval); workingval ^= key0; workingval ^= runningmod; - for (i = 0; i <= 4; ++i) { - workingval = pac_inv_sub(workingval); - if (i < 4) { + for (i = 0; i <= iterations; ++i) { + if (isqarma3) { + workingval = pac_sub1(workingval); + } else { + workingval = pac_inv_sub(workingval); + } + if (i < iterations) { workingval = pac_mult(workingval); workingval = pac_cell_inv_shuffle(workingval); } runningmod = tweak_inv_shuffle(runningmod); roundkey = key1 ^ runningmod; - workingval ^= RC[4 - i]; + workingval ^= RC[iterations - i]; workingval ^= roundkey; workingval ^= alpha; } @@ -283,7 +315,9 @@ static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, uint64_t modifier, ARMPACKey key) { if (cpu_isar_feature(aa64_pauth_arch_qarma5, env_archcpu(env))) { - return pauth_computepac_architected(data, modifier, key); + return pauth_computepac_architected(data, modifier, key, false); + } else if (cpu_isar_feature(aa64_pauth_arch_qarma3, env_archcpu(env))) { + return pauth_computepac_architected(data, modifier, key, true); } else { return pauth_computepac_impdef(data, modifier, key); } From patchwork Fri Jun 9 17:23:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274230 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 79A27C7EE25 for ; Fri, 9 Jun 2023 17:25:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqE-0006wd-Q0; Fri, 09 Jun 2023 13:24:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqC-0006wG-HS; Fri, 09 Jun 2023 13:24:00 -0400 Received: from mail-bn8nam04on20731.outbound.protection.outlook.com ([2a01:111:f400:7e8d::731] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqA-0004ne-VP; Fri, 09 Jun 2023 13:24:00 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GjT1WR0xpNiCo9Gl/5Qpfoe13orshzVdrHCxiaMUvEeAGZdcpqm4P+LWXs1OfqALkpZwzYuN3v0o9Pvu1cdB6KGsfWNhVvjUwH+Oxh9sft+W6avdhRHfC7e9mbQcChiG7r3pliOzP/lLnpuOuLderfLPKrWkL9vaH6hlWYROL7ZKWDuEOnx7J7PJaRlyqUK2tXvD+mwQ4JyGgLxCoSq91rxU55/4T0LVNFNnVT+lELuVgzifKtXRV9JVpe1jRflu4jP0mCiM2kCeJ4h9+LS9tMp0mwMJig5ZEndiw78/xZRCp0/hoMlEraDqlY1xcFA4V9azqlELoGvLbkGgNlxeug== 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=YnGBeRQCal4T4ULSbd3fbm3NoE/NjS+HeP6vgLIFZhw=; b=QvLfe7ZjvJZNbxfxKhzk3IzwfcgxMOcC1LtTmtI7N+xSjuv5lfe494ped++TpzAx9OHXYpJhTQdJ44bChdSg+E6dhWCI2TmB/wWwk8LZB2HuvwpToBuNRfdeWEmCZouc1dA/GR8P6FeHdQOQi08+FzMAOspEpY5e0LuZ4y0C3edN5CinZR9QwZUVf5rK6ioKC7BWz7cxl+7bojyYhbqUDhDVhOA/A9idPLaIvlxwtkM8b7hvfVYtpN3W11r6wXYknEzP2VSWyQ8E4t0yj035Y5KalQqNBVmclHszdHD7ViuiZuspYAbdc8DaGC1JJCnCJgFQAuqk0mf1U0NNuQ5yCw== 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=YnGBeRQCal4T4ULSbd3fbm3NoE/NjS+HeP6vgLIFZhw=; b=adeSE8WgFz+pSu/oS+DhGufGENEEaS8pliIEgf4ny5sWae79MDoPbpazijMW271R7Y3Ey8Hm74f90MPnDmmLliIrnFMctYCsRwjamPXOqhiViJn8Wd6fJpmgYQDLobIGUAmGKp/yQY+X4Pgu7gWbO8BRKrUTIkHiDLEulOojXFc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:53 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:53 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 4/8] target/arm: Implement v8.3 EnhancedPAC Date: Fri, 9 Jun 2023 13:23:20 -0400 Message-Id: <20230609172324.982888-5-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: e8448076-d311-466f-9db7-08db690e4bf6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: zpkRnqlUIN1tAXj11nClmW35YgRm9np73wjtcRa/uqnumqhs6WEoxr3jpzuXwEcvkZhPAHtDISdccoMNdCcBFX6KBzGEPZlkvxjzLeKpMGcXOEGyGE7vtWEf+GWWxXUoROpoVEcdvqaUazqIsbkcTBhL+8t4kZXI3brnZtsvrT/0dX2CZTbJWz4x+eTxPFYSegfZpKw/os6z7N3KgpDOGcX598mDMEsVAc5ersSvutcWJKZUcwwuflwcZs6P1gkNaFG9PWh8m0hQoOOsgHjnF5C/xuiGmeIwefoM41XKeXLEZSe7AiJnjz8Hif4K08QG3QLlQoHzQQHbDH8yR4yclNpw5ZLGgB/MNFKaxQ+IHMPOXqDxa4yPA8pD9dPOOSKUrck8MQtp8WhcX3Hlvy7xv5eoBOsLxRuKGKV6xC234DA8HVgPIUVEGjX+DXzqZTHK0HUGWPDujI9zDiOW4Y8+SV3TJ79Y558LqC2VMEYmrL49Bv/LXaBHim4GET9+fi7xc1IPRf6ojJ0LeMUGBnhyXi4VF6jM7XsmX/2iSENRFy1NA5pE7fZzPLoevu0g8kL2/OMaWY+WZxXAqkT7PggAaWdrfSYLrrYFRXVHB9+DVXJxTNmcIPcOruCWo/J4admV 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: PN/DW1KNKD8PvRvQFUg/WPYpf+6QyQlCnZY/8p6guWln6DqvBnLxNVfIUq6vHaZ5U6jq38VEgIF0NWxaavXTChhoFYp+C5vdw0mmotB3NwzKyLx/iWoAkayq//uh7jbLmw5pX8Fv9+KCx0CmNPjopF1JZzlocwTXJn5HOgMoveglnlsC4YMVKC/jY+f1xG54UBYuf7vyWSK2kmc9r1qPyPFz7n0rO+vZ/P9IRSbrmW5pRE0JTzp6x6Srmy7jvZRu686WiZk5d7dykGf/fWakyrgDT6g3/wI4Wn6Z48IhzJ4s9eyj6NNlRpZJDDSoZ+Wwd5MZ4HezVTqQZ024rJ/k++/HEIvbwBaFgVZz6+60xH5ObXGgsHiU6Sb6NQKViP0sZDqoFSdCKhuCVN2+36E/vgbIKlClL+oC/6gU8I4Z1I1LxFBy0DMGeectc4y8oB48dj+l9gPaZD7UfS/EmeZuO65SvuE73FWhitT7u0yjqNxvWI9m1gVcROBO14uu3bLxY6D2uF+IwLx1erBt9gAo8NAqmEQdsBiUkfWDIjebgvRlLUkqs1oyAtVmE4Qx7CA1zaKXwoHBPO/8CpgXK0qZVUNpszZYk9rcelN9dfJNwuoszERoMalYRrgnCqrJW+ODRBt1+nHPKJsaE55ig6lfygizYkvcq03f2xOjLXhmJ1jp2nZPMvCAarwPXUOxnL/OfApOFu500VZNQbtzrTizHuHhyo+uoAU6p3LWO3A/Mjf35X6N3uE6X9LlHFFUbsDOVmasN5qigDUVXLfy+G4FQ0VAVX5Mn4SP5kShRN5VofiwTcC60i1uPRcLMi5slcVgpds4OrFKf2hPC0YD95+yoOkO/OylyPLHZHe2sCONHbnWsI5O2/1UYdpoHCtz+8PJgP3WQTKBRWuHLv9n3Ko6LasEMm5ZGeFeD2Qm/B1Jms14QIdtUUAGVSKMiNQT7YCX2rRmikEEdlPpPcdM11QU2K8PmXYCZAT70ZeNxh3OD7kIP3ZxIAaoAE7X0qU53jTinJ4rzuDWKVSiqGDPjGLkebMPB8kogPPIQIdpFCiz0fiLyrlKlUiSh6I+4RFNfoPSNiEDdl05VpVqU9pitEjv0FubPuoKN+c1KlNpXHUPcuvhIWHRQU5ll+9poP1gmX1FlO663wRWprm2DyzpcykoLUolZQhuwuB2nymPmTbjUUq2WkVNnA6EG7yNctesJZdz+ZlKFdxJvhVKXubfyJwTzzaogrwvzvDLZDf49Fvj1zHi5uHDBBkgO0AJUbcBARCAFulbbhxBYRXBHteMpqUJcK4fNDdLgO1IcqlcArdiJJbG+hSn2Kt3dm0zqA5vpqjK8SkMMYLJxt3DqCfwMtnJ+hPVgT/6Wbg07vO2hOLWjYQPUmZgqW/0JAPD6Gao0BcsFvvAWGFo27u4LwvDInDWqLLMGf2/jmEKhIAM3duaJcsRtxt+NbmluHXI+N5BmwEP5lwONYRoExt66dGy6WxJ/foeJU9Ut1Y70eqpo3shau0QpbN6oqFTUryHQhzEPP52CN4g7tfi1NvBaToCkOgcOMsblfxy8KUyWgA6cSImyRxx9ndZyjvzg7Mkgt84P2/0vEbAzS7UQ/hpUYy1CW6aWO/G/IM+YnJ2QWi4T515M8w= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8448076-d311-466f-9db7-08db690e4bf6 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:52.9314 (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: 5NFcwZsVVfj5Bh9eA7S/Nl/7PQvXtXxRbJqKgGwGHRIhnjI6E+nkwxmTJwI9mCBiZw+ea2ziDxOAw+BSm/GWoUOilsJq+Wl1qjItrYY7JuDIUAMRkYDaJt+oIyoxbhup X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::731; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/pauth_helper.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 68942015e1..1e9159c313 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -326,6 +326,7 @@ static uint64_t pauth_computepac(CPUARMState *env, uint64_t data, static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data) { + ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false); uint64_t pac, ext_ptr, ext, test; @@ -351,11 +352,15 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, */ test = sextract64(ptr, bot_bit, top_bit - bot_bit); if (test != 0 && test != -1) { - /* - * Note that our top_bit is one greater than the pseudocode's - * version, hence "- 2" here. - */ - pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); + if (cpu_isar_feature(aa64_pauth_epac, cpu)) { + pac = 0; + } else { + /* + * Note that our top_bit is one greater than the pseudocode's + * version, hence "- 2" here. + */ + pac ^= MAKE_64BIT_MASK(top_bit - 2, 1); + } } /* From patchwork Fri Jun 9 17:23:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274233 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 47467C7EE25 for ; Fri, 9 Jun 2023 17:25:28 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqG-0006yF-Ed; Fri, 09 Jun 2023 13:24:04 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqE-0006xD-Sk; Fri, 09 Jun 2023 13:24:02 -0400 Received: from mail-bn8nam04on20731.outbound.protection.outlook.com ([2a01:111:f400:7e8d::731] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqD-0004ne-5m; Fri, 09 Jun 2023 13:24:02 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G0NoIfrKyYiICiom2PNukXNEFBSQlFP8Ywopd3e1FQZRYHiZLbbVpkq6uy1HmQrqXbutQs6v4SfbaGQ+po9fYfIdyQG8TkMYjCBYZy40Kjd1VsJYq++dbR4RkfLZ4mT67DGfWdMQeXVi8hs9PGi+PCNvmjYofXYCHP5H0RkBbVOVCGM1WYrxce88wUpqzBJzJH2WkU4sb6VsRJCYrvHzZnwoBVBlAclMlAuVXbV9nMdEi32usw89DmKoBHBUvcWlJPo/ahX2GInhUeU3yaANQMEgekAUXJ2emr+rO074D34RE0kjfp3jBzxwXFvU5CEwTUENSlF2ceeoR1N68dh1Lw== 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=4LbFKRhLM4tFTF6ZnSWYo2OCpwOarLmHtm8rjno3vpw=; b=CH57Xdgip/SjFnGFT3DjcF8Q0mX+ZC5XfhqUN01n3fybMQpIWPBMjhEC/DqViMnqo0l1CNFKRdZpQNe97IB8vpKbm0Y2WOvHZEAukvCfqlqGIg/0xrlAf/UMM5oDa931kWWc2+DbEHhWe0sseODeg1A/Z8xk2wQiURasHdvigNUCGvZCcGTsu7wz5kDsbwLfkphJu/JfXkX3A+twd+bdTVmFfwjAG/zZN+FAUMUun5bH2UG31rxSELy/Jgh6r8fuSiCQqZAirI/FrKsptplyX7k8YZdEb9tzaUXvzYE8uT6zS76oky6fsEcfNnH6mk0XpM4NeHZ1f5cV+2vj6uedcw== 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=4LbFKRhLM4tFTF6ZnSWYo2OCpwOarLmHtm8rjno3vpw=; b=JFnvaWjY/l4SUxuSpnE87D4xL2QDSd3dA8ZFoin3Zl6iwjRdxBMwD/r5E7HX8w3ssrRVS3HR7cN1qlCDi1sHeVgITSWRZjqQsr+EOP8Mu6hQV7pBzWEL5Bl/dhgGzeHirVOj0DcR4lyTn4sP0JcNLiW1OYaRpI7tp3SgeYefRDk= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:53 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:53 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 5/8] target/arm: Implement v8.3 Pauth2 Date: Fri, 9 Jun 2023 13:23:21 -0400 Message-Id: <20230609172324.982888-6-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: 571b5fef-4212-4c8d-8045-08db690e4c5f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: U2pQryYlmIqfxsPa/Nhf+DeeSLbbCXZmOjDdfmjwEj2PUFgSNq6eozTHky6wXx3YdG9tU/1zVP+UJAP2Ny32IK0xmfueOCY0focjiiFJfQfjgdkP7JPOBXvEi7agl8XvVVoq407WSM24dlUD09s+PW08gOrOAFoLU4Jxo/92wtgeBkxB75hJRJV8QDZYR/4Xu1uzYZmCu358tFDADvPfEYn5rRUamtflAu1Kd8yvfzBDxOkVz0zlGkP2TwhmyEbNCKIXTrrDm/BJjzUW74672+fYY05GHFVwWgLqIcTo3tBPbdL8QznH+ILr4lASxkYd5ATQowlTOQwUOysef7LRMvuPciPCpEa3A4PIebzijScxLF0kIZ5BufEXwbQn63f8OLD+PBwG606ca+AUlewoa3Ke2yJziuLW4pZuupCuWsgTFGwzcsZ3/d+cEr0lrNWDpEhv3Hl0wvEISoOqpfwWse8XkXVhXm4UYmy8ZhCPKVgS5oGJslELx/ig2BVQyotgTU42NsBrbJSamG8vMUAEUxHnkfmnMcDOosX55q6oYEQmuiLc+K+qY5/kD5GICMC6j4Ag8oGenUUX4c2rqmgLBCzpeTGnCbUk/CQAfQS46DiyXLqvllJXCJxImRT4yh8d 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sDcU1Baux2ln9SpD2DF0hbqacrp7G44A+t36cGjugvFIwZ/tfFaGDcWUr5H/IJc7cpWVNST4C5IQOHLpWFbvzElrbGbVvjKHZela/66moAW3x6fxBEQtasI3uu63InuX4Y8cqtFjlNtbBzfQnRRiV6OTbqshYxhNSdDOUtz2OSXbQUzmf62ypVKhKq1q0GUoi4y7sVrPJej/rhyNhT7ViEHEK9DMXQ2lc+jtn2F6yMjdZzMcglNXGBn9o34pMBQUHQeoUeQQ4n7uPUSAGmZ2cBj2L1Q1iV8b7kDjdEfIcphS3HsdObbYGGgU18YAoxIDoBVjMmQOSY65rRha4RUeDOOod870KsvYMDXnTPj8OBRBE6U2YVZeL0ZDaRnqd26Ya3gwKxVoYz3AjejehWV7QIOfu/fCNgLQdMny3CltEmxnmLxoYWQd9kNn1jflHuvfJjDdVxhr9RbllUEyTJLtmeUPbAB34m4wT9NG976d3Gfztm4z+kGON+VejXXNh0d4dnPD9hI5InBnlSBTsJfiuz6HWUmPja7yDGzfW/W1f4Ou5Z33UQnmOLXnVg4LMH+6esj9063sTjxFuNYSHjWScWDlnb/ZpaD6Jsr7xlv+5qOaZ6t1bGqS+oMoA5gHH+kJEWCJA6/fkYUFZVMeHrRL5X5wYFLTGLizjFgKrk3DGNKyFBq5/rR7ypFtf72qI01dTTC2lz7myIY4GzaTzJLI11pWyAlQm7MBGRcKXZ8kWI2fnGJo1lj+gw8Y3mjYn463tBGOOIF3seHNRuj+mQ7XUOEqCM6Mz0efIHggrnIvQNRE8s3TKousWV86PgDQYhVwDa/N1uM3fX3sWr74I9LnSjATAg84Iz5fpCJ/h01vJqhX+bfI7xrJLGWpryNSvn8+hDk3xhdMKeigLcMwu24j8igEzSQpsdSn5dYdqmjCzRWoHDUXUHjvzXp8QiEsWL5KUiFf589j24bUzJ4N6DC8d9Yme6aH7OLaLJyj4mG+XlUDnNtMa8GRLFl44H3iokhQMOC+yOdr5mPZo15Nl9fRQmr4ombUy9oGxri9VFJ/Qr/jHj8EMigNRI162xL/ekYZhEQUclQPalFqceaFikUNcNNxm62MHakKCjn4+03VT+YO1ReMK7L1emhWt9JLWzf4ZhbUNhRn1PlQZ3LCbwd7PX68EaGinB7WNuh4Wkza/Y1ZFxWWIDvmiHONeLbR7BVMFJXmTONRw+iNCPIZhXmxH30uBO+BsE1vJFT6HCtHi8fougYvmHcHRlAYN/31NxhSwspYiHvWFumdWVNEKvmjQuqgSuaUYi+rY/DaUTjYIT3bn/ZlKuA34utnc2Eb750eN7X75brX3v1cfKO516oI2NsKJrXhGlFfeAskMLkXA3RLiOWLcBXdYMXu7Vy48tQ9wmjw4pMLka08LxP0vGO2CzehOR1WiKgEpF5Y1PpDRXU8MxExWW4kOx46Et6ScuApuagbvDD2p/rm9XOWV9+RWGlQpt+r1LA08mMv+GuzK3No42NEXmqh70Up7gVIb0FYZnq3XKJGMzBdmjkMU3uwaCuSfvbT/Byi2QirftjXYEBCjlma2E985jEk7p1HeiVbVQtG8qzDVSvu794dbuDpatLCMOWQ0O42u4ky0bUHPfc= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 571b5fef-4212-4c8d-8045-08db690e4c5f X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:53.6529 (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: kNVrWdkEG/VG9/43U5JcDdKUx0aZEjb9/TAaGo3gIT4RbbNqEvZRc8m6riAcbkL0jlXtIjhKblcpvnbeTQhtfj7eqr+3fIzQChc1ZFtIkOuWgg7eQhUQiWUNNl0lfepr X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::731; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Peter Maydell Reviewed-by: Richard Henderson --- target/arm/tcg/pauth_helper.c | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 1e9159c313..b0282d1a05 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -352,7 +352,9 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, */ test = sextract64(ptr, bot_bit, top_bit - bot_bit); if (test != 0 && test != -1) { - if (cpu_isar_feature(aa64_pauth_epac, cpu)) { + if (cpu_isar_feature(aa64_pauth2, cpu)) { + /* No action required */ + } else if (cpu_isar_feature(aa64_pauth_epac, cpu)) { pac = 0; } else { /* @@ -367,6 +369,9 @@ static uint64_t pauth_addpac(CPUARMState *env, uint64_t ptr, uint64_t modifier, * Preserve the determination between upper and lower at bit 55, * and insert pointer authentication code. */ + if (cpu_isar_feature(aa64_pauth2, cpu)) { + pac ^= ptr; + } if (param.tbi) { ptr &= ~MAKE_64BIT_MASK(bot_bit, 55 - bot_bit + 1); pac &= MAKE_64BIT_MASK(bot_bit, 54 - bot_bit + 1); @@ -393,26 +398,34 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data, int keynumber) { + ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); ARMVAParameters param = aa64_va_parameters(env, ptr, mmu_idx, data, false); int bot_bit, top_bit; - uint64_t pac, orig_ptr, test; + uint64_t pac, orig_ptr, test, result; orig_ptr = pauth_original_ptr(ptr, param); pac = pauth_computepac(env, orig_ptr, modifier, *key); bot_bit = 64 - param.tsz; top_bit = 64 - 8 * param.tbi; - test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); - if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { - int error_code = (keynumber << 1) | (keynumber ^ 1); - if (param.tbi) { - return deposit64(orig_ptr, 53, 2, error_code); - } else { - return deposit64(orig_ptr, 61, 2, error_code); + if (cpu_isar_feature(aa64_pauth2, cpu)) { + uint64_t xor_mask = MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit + 1) & + ~MAKE_64BIT_MASK(55, 1); + result = ptr ^ (pac & xor_mask); + } else { + test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); + if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { + int error_code = (keynumber << 1) | (keynumber ^ 1); + if (param.tbi) { + return deposit64(orig_ptr, 53, 2, error_code); + } else { + return deposit64(orig_ptr, 61, 2, error_code); + } } + result = orig_ptr; } - return orig_ptr; + return result; } static uint64_t pauth_strip(CPUARMState *env, uint64_t ptr, bool data) From patchwork Fri Jun 9 17:23:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274232 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7E8C8C7EE2E for ; Fri, 9 Jun 2023 17:25:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqa-00072U-TP; Fri, 09 Jun 2023 13:24:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqI-0006zJ-77; Fri, 09 Jun 2023 13:24:07 -0400 Received: from mail-bn8nam04on20731.outbound.protection.outlook.com ([2a01:111:f400:7e8d::731] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqF-0004ne-Ek; Fri, 09 Jun 2023 13:24:05 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jd3PAjxmUyMr5feI4zITj6TQjaZD1P4Ylq12Hx+Rq5k3GdLAFR2ijTp0RZ6SnEADMCpWRUwreylYe5nlN9ejXhtcbh8ZRQfMOUzqETsWQG4578zyHBC2NktqbYYZIpeBK2sOzdjU6uZKOVqSZsf9+LV/zRxtoPbHzueuz7gNW6bc8MHhPLEpc+1uTcKbJE305LH1x3H6EHqbd+Rwxzaej4gvnHcuuDi6PNvctrD+QtsJF59Y3hOootNozMhohYkNjBJf3L6+3wAiAxyG6ofaXVfynTFSjtmohWw8golCokgqiTUl8IjixTzAByXrjv1tjnUJM+fI52GghXDlE2eQWQ== 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=bxn4vPThl+baVuxP8ItkNRPLUFSSsevGoNesf5gj2Ic=; b=g+051uCMqi7e+0aHu14Q6TnQVNpZzY+r+Mhaz7YkUu0dym5mlxcFHkq1Y7JYYoNnWYR9jRNQ4pxbi6TFanRQD0O1DGEVC3i6s7Lac+r0JF694vyBjjVMhRYTBV/O57oUvvOjDoR0LsHJF1mlCWE/mgyQTsUNlSDzOdrE08nMvQKHmv+nYrpYFhc9W0RW/SPBLgkfWMwgrq64GvKseRj/tpEm6j94mOtls9lKwWkHQRGlFDR9z+ADKUGsz1m0a1RN0QgxWrjh/WWGyD8J8d6XzV3H2M3iy35mvlLFRiNymyWi0d4Z/088NV9EttO6/+yS4SLsUOUtnc0bhUasZl7YoA== 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=bxn4vPThl+baVuxP8ItkNRPLUFSSsevGoNesf5gj2Ic=; b=eaWAJAS0gQw7SCEX9mujn1X5ZmyfZXeeIl3BNZrxTPsNnkEB07JAHM34c24QNxxnFmD36xhdwesq+9IDHa33V5eTvd1mN4oVlSMK85VSPslEnXh25LaMeoysgT8oclTnz1qBt5suNvk/RLe2rdMovef972KNSkSdDkdjegG6csU= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:54 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:54 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 6/8] targer/arm: Inform helpers whether a PAC instruction is 'combined' Date: Fri, 9 Jun 2023 13:23:22 -0400 Message-Id: <20230609172324.982888-7-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: 11085a27-53bd-4cdd-3937-08db690e4ce0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VocPE2Zcb8HFQEZeuW9HlVVRep/JLOim1MIYPOc/ocA4MQIn0aq+icPxyxA+XYG+w81G2jrsKMKzMqTIALIPG+O2mEWjQVIZqvoP9y4yfnSAg1xfJNK+khOdIFRYz7b/jsFzWC1zqLExvQsbpT6p1nRopUZX9QIfinrY1VxP3CUWNj3VRxTt4DVyziXs5v1mZrzl9PyMtltKT2MWrHIY/baQlV1tCMIbZsagO7ePk8cR3NOZhab5vJnP0PMobHCOchty7tZFVEiR9Zp+LC04wbDyFxXLqKLU378JgwpCvemwHi4Kv6k8Df8Sm5hbjy7Fxu34zAKmUCrlY67YsxvlWdy8wA+LuzCl9Iwzmap8mKq7gK+W92nYhbW8STxADeIvy0o4kFwXC6aJUGYVyS+WxByUG6QEnutYY1Dx/39u2ukKwyALeGF/zPKtETEzzHnvjCayjvAjfEZgMqWSPE00/Z8pRzeXB3uZ1yX9uNuvmuikZhjOWMtTL5pBBjk0Kmg1zp7lZAYtTTsoWLp3nSADTD9V9KgPEuufNpfvwblDdIJLw1s1SxhqLVKfacZw0mKdSEsCwfDbPCffS9vx63vKrNmBr26tS1nVLVBFhTVbSMeDmd2l2O8Ldndlnp2Ba+kr 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z1nLNhH/klC9HISph90jOnELFHz7jv3iQx1xkJBZnJolggBOwSKiTIjtoi+OVEvzReCzwp6/Of6xBS0d8VIfs19TcjrPoHuWBbw+x2SeQ3SlgXl+JuFJyg9srBQASTS2Q1MaYnMONwxJMk+cViCjQTXyN8fICRnAaopTtcWY1ohDUlpeB2TtRX50TxAHST9ucx0Pc9oWKpnBy6fSZqtXdgE21nV2CHC9iwK/F5Jf3nVpR3S9MPuD25U6FWfzNlobiw9XZLM+QUcs6UZH8KHbhYgcivVL2qt4jnmCcg/YTsH3DLocTPEhmnzA80SvVoes4uwMuE0V5jdnQno/vDHOe0b37NdlTP6RykQ2kXS9OlYxnDpR13xO/bxU2LaYbIyS27Zi61vwyI7LMymuAZhjoLCW+2DVIkA5Czlanm1R+PtL4Oe/ArXRyzswAAtf3ag7jUUBRmnIqRM8HhipvOeHIGHopdQg3+K0S65PvZZTTUMKk8LYBXl73utUFH340EqbgjYId3MbNawnlOrCBimGk/1oHV166UK3NEb0SBpwGfd9Qk3ZkwDxfzo9wtyisNc9tAy+LGgKwrpvuckL50vuPDC91UNc8/yGV47pU1DWeoESb0bA5v/upDOM9Hlm6exadrVDEqpFcoprpEn96T4CW5SbwfnIIOPD8EMloXfy3IBewK14uxZfjRIz1N+sD9O0G92d8cMYVsL7s9zIg12gq+XkOMz1TcdxiKrtRFcnXCmEptu3t9T6x+NRmPFQrgNivgpJQT9NzuItC7l/Fw0/TjPYs0bB7I3wTpososXWqORG43+zxeBJ1ENoHLwYxSDfsSZ3eEmJeW+jl9A1weiqcOm3HivbQzgjRJ6xJ9KVruRnPvuaHjeq34fe1Hk3K5tKvjZ+D6rPrLOoV0VgguLJ8tZOv8eksPsFuUdg6yEo7mvSNotaC3JDHb1zRPSWzdkq3faLLftGOQGXGf57SSr3hp/5rR3HsR4qJ9RkQMFvmSwb76eefJ3b5mfEHXe5VxINpK7aHLnPlWuyDxulDmGPEQDlC/wa2qSo9PGUbQHN0Uhk2+oS7xNrM4Mtm7JkPihvf0hlCeNzvJlbK1yTCZmPXgL7nmNmeEKLX973g8dcVmdaMGe0fVTGGjmBH/ax2P/9P6IKK8tP0Th2ARipWL4Y7W2zNzk6b+qFBEXovtpyHJTzvIfb9x+TG0Ka4P0BkNjDdsutkWgB63sXe6VCtzRr/x3StZmylWlvfBcTdvHcJWmf1mrxdwVHGQHRplnKejcsXsrFSaVklyepSW5HaHEmFStAs5sTpFxQSskEEINhMIuSPwWHzs4HrDUPp9KRxYImIY4dMk4CphX1AqB+TTQ9n6nUtDVGtMW+3ZBHlP27CwkjVdUDONwRydr9FRdJIc3mSLPLzh8NE3zpx0/WRf2CjKgSKVVavESzjrDVvph8cNvuN3reivxdJfsWAb4KEWkbaipKEiFWx00QoQHUY71CmJdjzwG/5SGkDUoZFrWJJqM3hXtnICQIf15309CZfZqhJz+wMAHbwqClf1cxGjESn020hg7cuVaHyWxT9PlxeXMgXWlADH90Ldj00lmwchH0U//wyZen9kGPhPJJje+b2fUyUpFTalGKy+qIqyL+Zwk= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11085a27-53bd-4cdd-3937-08db690e4ce0 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:54.5207 (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: cpwbwtbTWu+7YEHBMb5ArynMXcgApaxMTf/p8qbTr9mgSoNy59zv1vh8l5qQBF6UlY2cMyyH3q8pCTDDrVxOOJOFBIkujsiPeiIig2rVp39e7/3z+GDeLNs2TjS/rIJi X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::731; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org An instruction is a 'combined' Pointer Authentication instruction if it does something in addition to PAC - for instance, branching to or loading an address from the authenticated pointer. Knowing whether a PAC operation is 'combined' is needed to implement the FPACCOMBINE feature for ARMv8.3. Signed-off-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/tcg/helper-a64.h | 4 ++ target/arm/tcg/pauth_helper.c | 71 +++++++++++++++++++++++++++------- target/arm/tcg/translate-a64.c | 12 +++--- 3 files changed, 68 insertions(+), 19 deletions(-) diff --git a/target/arm/tcg/helper-a64.h b/target/arm/tcg/helper-a64.h index 3d5957c11f..57cfd68569 100644 --- a/target/arm/tcg/helper-a64.h +++ b/target/arm/tcg/helper-a64.h @@ -90,9 +90,13 @@ DEF_HELPER_FLAGS_3(pacda, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(pacdb, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(pacga, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autia, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autia_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autib, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autib_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autda, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autda_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_3(autdb, TCG_CALL_NO_WG, i64, env, i64, i64) +DEF_HELPER_FLAGS_3(autdb_combined, TCG_CALL_NO_WG, i64, env, i64, i64) DEF_HELPER_FLAGS_2(xpaci, TCG_CALL_NO_RWG_SE, i64, env, i64) DEF_HELPER_FLAGS_2(xpacd, TCG_CALL_NO_RWG_SE, i64, env, i64) diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index b0282d1a05..278d6d36bc 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -396,7 +396,8 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) } static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, - ARMPACKey *key, bool data, int keynumber) + ARMPACKey *key, bool data, int keynumber, + uintptr_t ra, bool is_combined) { ARMCPU *cpu = env_archcpu(env); ARMMMUIdx mmu_idx = arm_stage1_mmu_idx(env); @@ -518,44 +519,88 @@ uint64_t HELPER(pacga)(CPUARMState *env, uint64_t x, uint64_t y) return pac & 0xffffffff00000000ull; } -uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) +static uint64_t pauth_autia(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnIA)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apia, false, 0); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apia, false, 0, ra, is_combined); } -uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autia)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autia(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autia_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autia(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autib(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnIB)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apib, false, 1); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apib, false, 1, ra, is_combined); } -uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autib)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autib(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autib_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autib(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autda(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnDA)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apda, true, 0); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apda, true, 0, ra, is_combined); } -uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) +uint64_t HELPER(autda)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autda(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autda_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autda(env, x, y, GETPC(), true); +} + +static uint64_t pauth_autdb(CPUARMState *env, uint64_t x, uint64_t y, + uintptr_t ra, bool is_combined) { int el = arm_current_el(env); if (!pauth_key_enabled(env, el, SCTLR_EnDB)) { return x; } - pauth_check_trap(env, el, GETPC()); - return pauth_auth(env, x, y, &env->keys.apdb, true, 1); + pauth_check_trap(env, el, ra); + return pauth_auth(env, x, y, &env->keys.apdb, true, 1, ra, is_combined); +} + +uint64_t HELPER(autdb)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autdb(env, x, y, GETPC(), false); +} + +uint64_t HELPER(autdb_combined)(CPUARMState *env, uint64_t x, uint64_t y) +{ + return pauth_autdb(env, x, y, GETPC(), true); } uint64_t HELPER(xpaci)(CPUARMState *env, uint64_t a) diff --git a/target/arm/tcg/translate-a64.c b/target/arm/tcg/translate-a64.c index aa93f37e21..e1e49b7325 100644 --- a/target/arm/tcg/translate-a64.c +++ b/target/arm/tcg/translate-a64.c @@ -1508,9 +1508,9 @@ static TCGv_i64 auth_branch_target(DisasContext *s, TCGv_i64 dst, truedst = tcg_temp_new_i64(); if (use_key_a) { - gen_helper_autia(truedst, cpu_env, dst, modifier); + gen_helper_autia_combined(truedst, cpu_env, dst, modifier); } else { - gen_helper_autib(truedst, cpu_env, dst, modifier); + gen_helper_autib_combined(truedst, cpu_env, dst, modifier); } return truedst; } @@ -3587,11 +3587,11 @@ static void disas_ldst_pac(DisasContext *s, uint32_t insn, if (s->pauth_active) { if (use_key_a) { - gen_helper_autda(dirty_addr, cpu_env, dirty_addr, - tcg_constant_i64(0)); + gen_helper_autda_combined(dirty_addr, cpu_env, dirty_addr, + tcg_constant_i64(0)); } else { - gen_helper_autdb(dirty_addr, cpu_env, dirty_addr, - tcg_constant_i64(0)); + gen_helper_autdb_combined(dirty_addr, cpu_env, dirty_addr, + tcg_constant_i64(0)); } } From patchwork Fri Jun 9 17:23:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274229 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 80E89C7EE37 for ; Fri, 9 Jun 2023 17:25:23 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqJ-0006yW-3C; Fri, 09 Jun 2023 13:24:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqF-0006xb-N2; Fri, 09 Jun 2023 13:24:03 -0400 Received: from mail-bn8nam04on20706.outbound.protection.outlook.com ([2a01:111:f400:7e8d::706] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqD-0004ny-Ho; Fri, 09 Jun 2023 13:24:03 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FHEtUtNejARcOTdorTlSsIB1PukojolY4NghIEnx7szMC9e+FupeWP20vhlQdYxuyzC7mAkY3CHZqBc22npk4gDqaZ/s53O5YDl4mc70JP45WU6ZALFqEdWHXD9lwUbCFqUphJ6YIL2fAP97Lx5lgElda4ykt0WtPKoWCrC92fJAte9TcREJ056Q2HIpTpdJ1gsgApJJ+4pZwUK0O1XIsb6g9GKWx4cE0f0y6mJlT1MQfjfG9W0ugFDHtTsbttTclIp6vn8/VREoP498/8XW4+pRRX24xIAUWzgE0FN7J0c5ibkq63lfVr0NSeGjfYAH+Hi9xUyDOgx+/FeBNHAEWA== 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=lFsA/NscXzn1m1UVysR91UL7Upk5Y9pzyb2gUJB6ATE=; b=WuE1xQsZZJg859s9C+YedstWUJcm53mDKsAqvA/2Q5OJycrV3unSjtQ2WmY1nKIM6dAOcePieSuL83E3CCmlYiHRL75nO0OMLbSQN3LGboyAMyShh9hbTvRtNg3Xvao+oIKA4JHrVgXYBA9bmRIGtWsH+Ln/kt+oDmJRKNf8amKN6k+AvCqVE/uB9bKp+P61YATVYfJW5c9V0seLfmqFL5rkEg6o2HQ2kjKFwWr/WfY6Jysb0EI5dfQPVzNy9bDmlm42360pNjVzlbi5NuMa46JclbUYitQLHezm3xD9agKAnSkf8ecNTpuoageheR/0omIh8BvMLPrsN56QqbXpZw== 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=lFsA/NscXzn1m1UVysR91UL7Upk5Y9pzyb2gUJB6ATE=; b=GupRWy2J0k5LCl9CZWQRSQ4z5Uut7xPvaW6KHtxaUyrrVIkuRd74eSEUDJL7oGmym1PMCcXKGgcSeIsXqejgdMiSNmYNXZDX1YshoSmxYtDFgE5mCVun1RaUX6cOxbDQTYXHtNivnDdX9mh1C2lcIfKu9gepHORIHJDus4qhyBA= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:55 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:55 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 7/8] target/arm: Implement v8.3 FPAC and FPACCOMBINE Date: Fri, 9 Jun 2023 13:23:23 -0400 Message-Id: <20230609172324.982888-8-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: a8291e95-9fb9-4c4a-92b1-08db690e4d3f X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: nFThhXFcXE9tDRRpspQk1iG+zbUTIPdacdA6Z3nrHJ4OYTlacKsyVH0NO9+515JF3hpvgkzZLSnaQi2gp3JR1wivk0eQkRXOBZshFyLEzuiE0G+2vZslU0hS+lN9Tk1s/ZhP2ubKK+k7si9BKVsJkdsxVkLq0zGGLZEEt8hx2GKb0Qcb7VKUrd/KOLHCjNwYGXVWA2TH0Jg90rKtym6lOt+C1KQte5RtG2oalG/rUkylFZqfrqwWm0D6HtINXYsjLl674UbncUO0ogSR/thUkM+iV/9qT3ju6c/sGfKgLJR1GByBo115cK3cTWXBZqhiGFMPWSC8TgMyEKmoLZs8LGekNKD4n8WMi77P7cAfpxU9iVYRDkejFEs8EKZ9e1NDX2d2QfN6vhCVHt4DYfA+lkHNTYQfB+k5pUMGCNWgEYxVBsq0OwyLQFr6eSUb/JDP3qgTofJTVZrFYpWC4HMew765pylOt1KQBnRHfdRqSAuKRiDcmBkRvtQP/E2va7dVc3Qqvmieat0VEvSfUG9UJvznFE+gyXUYVPXpp+0VcKDYnrkDVMfOgPgOOrMGXv1cOIQdRW8i8/KSQNS6INlG2mLw1rRW3A8C/c0nM+eEQYE+KlaG5/IkdVeC8QTDyRBz 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Im+KYSph2VgTG6P9gk4LYTljPCfjhgwrq+6scMB9RfkVU7Za0omgYsRbh5/eWM0AAFzihsieYrry72xk0jAR+YxwR2fCkIONVA+85U9/db/jVoUQX/ggRJbCQiq4BgcoyUPaGbkqXAPz8MdMJ5wdMeFuMA21fLB7+fnZaroxdJJvudteVizRkcLmyHmlJGITw6B/VnvXRkiNDHYJl/WLciUWphzOALyy9A1fdCHNhakhXwxqz93PgLBFzM1ztxSmcRGXjxKA+ixdLmOwWX6ZORvh+5fUU47fP5qE32A+0jMXD2FkJwv8EA6QKlJxEgjE9tCNzSXXG1jjnttNMbA8xM6UIj87jmCB9sdNI+cSUOLaylMJSsCuEcrG3OZ+wLcXDumJmZma63YIEq0NThIxUEzUGsuU4rnb6SvE8/x9/Ab7SKOVXwRMumAsJZWzfJUdRctr6QnBYwXnv6IMCtC08Vt4/oo6ffRw0u5aK5GsrlLHNbQkDb9Ou3gCJYF7yPrPXyJlcnRrU2HvtAa0RFIawCysjb6yjFAOLgJQ94Mq8xR5VbvPFM3fjLPShX955edV1rcLXWIU+l2DNND2R9wbaUrFr1yiyk0Nenc9/DHiA3f7NqSZ9IJjAdl9D1q4f/DJtYm48gXg3vA/O2jt7/mgkt/xYo7JqGAVaAI40pYjzNYJjdQm3Qp6JSNgkIcK/Z/OuUNb9Nv9fK2jLM35zxLUxdL0jYMDEsiXyoO4dRmDUMZeS9Cf8EbK7TBQw0LjGAxC4omEqK4TpgPo5DfdDTKwfSP55WPKPsjyvOvRctkKsyBbQ4PynLJz9WolUPpoPMk714npKBNR0Myabo57rsIeIbsLlTe3VotLtEHR3A48zdLdMMQoyV3Hb6CsBFzerRdSwxq91HCX4U+urhNoqnqkJ7X4K81EUCJhIl0YGfupE7DnqegspoZ4MJwrJ79tZTKWa1kKPLKwNb+vAkethphwDBS1g4JJ73YQRDQFJRFwEEUV9nRsR3dBDDkaHBp4vom3GMFaIGf7f7ubMiMUQIucmKJcJFLXH+sg8aUe7zEDhXCaB1TTm8lfisBb9N/GK4oez6M9t93bqavcFfXVN0K2ZvzqDZG/NaHsvWg5ENMK77Y16oTDK/eFKI0JVnEKeRrSCMMPCaZGJ1/tZQvKis7f4ctDJ2G7h+iIqCgjc7Z9EF/8R3dUQ5/pDKzMKbUly0ZYHGnrdP/nwOPVYPGVGnvhwGsKYgk8NuJWh+cKA1K+HVEOpbUClI202BqfNl3aVAUbw+d+ORzcFgmJM4QJXn2wvXTaJyxmP2+qzNYmhaltYglo3IvNUvxYyzp5tgsMyL42xjl4quwQDzI+NrJyQR0kd3jO6+NRMls/uhPBMCbfCAVofMgS+advntIF6G9lHkZtNhx2dfdlXOOSGb2YMLFpwdcByn6sMX9XV6sZXd+x624Vq3XVSLdpWhHyOZI90EbNXFjuzWozt0PGEx3HGfSS4kIdj4UxPEJzfkU6bFhbOogFDnkQUzI4NRP/d8RS8OiJebMIMM6KQejRf2w8fdHxa761yg1+6MgjmjjX1BRp+sXqPTwP7WRzXAM0d8c7/efa9sqoYATlfPz2cJTrMPz/0SeebO45UTL8ruN/l9SMt/0= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: a8291e95-9fb9-4c4a-92b1-08db690e4d3f X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:55.0734 (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: dFtzHalMEJ2GnvGQ9GMxbOHBDcbtFKKNHpmyHUfHZLsIf6XPmHvNHj8Kt7YTFAal0v0FFdaxD1NbYbJKcFUdKuSUxuYPghoNsphK70O/yFoM+5zlEgd2Tfjfl/V5fWOW X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::706; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/syndrome.h | 7 +++++++ target/arm/tcg/pauth_helper.c | 16 ++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/target/arm/syndrome.h b/target/arm/syndrome.h index d27d1bc31f..bf79c539d9 100644 --- a/target/arm/syndrome.h +++ b/target/arm/syndrome.h @@ -49,6 +49,7 @@ enum arm_exception_class { EC_SYSTEMREGISTERTRAP = 0x18, EC_SVEACCESSTRAP = 0x19, EC_ERETTRAP = 0x1a, + EC_PACFAIL = 0x1c, EC_SMETRAP = 0x1d, EC_INSNABORT = 0x20, EC_INSNABORT_SAME_EL = 0x21, @@ -231,6 +232,12 @@ static inline uint32_t syn_smetrap(SMEExceptionType etype, bool is_16bit) | (is_16bit ? 0 : ARM_EL_IL) | etype; } +static inline uint32_t syn_pacfail(bool data, int keynumber) +{ + int error_code = (data << 1) | keynumber; + return (EC_PACFAIL << ARM_EL_EC_SHIFT) | ARM_EL_IL | error_code; +} + static inline uint32_t syn_pactrap(void) { return EC_PACTRAP << ARM_EL_EC_SHIFT; diff --git a/target/arm/tcg/pauth_helper.c b/target/arm/tcg/pauth_helper.c index 278d6d36bc..f42945257f 100644 --- a/target/arm/tcg/pauth_helper.c +++ b/target/arm/tcg/pauth_helper.c @@ -395,6 +395,13 @@ static uint64_t pauth_original_ptr(uint64_t ptr, ARMVAParameters param) } } +static G_NORETURN +void pauth_fail_exception(CPUARMState *env, bool data, int keynumber, uintptr_t ra) +{ + int target_el = exception_target_el(env); + raise_exception_ra(env, EXCP_UDEF, syn_pacfail(data, keynumber), target_el, ra); +} + static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, ARMPACKey *key, bool data, int keynumber, uintptr_t ra, bool is_combined) @@ -414,6 +421,15 @@ static uint64_t pauth_auth(CPUARMState *env, uint64_t ptr, uint64_t modifier, uint64_t xor_mask = MAKE_64BIT_MASK(bot_bit, top_bit - bot_bit + 1) & ~MAKE_64BIT_MASK(55, 1); result = ptr ^ (pac & xor_mask); + if (cpu_isar_feature(aa64_fpac_combine, cpu) + || (cpu_isar_feature(aa64_fpac, cpu) && !is_combined)) { + int fpac_top = param.tbi ? 55 : 64; + uint64_t fpac_mask = MAKE_64BIT_MASK(bot_bit, fpac_top - bot_bit); + test = (result ^ sextract64(result, 55, 1)) & fpac_mask; + if (unlikely(test)) { + pauth_fail_exception(env, data, keynumber, ra); + } + } } else { test = (pac ^ ptr) & ~MAKE_64BIT_MASK(55, 1); if (unlikely(extract64(test, bot_bit, top_bit - bot_bit))) { From patchwork Fri Jun 9 17:23:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Lindsay X-Patchwork-Id: 13274237 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B85E1C7EE29 for ; Fri, 9 Jun 2023 17:25:56 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q7fqd-000751-N2; Fri, 09 Jun 2023 13:24:27 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqL-0006zn-18; Fri, 09 Jun 2023 13:24:10 -0400 Received: from mail-bn8nam04on20706.outbound.protection.outlook.com ([2a01:111:f400:7e8d::706] helo=NAM04-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q7fqI-0004ny-DB; Fri, 09 Jun 2023 13:24:08 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JCEZJc5QzqW0PlJKxHOd6Vrfn+OYaX0N94vtO/dotrMi56n/hmyt4k/aVq+sKwScnqr9v652hHj6f/8oVjP/SloPH4XCtEpRjUvh5uOd2pigCOr4QS3K1X8wG84p9IBFGwnYZBd0ZoLG1Ztd/nLgwWMnaDBjxNkKvByq/nGJ96rYzXpHEkJ1Xl3K+xV4YlrzH9QmMf6w5jofc9/pWu72SowEI41wAfawFIz+Omb9ohoAQBQ8Il2r3FIOySJ2Ah20iE5p1uVxoK5+01npQoxp14gE24Tl8EDM7oW/lBJhRsuky3TXCFoYS7s9BRXjYomRmEGuGJr21XUSLIY0ilp7fg== 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=rG0MjqHOncKe64g/eFBXwRCtLf0aeWOUoKS30sy8Jh0=; b=aOAJq20ObVR6SUruCmbwpT/eiqOxJ2SviEU0DvWB40c+yHjwfLcMWQV7oECj2j8rRdbWe6VKc0eYRlcwuqA5TwQYqeIZLgvfcnnxgHgk+N+yd3Q1KrV3wiQfb4G0oW9mg/4IgAs1AtVZNClZmBrRo17epxDdQz3m/VzxcozX4WP0Ha8YwE9fZctSV9eS1eiJN7S7l/5V1CF0OM2dvSt5PGgW79AT4Ab7u+EeoCVzy1qByNdxYEBgycUa1jE3PI2+Q78+nvcDUZT1BoFZtUhAmThIR/YC3yI+ZT0FPwoevpZkAkQXmVOh38XMeAWaN/FDtH2vq3YbzPz5tmoSt1S8/Q== 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=rG0MjqHOncKe64g/eFBXwRCtLf0aeWOUoKS30sy8Jh0=; b=SuiXD2qf8f2lZkM8oxCjDzjGczthPYb9fPEQ14f/NT01BzgaKBg4EhDKPWCXeMX+CUiSdKF2ejQAZ0erRzDlpL58fzezSdDNoXwzlRnYa2axvZFnpkFlYWqYrdttr7R/2ojkcKSWgF6POad5cIB2jys5o9dam+I6SloKFpHtbnc= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) by SJ2PR01MB8126.prod.exchangelabs.com (2603:10b6:a03:4fb::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 17:23:55 +0000 Received: from CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed]) by CH0PR01MB7124.prod.exchangelabs.com ([fe80::9a78:4703:c6a9:16ed%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 17:23:55 +0000 From: Aaron Lindsay To: qemu-devel@nongnu.org, qemu-arm@nongnu.org, Richard Henderson , Vincent Dehors , =?utf-8?q?Alex_Benn=C3=A9e?= , Peter Maydell Cc: Aaron Lindsay Subject: [PATCH v3 8/8] target/arm: Add CPU property for QARMA3, enable FPACCombined by default Date: Fri, 9 Jun 2023 13:23:24 -0400 Message-Id: <20230609172324.982888-9-aaron@os.amperecomputing.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230609172324.982888-1-aaron@os.amperecomputing.com> References: <20230609172324.982888-1-aaron@os.amperecomputing.com> X-ClientProxiedBy: CH0PR03CA0009.namprd03.prod.outlook.com (2603:10b6:610:b0::14) To CH0PR01MB7124.prod.exchangelabs.com (2603:10b6:610:f3::20) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR01MB7124:EE_|SJ2PR01MB8126:EE_ X-MS-Office365-Filtering-Correlation-Id: 8697f11a-876e-4dbb-5161-08db690e4d82 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RkEuCOfBWDE3Mwd/SULuvS2Sxnpk6sSwnaLWOtoCXwdYe8xuOeFTZFtFvPY5XY7HJd47J6KgzqYINFqHPviCI8LoXjAroPQb3mwBcFA4LTC6uKVsvquzBliNWh207cdbOk7jh7t9sEsAMUtO4RhafOzCcpJp5y5J/u6wUazt+bepHOwMHlPOsLGE0bb5N4FRKNsOwWEmcrOfwdKdfbvqCyP6zDUXfC43WsG2a4Yvrwu/q/bc5e/poGogPuHyv6i/g2VnbhCfFi4NhFOzkC95RYvWTaPXvq2hkWc/jtxksdpc8hu3DLly9cDwD3wqB9TBuaJZ6yuzZiLgm0fVjzUvbIisiPd4bl775yPDke+VFSXUjQl1S2jxFRtVbdzPwVvtCmIRbqhj6dHV5OO2y99v+soJImznrN0UMFDngd/EMHJU2gUC6hgciCfjAmqsq/CuIavKf0BDHRAcKX8YBEtqcIU/FMe/bYVbo61haIy3wKBs/tq0lX11Kw+BlzG+RvDU0LKvh5SCXySM3WzAYRyjSmPryofpPsYEW+GWkANL7aOsOCysDOvCSC+yJ7X9r0n49/+qsuB9/K/qOgnSmComwf0C9+iXIhFjXQ4Wl6zOzqwE6HlzdoHtX49rekGpVl4J 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:(13230028)(4636009)(39850400004)(396003)(136003)(376002)(366004)(346002)(451199021)(8676002)(316002)(5660300002)(66946007)(66476007)(66556008)(4326008)(2906002)(8936002)(41300700001)(110136005)(52116002)(6666004)(6486002)(6512007)(26005)(1076003)(186003)(107886003)(2616005)(6506007)(83380400001)(478600001)(38350700002)(38100700002)(86362001); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Jz/BZoxnJILxNvG0PYjgZPzO7LlohNRMR7b0OSK133mAM8hJhrfd6ADLYggZOMCOwdKvXcqfH2Cvjn/V1L8RS8QvDg1BcHXPQjjvyCwrsXTsdLVxddceblPXhcD+TQllMRMAeVvltUeQv2ttAVsa4W8x0eI5wSPbb1OGvd/sqOb8Qa2i6OjyzNVNzD1uQCSMbOq0YnVZi7rZvHYt2AzpHOJuB+QUSrA03OcBBk9A6oHCfDFZ/TXY1K0SHUU0GymOexsMWj0ry1WBfo2KgHMz+U6DAAzOTmgX3AxqKYytt1u32LfqM2pO1QqlwUlhBstWydFY5XDBXBUrMuTAI3LczvUwlEvOHPlxTo5T4zMI1PaBTtKdukEnPMXy6wWkpeRbq5A+DYRPjoyBO04LYgN1BsK4iqqkxyuga7rfHrRYUsv+ABh7qblgUPK3O90goeabUQ4Z5AO59jhf8rPSJUei+kRPoWgwhaZxKKBqLwBLFtwUQuFE/EkmQLU4Obk48qQOuouf7iW8g+A3dQg3/uKAps9Wgo/EyqQrE2PrW6+Gm9eQHWDv+2sOoaIqU8u7IVqWHXZcfXRBj5ZlFMYFlc/e+OhSalOoz30ole/ZlJozI6XEFTotnvTyIXplJFQu5XjJKYzjnfpNiXQtsmIsF6jtllqlh1rWHOK4UvvBBMz5uPYgxmRk7VNKjZjExzo5TvPg47TvzdRmLPFm3HzbUm91P4sQVbHLgscHFsClqrCdhddPffgA6PfixeKSei33hnihwUYJ7FyL1x6epher46Wtsmq7CpNRpg/YUFyvIyaD7AnyxmYzK6cL25jajm8up2aKicQw+ToSpM5KX1+vcqXs6ZozDpvT8367tzlMjPXCm1GE13iyUqhNfQ64g02NMBgvEEKbI8Cja+EBct4Wm83lDi9B6I51LCMpttKLMLyhZm8VRH0J1h6H0nOuL6cW6AFWeacPiephFC+MZi/1p2YMkpgx4rcaNWJbPzpUobHDjAcpLWK3mwEsLc8hGdq+58SVJDqDOT5JxBUzVyGn8Fm1nIK6LjCivQYWer1F/OwtOqscXfMp8XiWHbp3GjuCx/5TL5Nxj8vL58CBHJw+Wt3c8Tz2it3iRLh2qWrm5WmE4rVTXakNElbIrdCCjAVBNKRX7XhIJOcI/JEe05RD0ahrEqWiErUb8VhOPlFEMDbxFlxEPwOC0ZwphAa+RRr1x85+k2qpGLOfKm7vaTK04YXo2XrSKSD7EpAK9qJ//fSF6AwaiTf3d197p0UUNoUS42ubVzv53aS0VM7Ml9ilvC09v920zrNeSbv6ojPQQZYi16tScO3ivN0Ci45089URwQR4SiwA3MzSdpYp1wlZD0TMDIVF/F6pSci/6Hl6nbev786ZkknZ+jdpcmqCGOMxRwqjp12fDEdQEzEy7hLHepfCLO4DezX8zw56gqnZeeczE+KYtKRz45P3qz/l5zhgKeQVJXgyzu4Bt5SGRLka3REldaGYWDZW+HSX75GA+ZfNaC2sb05NnTfY56zqaMOtzRiiGBFBGwfxdMM74LSG8ltGBCq/5OAjrEFqAr2iEveVVsxh1NlRBLn44YfCUKW3+hDHyTCh2ZBqkiEozt1D/oT6HDswJTFFftkItoTatujLHSk= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8697f11a-876e-4dbb-5161-08db690e4d82 X-MS-Exchange-CrossTenant-AuthSource: CH0PR01MB7124.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 17:23:55.5204 (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: nLOiemtIf8paoBvXvd/kyiXJIl4gz2++dVuFiegF3m9hRoTHzeEcY+7Xps1p4IORMwLmvyuNFzhGXt6RgDAdqljzG7zslpPwkDRx3ql0LpZql3hg0vTfi/H9Nf1DQoau X-MS-Exchange-Transport-CrossTenantHeadersStamped: SJ2PR01MB8126 Received-SPF: pass client-ip=2a01:111:f400:7e8d::706; envelope-from=aaron@os.amperecomputing.com; helo=NAM04-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Signed-off-by: Aaron Lindsay Reviewed-by: Richard Henderson --- target/arm/cpu.h | 1 + target/arm/cpu64.c | 48 +++++++++++++++++++++++++++++++--------------- 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 22dd898577..0c4c6c9c82 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1061,6 +1061,7 @@ struct ArchCPU { */ bool prop_pauth; bool prop_pauth_impdef; + bool prop_pauth_qarma3; bool prop_lpa2; /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 6eaf8e32cf..b0a5af7a31 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -473,9 +473,6 @@ void aarch64_add_sme_properties(Object *obj) void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) { - int arch_val = 0, impdef_val = 0; - uint64_t t; - /* Exit early if PAuth is enabled, and fall through to disable it */ if ((kvm_enabled() || hvf_enabled()) && cpu->prop_pauth) { if (!cpu_isar_feature(aa64_pauth, cpu)) { @@ -486,30 +483,50 @@ void arm_cpu_pauth_finalize(ARMCPU *cpu, Error **errp) return; } - /* TODO: Handle HaveEnhancedPAC, HaveEnhancedPAC2, HaveFPAC. */ + /* Write the features into the correct field for the algorithm in use */ if (cpu->prop_pauth) { + uint64_t t; + + if (cpu->prop_pauth_impdef && cpu->prop_pauth_qarma3) { + error_setg(errp, "Cannot set both qarma3 ('pauth-qarma3') and " + "impdef ('pauth-impdef') pointer authentication ciphers"); + return; + } + + /* Implement FEAT_FPACCOMBINE for address authentication and enable + * generic authentication for the chosen cipher. + */ + int address_auth = 0b0101; + int generic_auth = 0b0001; + if (cpu->prop_pauth_impdef) { - impdef_val = 1; + t = cpu->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, API, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR1, GPI, generic_auth); + cpu->isar.id_aa64isar1 = t; + } else if (cpu->prop_pauth_qarma3) { + t = cpu->isar.id_aa64isar2; + t = FIELD_DP64(t, ID_AA64ISAR2, APA3, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR2, GPA3, generic_auth); + cpu->isar.id_aa64isar2 = t; } else { - arch_val = 1; + t = cpu->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, APA, address_auth); + t = FIELD_DP64(t, ID_AA64ISAR1, GPA, generic_auth); + cpu->isar.id_aa64isar1 = t; } - } else if (cpu->prop_pauth_impdef) { - error_setg(errp, "cannot enable pauth-impdef without pauth"); + } else if (cpu->prop_pauth_impdef || cpu->prop_pauth_qarma3) { + error_setg(errp, "cannot enable pauth-impdef or pauth-qarma3 without pauth"); error_append_hint(errp, "Add pauth=on to the CPU property list.\n"); } - - t = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, APA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPA, arch_val); - t = FIELD_DP64(t, ID_AA64ISAR1, API, impdef_val); - t = FIELD_DP64(t, ID_AA64ISAR1, GPI, impdef_val); - cpu->isar.id_aa64isar1 = t; } static Property arm_cpu_pauth_property = DEFINE_PROP_BOOL("pauth", ARMCPU, prop_pauth, true); static Property arm_cpu_pauth_impdef_property = DEFINE_PROP_BOOL("pauth-impdef", ARMCPU, prop_pauth_impdef, false); +static Property arm_cpu_pauth_qarma3_property = + DEFINE_PROP_BOOL("pauth-qarma3", ARMCPU, prop_pauth_qarma3, false); void aarch64_add_pauth_properties(Object *obj) { @@ -529,6 +546,7 @@ void aarch64_add_pauth_properties(Object *obj) cpu->prop_pauth = cpu_isar_feature(aa64_pauth, cpu); } else { qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_impdef_property); + qdev_property_add_static(DEVICE(obj), &arm_cpu_pauth_qarma3_property); } }