From patchwork Thu Apr 13 14:37:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Machado X-Patchwork-Id: 67706 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 B44963858C66 for ; Thu, 13 Apr 2023 14:38:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B44963858C66 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1681396703; bh=bgEtHlcXw7SyYjkY6tT7nTQowokIDdz4EA5t0iOrP2o=; h=To:CC:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yLTNVpCT8u7wtc16CILoFbHw1f4AFvG/zUA0j86aCHbBAHAr7cG97iJKLQg70ByVQ fzweNEFOAeCaoEqGhoMKDck5HcE7cH0H54yW9/qXybHU5L6ZtaHwBlIs28CmJlJoyb qLSXC9Jkwu+dGkd2rDhT/9cIuwBOdL/tOBrqfQx8= X-Original-To: gdb-patches@sourceware.org Delivered-To: gdb-patches@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2085.outbound.protection.outlook.com [40.107.6.85]) by sourceware.org (Postfix) with ESMTPS id 8CEAC3858D20 for ; Thu, 13 Apr 2023 14:37:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8CEAC3858D20 Received: from DUZPR01CA0236.eurprd01.prod.exchangelabs.com (2603:10a6:10:4b5::15) by GV2PR08MB8270.eurprd08.prod.outlook.com (2603:10a6:150:c1::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Thu, 13 Apr 2023 14:37:55 +0000 Received: from DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:4b5:cafe::44) by DUZPR01CA0236.outlook.office365.com (2603:10a6:10:4b5::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.32 via Frontend Transport; Thu, 13 Apr 2023 14:37:54 +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 DBAEUR03FT018.mail.protection.outlook.com (100.127.142.74) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.29 via Frontend Transport; Thu, 13 Apr 2023 14:37:54 +0000 Received: ("Tessian outbound 945aec65ec65:v136"); Thu, 13 Apr 2023 14:37:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: b60e39bd78268348 X-CR-MTA-TID: 64aa7808 Received: from b44663577202.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 60A817B1-AD0D-4BE3-BA04-9D84AA173CC7.1; Thu, 13 Apr 2023 14:37:48 +0000 Received: from EUR04-DB3-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b44663577202.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 13 Apr 2023 14:37:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=M0GTu2L6X53axoyvjT25ePCrJAFLgT1bDebBZTrd7XpZde403yG2nBgNelkvEvTCHsN4gOTH8ZK+WGQ9yC0943Eo4k/A4Y2FLMr1v7LqufiW/l9HOxd+Dnxsy0u3vGdkBWrp366PsH4j8H2HEq8RnTdqSarsn9FWTZ37/UioR6c+FnEe7kUc6kM4uaTtgM/rwN/QaVnndVjyj4FAhgrkq5C1wy7DxlJSamg8so2EYdVTShJrBgN8jptXBMF/TOI9V0nn7qGRBiuL5OLxzqJzOL4N1BbdtYt+iOMDiDMUkRumMlozfua9CLP2bFL/D0VN5Yik1xX8JGRuco9fnjCt3w== 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=bgEtHlcXw7SyYjkY6tT7nTQowokIDdz4EA5t0iOrP2o=; b=nqWj4ejD6qH7YYVeGk2AJ49rRLleSA+RNCsKXOdfzMmwUmcY0DvzAJAXTa0rTsfPLYWmwiiP+MF7blyC+qzTuf9/eEtVSZm8xaavfGljnRhR/GyGbU4VqxeLTyhmXimmOqnGMusUI+KD33LFlvquoq3xrrWoKm6fY9Zu/hSjSifcJlRurbh02BF3AmDP00VWFkBL0zmKApxHYleAkbbkEibQaE3jYxH+jMFETrPcuUZGbslHhgEqIYnQmg2SqSFcSxzyVgFQy3aMh1ginJdySZIZxPuoj8aXO6/5byXwVA6nfPESzkdSnECs7N7HZkEy+NGiQmp7JZ7Wjru7gOLdcw== 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 DUZPR01CA0067.eurprd01.prod.exchangelabs.com (2603:10a6:10:3c2::6) by DBAPR08MB5621.eurprd08.prod.outlook.com (2603:10a6:10:1a3::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30; Thu, 13 Apr 2023 14:37:46 +0000 Received: from DBAEUR03FT034.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3c2:cafe::df) by DUZPR01CA0067.outlook.office365.com (2603:10a6:10:3c2::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6298.30 via Frontend Transport; Thu, 13 Apr 2023 14:37:46 +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 DBAEUR03FT034.mail.protection.outlook.com (100.127.142.97) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6298.31 via Frontend Transport; Thu, 13 Apr 2023 14:37:46 +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; Thu, 13 Apr 2023 14:37:45 +0000 Received: from e129171.cambridge.arm.com (10.1.36.15) by mail.arm.com (10.251.24.31) with Microsoft SMTP Server id 15.1.2507.17 via Frontend Transport; Thu, 13 Apr 2023 14:37:45 +0000 To: CC: , , , , Subject: [PATCH, v3] [gdb/aarch64] pauth: Create new feature string for pauth to prevent crashing older gdb's Date: Thu, 13 Apr 2023 15:37:43 +0100 Message-ID: <20230413143743.37947-1-luis.machado@arm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230412122722.2606425-1-luis.machado@arm.com> References: <20230412122722.2606425-1-luis.machado@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: DBAEUR03FT034:EE_|DBAPR08MB5621:EE_|DBAEUR03FT018:EE_|GV2PR08MB8270:EE_ X-MS-Office365-Filtering-Correlation-Id: 1db0e936-89a6-4781-28c0-08db3c2cab03 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: TTDKnE+8VsGB52PDUiboEbxsHa/omOJP2kupHV/UwGTuOahHvkMonmjTaCLpRDckpu5mGC2OOZtYoPqSPeIfFVNhNpsbQQRkQTVaYWbcnu6m2MoUvGJbO/lg5kH0iM4QnU5ATRzn7eWVvefqGqG6u342bMJT1bhH42nXth/zveeiruA/h/xVdbJiwhWO3UMlkw5mvxRY2VouptetU3RUVNuASAPOHKBtc1LQd9sqZzTbGqLSTaCKmpZqVCNadXzMNjUFE0iXH8RBLBA9xSdPy85HgN6/AHva76oBHjVw6x1R0y5UyyyK99OtNYlw2IB2gpjTkoHvnIWGUKWm8zXf/AjxbPLeTxZNAxwAsjRndh3/OYTgwLBq3ZdFjLBOsKKdpdtNlJcpntQVZi1FpEG68pi0SgD2WVNuPSidTcEbTrokNUYvrZROy+uMxkM+Tqc0PtDTI3QabVxv1k/HZiJoLG5Y8Ns57H57Ks/KAM+acWCY7f9Ukmyq3/kKyJ9E9Qf0EUWyXuQbVoiyyEglZvQmjeYqS8XJ2098ZdKrcUBXrmPz03Gp347MHYf1jQa+OLeb9NhSI4OGWgNkSHfcAn+ZNHkobwocM7Fjzuine3jVLzTntd69GnwaagQ14V2dGeyON4zBbiwxgQtmqZeNYWlpKB5c1yqkt0WHb+E4f5cGy2K5t+nvegazEqAz92tXiwj+C4gqWXx2YrNdT4vZT8zOdA== 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)(39850400004)(346002)(136003)(396003)(451199021)(36840700001)(46966006)(4326008)(70206006)(70586007)(54906003)(316002)(6916009)(2616005)(1076003)(26005)(186003)(336012)(426003)(40480700001)(47076005)(5660300002)(82310400005)(41300700001)(478600001)(7696005)(8936002)(8676002)(36756003)(36860700001)(86362001)(83380400001)(82740400003)(44832011)(2906002)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBAPR08MB5621 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 3a4fbc5f-4b76-4395-6c94-08db3c2ca5e4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OOo2mqr5zHFmSXP1+82LcKI+4BLAHX2YIhiNPmOBd7CsjaUvPgsbZnxq7zhNur373Is6kAjNjPfjq7fu4cb3ggUyLyEJ31nRqR1+eq5CkDOAhrBVsG9BqpnvrGJL8L8/iNdvWkxNdX0G48n3UaibyJae5b5GcRcunK+pK72WGqdiScii0WxYxHY3TrE57JyTX/LtJGywGQqIKNQqRJJXG4bi794v6Ob4lMdVV3lGYn/5bW9xVNeJuXJLF0DLEtT0Cw4eTMJv5jAx2yPYPwEcKhmTJcb5eZ7l4cXdT8hNfU+JIW17e85JJPkqzafzifpJXD7XxXGxS4XNQOyvRl7kNMN5qd+JQKNxlnizL3l76JoBr2xgxUYurBLOUS6FaPgRBTTokowtoJOMyHp0u5xWEhczS4qH7wipElckTQVMAng6d/pzhVRApCB8B7FHyI5AOsBt9JEB6Ks/Fjx2zN2No9ZKC5CRKy81PFKUtQPogwPxkbyD48gVOAp6yf/qpLlqxEEPzwCvahMJJd4pRnZ2hxobWqYb4RNJ0blYgU94JguuqN4nb9TLExrqgtjHHPLsiRoFXAnWcW5IMlYWVh/R42eKL5A6Wujhgcy+3yAzhDFoYE03Q3Qsj0P3vUjP5S7bIiqXOBTuks3XXQEsJ4MlKn4ADMPkWgEteGTA6s9bRBfPOjZgEzZ4WNyh2mJoaWdv6n7bnwDOjdopUPjZK3H05w== 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)(376002)(39860400002)(136003)(396003)(451199021)(36840700001)(40470700004)(46966006)(40460700003)(426003)(336012)(107886003)(2616005)(186003)(26005)(40480700001)(1076003)(47076005)(82310400005)(81166007)(70586007)(70206006)(2906002)(4326008)(6916009)(7696005)(41300700001)(8936002)(8676002)(44832011)(5660300002)(478600001)(36860700001)(54906003)(36756003)(82740400003)(83380400001)(316002)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Apr 2023 14:37:54.7926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1db0e936-89a6-4781-28c0-08db3c2cab03 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: DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8270 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" Updates since v2: - Added NEWS entry. - Rewrote deprecation paragraph. 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/NEWS | 4 ++++ gdb/aarch64-tdep.c | 15 ++++++++++++++- gdb/doc/gdb.texinfo | 23 +++++++++++++++++++++++ 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/gdb/NEWS b/gdb/NEWS index 10a1a70fa52..54b5da21245 100644 --- a/gdb/NEWS +++ b/gdb/NEWS @@ -3,6 +3,10 @@ *** Changes since GDB 13 +* The AArch64 'org.gnu.gdb.aarch64.pauth' Pointer Authentication feature string + has been deprecated in favor of the 'org.gnu.gdb.aarch64.pauth_v2' feature + string. + * GDB now has some support for integer types larger than 64 bits. * Removed targets and native configurations 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 c11457952d2..940315b2713 100644 --- a/gdb/doc/gdb.texinfo +++ b/gdb/doc/gdb.texinfo @@ -47991,6 +47991,29 @@ 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}. +Please note the @samp{org.gnu.gdb.aarch64.pauth} feature string is deprecated +and must only be used for backwards compatibility with older releases of +@value{GDBN} and @command{gdbserver}. Targets that support Pointer +Authentication must advertise such capability by using the +@samp{org.gnu.gdb.aarch64.pauth_v2} feature string instead. + +The @samp{org.gnu.gdb.aarch64.pauth_v2} feature has the exact same contents +as feature @samp{org.gnu.gdb.aarch64.pauth}. + +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