From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2074.outbound.protection.outlook.com [40.107.21.74]) by sourceware.org (Postfix) with ESMTPS id E74503858434 for ; Wed, 12 Apr 2023 12:27:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E74503858434 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Psrb01KZdBc+3gnqZNkhovuybRd5fsWY+iSzFNd2m5g=; b=44wod1oRZzF7sUe6J/EmgPWi3fH90rZEvv518UpLV8HymyWR4JZCJ/8C4Jct7AT2pmPMBoOe64r7X0RhI6Rgj3kXyYoE+hSCmKl0Bh5nab6tsJXe5mqyRkccZnmUIfuMGOcOp/W+EK4VFjhNa44PiLaOI2oi1hBARLW9yE8EWzg= Received: from DUZPR01CA0041.eurprd01.prod.exchangelabs.com (2603:10a6:10:468::19) by DU2PR08MB10158.eurprd08.prod.outlook.com (2603:10a6:10:46d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Wed, 12 Apr 2023 12:27:33 +0000 Received: from DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:468:cafe::aa) by DUZPR01CA0041.outlook.office365.com (2603:10a6:10:468::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 12:27:33 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DBAEUR03FT007.mail.protection.outlook.com (100.127.142.161) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 12:27:33 +0000 Received: ("Tessian outbound 5bb4c51d5a1f:v136"); Wed, 12 Apr 2023 12:27:33 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fb7d32edf28d6198 X-CR-MTA-TID: 64aa7808 Received: from 08afb65b06cb.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 03F97AD4-A72C-4B0C-A5AA-99A65D67973E.1; Wed, 12 Apr 2023 12:27:26 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 08afb65b06cb.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 12 Apr 2023 12:27:26 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=bMONRjUWFlTogq1Itm68aO8lv5gjfkFKo+ag+6bbQWDmUV/Di7OkEp5KsxGkgyGJFgiB59d1W/E34ACIUIrpd7Q4JvCywZqIHrxYVK9qypJ86sqdY8oloyxKQ9/KIQVdKJM3KxUeuf45IzraA6/6yyez5XQDMivwtQgvaxwRY8tv9KJBeq7//BL0PSQVlLi1cnFyHatSpDGYXNj/xaj16i0mvwznSFZgtCkuq3myBvaWS6ha7Rnc0a/HKFDVZwZyWb9jjZJ9P1qFEmcrFgENS6Pp3MhkvNsfBy+nwSesFo6aJ3sCxYVYk3EfQ/p7V//6OUwNimpeudOxUKAcwgTV/w== 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=Psrb01KZdBc+3gnqZNkhovuybRd5fsWY+iSzFNd2m5g=; b=XRY/asoOyEzCrMbMUPaLMN0NSCg9UGPJQ5ByL55PHPPdesCLwxeG6bBfRbJx9ZkRBcLT0nCDIb62zgt3qX5yVF44whi6BbXlgDyfXjPV6HBJPJejLTJAQPwBvNHptJpcgww9ShCnmOCiX3Akwue+IU/Eu3IoIp16lLT6xOBzlpiNLbXGp34nC8QqQBW0+57QzwiVbStesXSrlHadd0eVeyp1kXd0T5GXUDklhuzBei27Q41E2TqOg1FDTQ4lyPMVeP5gOaUXK4CRQPXJ9povdSPLwcabELMWoxXoeaa/5d/qhWEnDMRAVJ6LqGPHbUsLrfHMBTJaMPRFVQwX3oJZMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Psrb01KZdBc+3gnqZNkhovuybRd5fsWY+iSzFNd2m5g=; b=44wod1oRZzF7sUe6J/EmgPWi3fH90rZEvv518UpLV8HymyWR4JZCJ/8C4Jct7AT2pmPMBoOe64r7X0RhI6Rgj3kXyYoE+hSCmKl0Bh5nab6tsJXe5mqyRkccZnmUIfuMGOcOp/W+EK4VFjhNa44PiLaOI2oi1hBARLW9yE8EWzg= Received: from DU2PR04CA0032.eurprd04.prod.outlook.com (2603:10a6:10:234::7) by AM9PR08MB6723.eurprd08.prod.outlook.com (2603:10a6:20b:2ff::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.28; Wed, 12 Apr 2023 12:27:23 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:234:cafe::59) by DU2PR04CA0032.outlook.office365.com (2603:10a6:10:234::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Wed, 12 Apr 2023 12:27:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Wed, 12 Apr 2023 12:27:22 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Wed, 12 Apr 2023 12:27:22 +0000 Received: from e129171.arm.com (10.57.80.123) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Wed, 12 Apr 2023 12:27:22 +0000 From: Luis Machado To: CC: , , , Subject: [PATCH,v2] [gdb/aarch64] pauth: Create new feature string for pauth to prevent crashing older gdb's Date: Wed, 12 Apr 2023 13:27:22 +0100 Message-ID: <20230412122722.2606425-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411224327.2142994-1-luis.machado@arm.com> References: <20230411224327.2142994-1-luis.machado@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT061:EE_|AM9PR08MB6723:EE_|DBAEUR03FT007:EE_|DU2PR08MB10158:EE_ X-MS-Office365-Filtering-Correlation-Id: e346cdcf-e06c-4879-4afc-08db3b514a8a x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: vKUVX3ivz424qCGtoUuidqxnFZ/EflK2Oxn5o6KSMH95BLGtpNAC2QvWHO6t9qU7Wve6eRnPc2F4euLHWh4Rfzoc1SnrFSciy8kZclt/04VttduCLVkfGHjXxrCbtRytJc7CaSnDQk1LAGU110/Vx1Krw/+WET0GLArzZcn070bJvg6ICTuX774WBo+vmbDFKvkxt4Zhb7mXGfKv/Qu7zQcu++a8h+mzJWYR49behvsXR1sM7iTnO61dkpnTBAbGRl6D1A6jrO66KlbhYau9WaOoNEdeVAAMIzC/JYSEVbjZBG6OGPB7hw2qrK7sfLMx5rHTdJcMkaGyIikYsXSU6TZO0uXFpWk+i2cp84LF0YDXDmC+V09VyzzNYeMDa+F1VZFW0qyvBZmx2A1wRYuCBZZQfuA7qgKMYXdpGyIMx564pmJbPN/xQgiAEJSvEgNfDuEySFj/Mr1Pi47MuYuw8oor/fQV0wwI/+dS3UCkp7QQUL+wmfjdYXjXz7j0mxyvqTOfnO4zairfRZsl1AnIsb7Ja9Ww4kOQnGDycOuQ3CkX9EbmkPlGqsy/Lsg5Sn3FJTerjaC5GV25y5RyZJgyeJ4P2xNVBrDD59SLPEDJ30JSVewiggwSt1iuCoMfokzDK1ucpiyNC2phSzG7kzB7deqconno4j2qINN9sfFyQ36QLs8EAUYGCvo7L+EHDRJxkA3pynxKpfsbK527+ioclEEB60FH2SgHhzvcu/YSg7g= X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(396003)(136003)(376002)(451199021)(46966006)(36840700001)(40470700004)(40460700003)(478600001)(54906003)(316002)(5660300002)(8936002)(8676002)(2906002)(36756003)(4326008)(44832011)(40480700001)(86362001)(82740400003)(6916009)(70206006)(70586007)(81166007)(356005)(41300700001)(1076003)(26005)(186003)(82310400005)(426003)(336012)(83380400001)(47076005)(36860700001)(2616005)(7696005)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR08MB6723 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3e228a30-867e-4b00-12f7-08db3b514470 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qqhek9AfTCEtt3BT9HQtmuINumbHBw/di0FMao0dzy3RkZxNjU+sDGc+GBBMGZmHl2wO+2D8EK3Lc91hGOuUeossbXfVSXnWEyAXQ9yc1/aVzusbhbpGAPjpQMAVHVtxcF18rhF973Qlq7FK7+IfnvReS3KySMlIpueoj8goFZsQM3TwHkwLODc+kky4EvBD/oX7P9QAnhD++F8kQLEUFRlvs2+Qui8LecBSvp0XKASdgtjq2aBEmdQFl9dmbI/oBnN2HecaFeCtvudFzaMSpGTZ8Y5ZERf9Ue9fE2ZfHExWS1w83diqZ6ZvDhTB20+UTNMtTWIHjJkaaMceSzrXAeCQkHbndNskEDopADGxI9YA0pgNQB+fGTFNQIbSWCiM0rioppWuTDXw44WIg52FZctYpo0jwmYuaJT2Y8kKo756p7ce1y0/41Yj4tDyxWjpxD6bQScbNSi8xf9/TKa4mDjpIxA1bnR33vsCYVXXfnmp1JBvKrIbRAoOSuvdgLYPNlqo1WEcdSqxpjdUN6lkJCHokKG7YY8O4xKyLGFY5IGhwQFo7PeFPeOmPgJnNeUUk4j9SUliOTLo71d1i099jlNKRcYGQEuQMVZ+t/xV+eYSsQHSzeLRg9Nw4xGhbLzoTx0za/MqRqd9X2rIuubd47vPKwRNMYa8F1TP3WOn6/Lpu6Y7DW2j6msuVNjTuokQ4sSgswJPsxwCGgs24hUzCg== X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230028)(4636009)(346002)(136003)(39860400002)(376002)(396003)(451199021)(36840700001)(46966006)(40470700004)(82310400005)(2906002)(5660300002)(8936002)(41300700001)(47076005)(40460700003)(83380400001)(6916009)(4326008)(8676002)(70206006)(70586007)(36756003)(316002)(7696005)(44832011)(54906003)(478600001)(86362001)(1076003)(36860700001)(81166007)(336012)(426003)(26005)(186003)(40480700001)(82740400003)(2616005);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Apr 2023 12:27:33.2024 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e346cdcf-e06c-4879-4afc-08db3b514a8a X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: DBAEUR03FT007.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR08MB10158 X-Spam-Status: No, score=-11.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Updates since v1: - Adjusted the documentation flow and details. Older gdb's (9, 10, 11 and 12) have a bug that causes them to crash whenever a target reports the pauth feature string in the target description and also provide additional register outside of gdb's known and expected feature strings. This was fixed in gdb 13 onwards, but that means we're stuck with gdb's out there that will crash on connection to the above targets. QEMU has postponed inclusion of the pauth feature string in version 8, and instead we agreed to use a new feature name to prevent crashing those older gdb's. Initially there was a plan to backport a trivial fix all the way to gdb 9, but given QEMU's choice, this is no longer needed. This new feature string is org.gnu.gdb.aarch64.pauth_v2, and should be used by all targets going forward, except native linux gdb and gdbserver, for backwards compatibility with older gdb's/gdbserver's. gdb/gdbserver will still emit the old feature string for Linux since it doesn't report additional system registers and thus doesn't cause a crash of older gdb's. We can revisit this in the future once the problematic gdb's are likely no longer in use. I've added some documentation to explain the situation. --- gdb/aarch64-tdep.c | 15 ++++++++++++++- gdb/doc/gdb.texinfo | 24 ++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) diff --git a/gdb/aarch64-tdep.c b/gdb/aarch64-tdep.c index d8349e4ccdb..ec0e51bdaf7 100644 --- a/gdb/aarch64-tdep.c +++ b/gdb/aarch64-tdep.c @@ -3500,8 +3500,15 @@ aarch64_features_from_target_desc (const struct target_desc *tdesc) return features; features.vq = aarch64_get_tdesc_vq (tdesc); + + /* We need to look for a couple pauth feature name variations. */ features.pauth = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth") != nullptr); + + if (!features.pauth) + features.pauth = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth_v2") + != nullptr); + features.mte = (tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.mte") != nullptr); @@ -3679,7 +3686,6 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) feature_core = tdesc_find_feature (tdesc,"org.gnu.gdb.aarch64.core"); feature_fpu = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.fpu"); feature_sve = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.sve"); - feature_pauth = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth"); const struct tdesc_feature *feature_mte = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.mte"); const struct tdesc_feature *feature_tls @@ -3773,6 +3779,13 @@ aarch64_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) } } + /* We have two versions of the pauth target description due to a past bug + where GDB would crash when seeing the first version of the pauth target + description. */ + feature_pauth = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth"); + if (feature_pauth == nullptr) + feature_pauth = tdesc_find_feature (tdesc, "org.gnu.gdb.aarch64.pauth_v2"); + /* Add the pauth registers. */ int pauth_masks = 0; if (feature_pauth != NULL) diff --git a/gdb/doc/gdb.texinfo b/gdb/doc/gdb.texinfo index 45a0580bc29..83cb392416a 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -47980,6 +47980,30 @@ has a signed link register value that needs to be unmasked/decoded. Extra registers are allowed in this feature, but they will not affect @value{GDBN}. +In the future the @samp{org.gnu.gdb.aarch64.pauth} feature string might be +deprecated in favor of feature string @samp{org.gnu.gdb.aarch64.pauth_v2}. + +The @samp{org.gnu.gdb.aarch64.pauth_v2} feature has the exact same contents +as feature @samp{org.gnu.gdb.aarch64.pauth}. + +Targets reporting Pointer Authentication support via the remote protocol +should always use the newer feature string +@samp{org.gnu.gdb.aarch64.pauth_v2}. + +The reason for having feature @samp{org.gnu.gdb.aarch64.pauth_v2} is a bug in +previous versions of @value{GDBN} (versions 9, 10, 11 and 12). This bug +caused @value{GDBN} to crash whenever the target reported support for Pointer +Authentication (using feature string @samp{org.gnu.gdb.aarch64.pauth}) and also +reported additional system registers that were not accounted for by +@value{GDBN}. This is more common when using emulators and on bare-metal +debugging scenarios. + +It can also happen if a newer gdbserver is used with an old @value{GDBN} that +has the bug. In such a case, the newer gdbserver might report Pointer +Authentication support via the @samp{org.gnu.gdb.aarch64.pauth} feature string +and also report additional registers the older @value{GDBN} does not know +about, potentially leading to a crash. + @subsubsection AArch64 TLS registers feature The @samp{org.gnu.gdb.aarch64.tls} optional feature was introduced to expose -- 2.25.1