From patchwork Tue Apr 11 22:43:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 67654 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 759043858404 for ; Tue, 11 Apr 2023 22:44:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 759043858404 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681253060; bh=5OrEKPiwXu6/AqUjMfEPdpyD4Rl5x7uXS1pkUJdgCSo=; h=To:CC:Subject:Date:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=bAleqb5OqihjYaJYG6e1DetQVlrzRhYUwhKIecGh/pU1AcKPPLGeAf44gqDJVX1om AJk+5CZFRlkCVDUZfKtUV4WMMpy0BKuTWILw1UAteLmFTwsaqswuniXwB2pbaJW0e9 HE4bQHT1VyLjfi/V1I3YsAVlXFV2hcNsxiGXezcg= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2075.outbound.protection.outlook.com [40.107.8.75]) by sourceware.org (Postfix) with ESMTPS id 34D113858D32 for ; Tue, 11 Apr 2023 22:43:53 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 34D113858D32 Received: from DUZPR01CA0089.eurprd01.prod.exchangelabs.com (2603:10a6:10:46a::12) by DB4PR08MB9310.eurprd08.prod.outlook.com (2603:10a6:10:3f6::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 22:43:49 +0000 Received: from DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:46a:cafe::df) by DUZPR01CA0089.outlook.office365.com (2603:10a6:10:46a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 22:43:49 +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 DBAEUR03FT061.mail.protection.outlook.com (100.127.143.28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 22:43:49 +0000 Received: ("Tessian outbound 8b05220b4215:v136"); Tue, 11 Apr 2023 22:43:49 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 0d10a0344a4a11f6 X-CR-MTA-TID: 64aa7808 Received: from c8129ae87037.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 1BA437B8-630F-4121-BC1A-FC4FD537FF44.1; Tue, 11 Apr 2023 22:43:43 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id c8129ae87037.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 11 Apr 2023 22:43:43 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=eRSAH13IyVad9pIHCT+ZHtMU9G3GjcgnQI0x8ku4fQMGIgjDzTZ1V5OdBCHh5WNBltp29BwyvDdMmMTG15z3fiRHcrut22T4ku7ugR8s7OG5GrQ1GLDclJnd2O+p99udmTo4QjDPDc1E2l4rLZe06xdoUYcyBpkJLf3bUNUtNcOXIr9w+eOTTw8wUqJzZVbH6WtuBPFCT684gEWDyUmA7p9hNES+9PZKFwFHEBPMyPx3jzPhozI9k0QYp4C7soh12b0+QpY9XaB7T74WZ1fkXF99HFSaxXl0XegqnnPnSKAh2Mo5DwXPh8HFApoYo9SxZ11lmhVvYQUcFG1nIm8DAw== 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=5OrEKPiwXu6/AqUjMfEPdpyD4Rl5x7uXS1pkUJdgCSo=; b=jplxGLVTLbWFUZ47vnvu0mq3MaNlGEjLsyK1Frb9yZCHnwEVPznzOm8M8SZt/9chXOLpizBYGsd99mbeEooaMRNVjTD5SOFDqHuqc1zXcqCsm958bdggqWrZgU8kSqkJaGZoZmh4b5KO9naOnEteFq2hljiBKTWOwG95JO1/DDvyoRQtBooAi8RpyjHdoxzo0ac2q6KSl2n5HexgD3Ofmdc11x41O2CY16P8oTaBOf2qHXe5M7lm2/Ur/9zXLtdH2A33qJj5+2Dc6Dt4F0b/m1duqURkl7JBXLLaOncxcQFNWPGSKJ4b3gBTcp3kIj1JooxnABdSPOaoFrEIQql3qQ== 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 Received: from AM5PR0701CA0006.eurprd07.prod.outlook.com (2603:10a6:203:51::16) by PAVPR08MB9233.eurprd08.prod.outlook.com (2603:10a6:102:30a::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6277.38; Tue, 11 Apr 2023 22:43:42 +0000 Received: from AM7EUR03FT057.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:51:cafe::36) by AM5PR0701CA0006.outlook.office365.com (2603:10a6:203:51::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.21 via Frontend Transport; Tue, 11 Apr 2023 22:43:42 +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 AM7EUR03FT057.mail.protection.outlook.com (100.127.140.117) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.29 via Frontend Transport; Tue, 11 Apr 2023 22:43:41 +0000 Received: from AZ-NEU-EX03.Arm.com (10.251.24.31) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.17; Tue, 11 Apr 2023 22:43:41 +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; Tue, 11 Apr 2023 22:43:41 +0000 To: CC: , , Subject: [PATCH] [gdb/aarch64] pauth: Create new feature string for pauth to prevent crashing older gdb's Date: Tue, 11 Apr 2023 23:43:27 +0100 Message-ID: <20230411224327.2142994-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT057:EE_|PAVPR08MB9233:EE_|DBAEUR03FT061:EE_|DB4PR08MB9310:EE_ X-MS-Office365-Filtering-Correlation-Id: b15a871e-4750-4740-6559-08db3ade37eb 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: K1rkL/YVZo5Fy9ggu34bRrwOZkPVVo+A8zXnk5X29zsCbo/amkTZzk9RaVCOZ6I7LXP4di5Sz/zzux4/l89ZK/wgXyGRWCdvDotcQCe0TYjBLcwFeotbuQPZcdLNLoXeROz9hcEvKmMVw0DONGlKHrA3NLQmgee3EG6fdh3xnHBFhhHuEX+Q6OIClnKLPxC4QNKLRhZwndUyG3Md9ssb84/a0C+3PeKXU9A6d+CgmF1wRRDoKb9OA2znccN3bFjJYOXEtz0wmEtqJrshmIgFRdxS3hofLY6V4YmA86ccfsHTsDwaoiy1C0JaSJtKDla71oeeoDfllynRJNfpzvhdeJcG063v30TEjP5cHF4DCwW3L7i44gMiUaUB2ZFxx4z4n+hdnBJTslbxduZxlulf4FfLL0nS/XrcdnQTGcJU+GjXj0uoDqGDL7bhuzjOzITrqlCjpWhH0Do1/VD8EwDThRy63qSm+GVLYu6m0tqvtBRKOMUciCwCXl8PL2IkVmd1lllvfnxJjGymeQdCOZf7bdPBNmdMmXGr9ycC5wcuA481nXP4Fr1DONbk6mIiDw+KaglqLU8V9F0ftdkzfkhf2qPklnXXoRx82n8Taf4PQ2GduystJuHdZWinBtqByq73ADgVpfGDTXCZzS+4h/3m/oBdCAeVmnsbDd2fxgoc0D/sv6vzm1qg773inu9zcGSxJWNX1dSyJuTlGc7x/z82N61z+3Nhwt3VqKPL0NvC1F4= 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)(376002)(396003)(136003)(346002)(39860400002)(451199021)(46966006)(40470700004)(36840700001)(44832011)(5660300002)(41300700001)(36860700001)(8936002)(8676002)(40480700001)(2906002)(82740400003)(81166007)(356005)(40460700003)(47076005)(7696005)(83380400001)(6666004)(478600001)(2616005)(186003)(36756003)(336012)(426003)(26005)(1076003)(82310400005)(86362001)(6916009)(4326008)(70586007)(70206006)(54906003)(316002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAVPR08MB9233 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: fa2ef93b-0f21-42cf-b5c0-08db3ade3345 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: icgWKSISVxZxckNkghh3c+8j64Fg1nO/QA2HTJKYMGG2ZOzmB7gQLgCg13m+EMgF1AIYl956xMc7h6ZB+rv4kDaegteJ6B84ZWdeqyvQwXUCMBQEUR7JuyEIvShyu010v1lKzBRBT+NkZItxD9eZDnQ29DS9vUlGVx4LQR0knZhjS3pn29U0zyhzePDCgyc3BZPqJNWxng6k6RGsbTCSjPYBiCnH7qP7V5n8vtkfThbO6uZh9TSLn8symWf/BjhFBcdfLhyMOTGvrNz7xU9shTaW5p1vnEoMpY27kaiv9x8+jyMHGu+ngh42RJ73xyGbTYhlEGFgPmYkBM1810UJvdAJODkIGpqHRqiN+XYVnyIBOzKtbB74EQmfIY6lfDZRJlGYeMrHxjc+W+GwOnnGwrI2XUNbtLWy1MNtYL5HFJbZa3ap75l8IX9Hq1uFV9Qssa2v1cE5dPrt1RLobHgULL8+jpbPzUpM8TexC0mbWyB0Ml/9M6N4zIcs5nHGKd4+DZm9FgIflNEvk1KNTDeV1m9zheQXzg6LlG9MORgtc+PDNCzXb0qt2arXqUI4d/NJHe55T//B2h6bptPrVlLq0YL1mDsgoLB/DDSsJFXmR1CDBA62l3lOqlr5N0bT9zxJX2MYNfFP03TQJtkNjAo+5S1uCALs+VgbdT+nOcoI42D8RAFDxj3Evs8hQ3Ot+ZYjlQmrFvzdzEVCKpwaPY6jPQ== 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)(396003)(376002)(39860400002)(136003)(451199021)(36840700001)(46966006)(40470700004)(478600001)(7696005)(40460700003)(316002)(1076003)(26005)(54906003)(186003)(5660300002)(2906002)(44832011)(70206006)(70586007)(4326008)(41300700001)(107886003)(6666004)(8676002)(8936002)(6916009)(82310400005)(81166007)(82740400003)(40480700001)(47076005)(83380400001)(36756003)(336012)(2616005)(36860700001)(426003)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Apr 2023 22:43:49.8225 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b15a871e-4750-4740-6559-08db3ade37eb 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: DBAEUR03FT061.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB4PR08MB9310 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 X-BeenThere: gdb-patches@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gdb-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Luis Machado via Gdb-patches From: Luis Machado Reply-To: Luis Machado Errors-To: gdb-patches-bounces+patchwork=sourceware.org@sourceware.org Sender: "Gdb-patches" 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. Reviewed-By: Eli Zaretskii --- gdb/aarch64-tdep.c | 15 ++++++++++++++- gdb/doc/gdb.texinfo | 16 ++++++++++++++++ 2 files changed, 30 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..aefeb63f75c 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -47980,6 +47980,22 @@ 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}. +Due to a bug in previous versions of @value{GDBN} (versions 9, 10, 11 and 12), +a new feature string was created to prevent targets causing a @value{GDBN} +crash whenever they reported support for Pointer Authentication and also +reported additional system registers that were not accounted for by +@value{GDBN}. This is common when using emulators and on bare-metal debugging +scenarios. + +The new feature string is @samp{org.gnu.gdb.aarch64.pauth_v2}, and it has +the same contents as feature string @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}. + +In the future the @samp{org.gnu.gdb.aarch64.pauth} feature string might be +deprecated in favor of @samp{org.gnu.gdb.aarch64.pauth_v2}. + @subsubsection AArch64 TLS registers feature The @samp{org.gnu.gdb.aarch64.tls} optional feature was introduced to expose