From patchwork Mon Jan 13 11:22:03 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 104682 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 04C6B3858432 for ; Mon, 13 Jan 2025 11:23:52 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on20627.outbound.protection.outlook.com [IPv6:2a01:111:f403:260e::627]) by sourceware.org (Postfix) with ESMTPS id 52A763858C98 for ; Mon, 13 Jan 2025 11:22:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 52A763858C98 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 52A763858C98 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:260e::627 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767355; cv=pass; b=D2koTrtAw7x896ogJbkRcLZGjwLwigeRrDBwC45gkJSoHu3b3mKBckWJGrPRzyD6T6l+V5Fe29YHsZIwRCM3q0xuMCYgc86zpao2rafPwJ+E/fb5qX20LGGnupqUpn3NddsAdGwemdq2nhMJvn4ziYBcNR1b+My3bNEieJg+LjM= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767355; c=relaxed/simple; bh=Df0mRcnTik7Xzc3ulRS2cXv0/Eq6XhLFkFfLfbAvous=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=hXk+lK9bLti4InKWSdmH4vrvCVI6BBMDs2dTyShwr5BKyUbgtfdJWvLbkJxWYCLWvQFbS0dxGuXX5V5QkXiJzMmMoNgeVFlY8YBL5Y/lhnV3CPYzHil/yLfQsybqcqbO1rEd1s5z4q720xhoJQt/SKxzoqXFCbogOFXIzX0/h60= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 52A763858C98 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=acCNT/VM ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=kqj6v4lKT+366KgmJ4oHW08YvidMSuu9r5EpQzw/h2Ac1V+MvRLjBv2yrVxX0BbHbhGkWkptuAJlCIqOtQX5LtgCvG6PRaJlumk3+qzuNVu/iapCL1bJxYmMvlCYDi3BJY/yjnihDS+tuwg+r3k9/abDbyEYXuaDUYKNbdtTiKQMW86/bl9F5AFIfoKGAlrUs9tmz6j+LkqMf562Xp7nIh7+5vPdDMCnJGLMKpi6wp5juW6K5bdM8MLkAgtgOTEacAE6KyYaD/HG/u4UuWrogR0SIxY6QqYvFBE12LAGIQHSJcOY7Dpe0K7Bz/0ErQ24F1AU31xSu9P5wXFdq7dpqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=a2ubUibZDWLFf3893VsDg739a3Nv63cHjBwYxz/AXW8=; b=SfpJk5QXL4gMnBR3yeFeM7lyqStPiMYxKWkIBSS0WFeYjzYZu+CLqStepWmd+6IYknaEfy2+ViMvbko3wHe7d2Gog/htqhJHvIj84rM7QWta+dG5uhZ75m079KJ82VJzTFjlw8Jo9Mep/6549rFq0MHj3Z11X6kX3h3wmCgZuM5Ycv8H1Ycwq0DC7Fq8LF0v8rzPYiL2uzbNiSRxOdSLw85yFPz6HflzkAF12PRd1puz10UrrccIBkDHAn+kGsXF4Qr2jWgtVnSuG3NfB8cwu26rRm2zrrTWMOHBCgRzHyVDYMHQz7zerVmTkXqOdaAL7WxqXjZqvw9UGGTX82lZRQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=a2ubUibZDWLFf3893VsDg739a3Nv63cHjBwYxz/AXW8=; b=acCNT/VMiK3YjRpbWAnWpBUtpY59n4O582pnuavH7QkwtsELBPEzwUYOdWY4WAjlv4ZiV0onc3encYkDs8Hi0+Huysa4mLmWaH8Mab3lc/Oo0LFtbi1B422GWvmPbiG4Tn7wSrO/7cILzJwYUyufs3Pyq2e5SI6WsmPcRfIyDNg= Received: from AS4P191CA0023.EURP191.PROD.OUTLOOK.COM (2603:10a6:20b:5d9::19) by AM8PR08MB6626.eurprd08.prod.outlook.com (2603:10a6:20b:367::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Mon, 13 Jan 2025 11:22:31 +0000 Received: from AM4PEPF00027A69.eurprd04.prod.outlook.com (2603:10a6:20b:5d9:cafe::49) by AS4P191CA0023.outlook.office365.com (2603:10a6:20b:5d9::19) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.18 via Frontend Transport; Mon, 13 Jan 2025 11:22:30 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; Received: from nebula.arm.com (172.205.89.229) by AM4PEPF00027A69.mail.protection.outlook.com (10.167.16.87) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8356.11 via Frontend Transport; Mon, 13 Jan 2025 11:22:30 +0000 Received: from AZ-NEU-EXJ01.Arm.com (10.240.25.132) by AZ-NEU-EX06.Arm.com (10.240.25.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 13 Jan 2025 11:22:30 +0000 Received: from AZ-NEU-EX05.Arm.com (10.240.25.133) by AZ-NEU-EXJ01.Arm.com (10.240.25.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 13 Jan 2025 11:22:29 +0000 Received: from PW070M4K.arm.com (10.1.32.155) by mail.arm.com (10.240.25.133) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 13 Jan 2025 11:22:29 +0000 From: Matthieu Longo To: , Indu Bhagat CC: Richard Earnshaw , Nick Clifton , Jan Beulich , Matthieu Longo Subject: [PATCH v3 1/4] aarch64: make explicit that CFI gnu_window_save is for Sparc, not AArch64 Date: Mon, 13 Jan 2025 11:22:03 +0000 Message-ID: <20250113112206.1071596-2-matthieu.longo@arm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113112206.1071596-1-matthieu.longo@arm.com> References: <20250113112206.1071596-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM4PEPF00027A69:EE_|AM8PR08MB6626:EE_ X-MS-Office365-Filtering-Correlation-Id: 0dd2938b-c5a2-48c9-7ae2-08dd33c491ca X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|376014|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: U4dILK8SJY0puRBVsh2GWsD24tI6wabhI2Kbf3rHDpUHkrjhuiJHm9qOsS2wPwpW5dNqPxciZ7aAneST5iYjBDbOHN7DB1Hp7xgcsM9hy3gcQ3i48Bd8c8UtBNZljNbWqePuPSBPacgN2czAncxv2k4kGppJmpSQKG6yfKnRvGv7iK+oMN2eokiOqzwiIdjqSMfpbH9fA/vZoqSIXxnW3DrxuQoCcvK7Ik1wd6dlIE9iIYIAsL0IlHmG+mmZS8oZRjesG1UZvnFERX3sfNJeBNWJvhcqpJz1dC8GGO68LIUTCJqQGk9Ka4IGeHWv01oQnRfR8c1Ie1yV6UnS71+S40GOyouOD5v1E1DQ8hhWWEi2NwFCfq5Kmfink5s+e8Gld5q4SdCXh7Z4swgtWP+y8BqhcA0X81JLx5HOD9Q8pW76u8qjqVAsahXkjAjc/96c/03C9orBPOOpGn5Ao9Jc101dF65bTk965cROsN00rT7A4ZQAAVc16ReULJXIsffrX4GAsQLTcRFIsuKkLIDJcXo/F0LZ2GlKxuz5APqovOQuSdInlJA/ueq5TkEa7JxPu1eyAf2y/7lHVTKyHP74raxIB5/kgQbcAY1abv7zwZOiN7bO0JPS0HaqebWWNkEeO+iX9QuC3T9DgyLmWmvX7ATo531xv6wvTMRz/PsNkk9ZWb3U4K6BSkQDB4m5+4q4meh4U4qoEMicgm4q8wGs1oyXtSy7PWWn5pEKepBJ/eIy7ZUcC9qC1jKFBnzgOtjC77Iz7YjTfDGa4k+6XsG5AJRmJPrwRcNYEKVUMErt1l7y9JU7GM/GosBOTaRG//I0NnDm4tDs6/38AKb4OOxmsib22SN8EwMgG2ZaEnC/qXejwNDVm49ZYFl8eU0CuyOmu+W5fL5JeAoru9ZalQVNyDGqyg79kH7bncSbLf5MXfRd82ac9vRtFVIB1fOoJTZkO+p+YXXpa/eIxCakd8ryjWjiwsstamY9ADgzXQpf3419QHYamJqQ7ypD2yRgd/BrPcdfoMLbEErSUs3wHdBHpHlhxUhRsbAd+e7OYMWuBFQ/JbMswhYl2ZPeGdioFKMJBE2oEEixCysJccK0adl6psnI/2yhSCl9f1ntAy74fIwCzHzL6Z+lv9aTHB+TwEP01GmrEjPXco21J6c/6UoMZDGuFo1Syt37iyq9NWEdvTl/d5hPHHsCoMc2NVvG6nhMzUHxrt3Z5hjitYPCqaMysWASrZiCJTv+4CvfQeHDSL2wfLLy9DslV7K4pC2zgZu7PVrOh+Jt5KnSRRW4ua+55JsQqijxFPPzKCI2maRdy+NIU7VoOXuGHgg0KZjvANoKcgnd2vfv3tfUXtDppQGe2zTSxfGJntqTjFu6s5ItIE6PxlK41HUgCJSuUhQGN+WihGf3m6NGOlM27H5XRKRbTSv/E+4TxzbH7FmCdn7N5W0SQSzwOKumOsfZyD/VWGxIycJD0UouiYpP0gWL/Da/QvQCOKmePse1IbJo3gxwKIE= X-Forefront-Antispam-Report: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(376014)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 11:22:30.8738 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0dd2938b-c5a2-48c9-7ae2-08dd33c491ca X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[172.205.89.229]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-AuthSource: AM4PEPF00027A69.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB6626 X-Spam-Status: No, score=-10.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, KAM_NUMSUBJECT, SPF_HELO_PASS, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org - add a detailed comment when parsing DW_CFA_GNU_window_save in SFrame to explain why we are checking whether the targeted architecture is AArch64, whereas this CFI is a Sparc extension. - replace .cfi_gnu_window_save by .cfi_negate_ra_state in existing AArch64 DWARF tests as this is the preferred directive since GCC 15. - add a new AARch64 test to check backward compatibility with old GCC versions that emits .cfi_gnu_window_save. --- gas/gen-sframe.c | 8 +++- gas/testsuite/gas/aarch64/pac_ab_key.s | 4 +- .../gas/aarch64/pac_compat_cfi_window_save.d | 44 +++++++++++++++++++ .../gas/aarch64/pac_compat_cfi_window_save.s | 20 +++++++++ 4 files changed, 73 insertions(+), 3 deletions(-) create mode 100644 gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.d create mode 100644 gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.s diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index 71296f2f4fb..a3c40bdd735 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1273,7 +1273,13 @@ sframe_xlate_do_aarch64_negate_ra_state (struct sframe_xlate_ctx *xlate_ctx, } /* Translate DW_CFA_GNU_window_save into SFrame context. - DW_CFA_AARCH64_negate_ra_state is multiplexed with DW_CFA_GNU_window_save. + DW_CFA_GNU_window_save is a DWARF Sparc extension, but is multiplexed with a + directive of DWARF AArch64 extension: DW_CFA_AARCH64_negate_ra_state. + The AArch64 backend of GCC 14 and older versions was emitting mistakenly the + Sparc CFI directive (.cfi_window_save). From GCC 15, the AArch64 backend + only emits .cfi_negate_ra_state. For backward compatibility, the handler for + .cfi_window_save needs to check whether the directive was used in a AArch ABI + context or not. Return SFRAME_XLATE_OK if success. */ static int diff --git a/gas/testsuite/gas/aarch64/pac_ab_key.s b/gas/testsuite/gas/aarch64/pac_ab_key.s index 4b328e72ae4..3b81919409d 100644 --- a/gas/testsuite/gas/aarch64/pac_ab_key.s +++ b/gas/testsuite/gas/aarch64/pac_ab_key.s @@ -7,7 +7,7 @@ _Z5foo_av: .LFB0: .cfi_startproc hint 25 // paciasp - .cfi_window_save + .cfi_negate_ra_state stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16 .cfi_offset 29, -16 @@ -23,7 +23,7 @@ _Z5foo_bv: .cfi_startproc .cfi_b_key_frame hint 27 // pacibsp - .cfi_window_save + .cfi_negate_ra_state stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16 .cfi_offset 29, -16 diff --git a/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.d b/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.d new file mode 100644 index 00000000000..8e59086c1b4 --- /dev/null +++ b/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.d @@ -0,0 +1,44 @@ +#objdump: --dwarf=frames +# This test is only valid on ELF based ports. +#notarget: *-*-*coff *-*-pe *-*-wince *-*-*aout* *-*-netbsd + +## ARMv8.3 adds support for a new security feature named Pointer Authentication. +## The main idea behind this is to use the unused bits in the pointer values. +## Each pointer is patched with a PAC before writing to memory, and is verified +## before using it. +## When the pointers are mangled, the stack trace generator needs to know so it +## can mask off the PAC from the pointer value to recover the return address, +## and conversely, skip doing so if the pointers are not mangled. +## +## .cfi_negate_ra_state CFI directive is usually used to convey this information. +## .cfi_negate_ra_state and .cfi_window_save are both in the processor-specific +## numbering space, but use the same code value in the dwarf tables. +## In GCC 14 and older, the Sparc DWARF extension .cfi_window_save is emitted +## instead of .cfi_negate_ra_state, but it mapped to the same value. GCC 15 fixed +## this naming issue and there is no change to the object file created when the +## source is assembled. Nevertheless the support for the SPARC directive is +## preserved in binutils for backward compatibility with existing GCC releases, +## hence this test. + +.+: file .+ + +Contents of the .eh_frame section: + +0+ 0+10 0+ CIE + Version: 1 + Augmentation: "zR" + Code alignment factor: 4 + Data alignment factor: -8 + Return address column: 30 + Augmentation data: 1b + DW_CFA_def_cfa: r31 \(sp\) ofs 0 + +0+14 0+18 0+18 FDE cie=0+ pc=0+\.\.0+8 + DW_CFA_advance_loc: 4 to 0+4 + DW_CFA_AARCH64_negate_ra_state + DW_CFA_advance_loc: 4 to 0+8 + DW_CFA_def_cfa_offset: 16 + DW_CFA_offset: r29 \(x29\) at cfa-16 + DW_CFA_offset: r30 \(x30\) at cfa-8 + DW_CFA_nop + DW_CFA_nop diff --git a/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.s b/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.s new file mode 100644 index 00000000000..92a54f3a344 --- /dev/null +++ b/gas/testsuite/gas/aarch64/pac_compat_cfi_window_save.s @@ -0,0 +1,20 @@ + .arch armv8-a + .text + .align 2 + .global _Z5foo_av + .type _Z5foo_av, %function +_Z5foo_av: +.LFB0: + .cfi_startproc + hint 25 // paciasp + .cfi_window_save // really .cfi_negate_ra_state + stp x29, x30, [sp, -16]! + .cfi_def_cfa_offset 16 + .cfi_offset 29, -16 + .cfi_offset 30, -8 + .cfi_endproc +.LFE0: + .size _Z5foo_av, .-_Z5foo_av + .align 2 + .global _Z5foo_bv + .type _Z5foo_bv, %function From patchwork Mon Jan 13 11:22:04 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 104683 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 82E5E385841F for ; Mon, 13 Jan 2025 11:24:43 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 82E5E385841F Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=QAWk0FTu X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on20622.outbound.protection.outlook.com [IPv6:2a01:111:f403:2614::622]) by sourceware.org (Postfix) with ESMTPS id 196773857B8C for ; Mon, 13 Jan 2025 11:22:46 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 196773857B8C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 196773857B8C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2614::622 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767366; cv=pass; b=clbWvgKfSaQERc1A2d1vXfSPQLhhdOLD7Nou5QgcRAKVaYLIAG77an0Vb5eUXT7ROZxjLGCYcv93jf0BqMUQiHrEUaX3FvHVpqyURMFm50vW01LSBc1FPaLueTUikGSy6S0zqCE0MRyuuR29IMUC4agfaus2YrG6/32H9kRB8U0= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767366; c=relaxed/simple; bh=9HWtOABHoxI4IH0TAbaCiWtG3UN8IK/KrVtaGG4490E=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=f2NL9wMcghPaXZokTDQ98qlazM1avhFqOPzAivhR5EQgle7MXPvjZvlkW80ci6HJCHqryJZz9+3r+/bramki8BEs1I6gYr7bGmyeDiIhocbUuUTSRTjuqy9sHzvYiRwR2wGRaqxH2C5vv3Rhot/KwyF+IQg7qFnLUkTQRW3+TKY= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 196773857B8C ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=iC2o3n8fsITwahW8iys8+1aC5RqCLG0wpEkHAD8tUhVHN3exXY5Wd/BGANzYkFVmvFCh8Q9ZAG0wQdd+Eja+5mo+bOJfxekq1YkCdSmXsMD53CtXwHj5/MM+jjtD6Mkl0x9rsZR9kU0HsO+YnpeBFg5WBDcQw6ZkzlRzBls7bqYKNOxGUyMRhhckzwm5NPl366YjHq7L8YGDuKltJ0FFIIIN47hiCy7RZcKe82cb+bYjQ/8/uW2aabgsXxHm4WAQzGnMzZU0KB9TBOZ975QwvPuuC2KdyADNK5JG5X+0tVSjZiRfABzwB+nIKkYbsOf9YUG9NyC5xgZ6jHB6aiavCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=KVOLZW0p+QFFFT/kAoQCx8i+u66w6e3rPGIaAlElr9Y=; b=q6eEFArWnPkup57c/kTVEMPIAlSyfDTRxSUDsWpeO4qO1qkZpaP/bUmMSut1r9MpsCCuCNdbmgkaGSxxy4m7PtzuluAH8decvAu8QtXtJU9MkueTMlJkjHj2g95i6PSSaB64wP0xOv9MQx8flXfwl8Jc/NtFMCSnFsQ5vBeMLKZACvyVYKYJTfnVutELshIR1m0zvUPgxM97LOEymmmi76JVOanuSJE2BPsR3I/4i8lAjPX8pQOj14Ow1CCychyhaYAVWZvZck6/1qYbI3dHo4MYKoIwjZUKO7aDtG68D6uKfHuhi0hUoRe9+H6gM9RE5LJr1D5g6KXC03gk7EdYug== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=KVOLZW0p+QFFFT/kAoQCx8i+u66w6e3rPGIaAlElr9Y=; b=QAWk0FTuClqKDZbaeguJbZ6YDNfbq04QwXfppXBWzOTqAoKSE25XRk7Zp6UTHQgXaKyN2RWXPy8vHFxVZa2C2+pLvQSam3yZmZLjz653vZhgxjq4w56HOheI8iWPKybVAnm5wC5dD1V1a47o/W/+6it+DzQ8cNwDBE+XbcWBEY8= Received: from AM5PR1001CA0012.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::25) by DU0PR08MB9629.eurprd08.prod.outlook.com (2603:10a6:10:44a::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.17; Mon, 13 Jan 2025 11:22:41 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:206:2:cafe::16) by AM5PR1001CA0012.outlook.office365.com (2603:10a6:206:2::25) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.17 via Frontend Transport; Mon, 13 Jan 2025 11:22:40 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; Received: from nebula.arm.com (172.205.89.229) by AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8356.11 via Frontend Transport; Mon, 13 Jan 2025 11:22:40 +0000 Received: from AZ-NEU-EX05.Arm.com (10.240.25.133) by AZ-NEU-EX05.Arm.com (10.240.25.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 13 Jan 2025 11:22:39 +0000 Received: from PW070M4K.arm.com (10.1.32.155) by mail.arm.com (10.240.25.133) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 13 Jan 2025 11:22:39 +0000 From: Matthieu Longo To: , Indu Bhagat CC: Richard Earnshaw , Nick Clifton , Jan Beulich , Matthieu Longo Subject: [PATCH v3 2/4] aarch64 SFrame: use preferred CFI directive for AArch64 PAC Date: Mon, 13 Jan 2025 11:22:04 +0000 Message-ID: <20250113112206.1071596-3-matthieu.longo@arm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113112206.1071596-1-matthieu.longo@arm.com> References: <20250113112206.1071596-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF0000004A:EE_|DU0PR08MB9629:EE_ X-MS-Office365-Filtering-Correlation-Id: 5bab049d-f714-4304-897e-08dd33c497c2 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: y8oW13PxkqK1Ko6oShJJBtrrdVHmLJd0vZ9sDeL6aJjJXy5wk1dc7eTu5I7MjbwZ7FWHMtP7MColAMcvzw/iXEnrZtukTw+/d5FEEjdImaZ2NC6diuCkeXA9DzoN7h+Ehl4TEf38rCUgSEBc3KcCXEpudDNiVjuELIWi9FxuNc2L9qlpvzWokkR5ouqcBiwRbRPGZeIz4JIEC4L11BzHs25mYiYKCH3DJGyem/wMcgRcQoWSD3SGl/mipoIt2qlZuCILuAB60TQpteDZH5aa1nA9oGaI/iS/SC9FUJWxsF3/8GtRS62JI4Umd1lJ/o5yKSTFf6JFRd4NC7e48w0XHWTRNn2ZdRMzjh/zOPtvInIvU8qFOk4lN1RkaG7RRGSS8Sh2VfMkJ+1Wmgn1qaiBRRyZd4gh/2741HA8TQBmur6tocyE4F3wah2o9Cw/lb+UDmwN8xjjhFQlljHWECMJCT0rAN9SHpj9+9y3Xc1epYuIXWnhkjcpMD6E0ueFDNQYiEpzpvg/01wXBkYpnN/VJU2jmJMNz312TRfZteh0VWIZyjTmZvsKSq9tmbinvp7QmOJiP0qMRUKsKRivDinrbby0vNMDqQSjJA+C4K47gKIpS2I69c5SFSAwWQyDPCQ4v4UeXPK99RrZzIMIo/vgsgBwURNmSo7B8v/L1EM6+osRiTQg3FFb8MULja3QMsq77nn+OzETN4JTD87gLobffx4zv/VpKFYOy1PGxDEsYNsQUDBFFxybrSrH1BU6ZMH5mkupf2ZbnuIb2m2ymTbL3eoa3ZDP2KsGMZBuNC+aels9RJER6lw3are6nsPLnOpnOYTKNKTCbnoDuK4KTh997G/MT6YJnkHSGrWYY4aGyyBxKc5afThTgw1FTA++L5C9sQTrY4OPTGBlU7f8+M6LnwCiPM5MpIGZabEFpS2HDF5jv+C8IUtbiBBOrPpZjR+XFYzZ7Pr02oH5v8JTBJpXhmSZgNL7Zg6D0Tpzv/uC0YCZSTKhuiukh8Pb8EQzaTistBff8yDi23sOjLJ/RVDrCwWExtwpGLM7rSV9DuOvSgvazziics4kkU5VgpNG2bk6u48bKwZPxBFukLSNndypJkSNA+4fmn4Xdm51P4BWwLSma9FxVQUOp+PcUC+Tr2NziIKJJSato0vTZ8Fqb19vZ6h9hyKdOZV6zTQ/nUITUhVbzUiJ2yucLbCSqOu7zVfeT4rarIeaghQzDcc1nZyZCX9U6HIWkt4szlA9CWd7OuOh1m8NBEAmNTnF8azY5ZAyEbd+/WMXdLegANJjwucGqGk5Jg1YRoLU/qvYUUz0RVZFdaS3QEuznAsvDdfT3mTHhrfyWJWrM9gWCNftCba9CAXS7m/k/u+Jy/DksYJ4Z5W3Rrtg4fdcsl0L4YKlxtgzux9xoqLbGlyupBvIkVU3m2hWVZuxcuWIyGqobNnZrTEl6KpNMq9qQOf0LN7x1DbDC0X8Q7uqVWDWguCUxutVPpRlf0iELJ+DYgCeTEHgpKg= X-Forefront-Antispam-Report: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(36860700013)(82310400026)(376014)(1800799024); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 11:22:40.8881 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 5bab049d-f714-4304-897e-08dd33c497c2 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[172.205.89.229]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9629 X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org ARMv8.3 addded support for a new security feature named Pointer Authentication. Support for this feature in SFrame already exists, but is relying on the deprecated "AArch64" (actually Sparc) CFI directive .cfi_gnu_window_save. .cfi_negate_ra_state CFI directive should be used instead to convey this information. In GCC 14 and older, the Sparc DWARF extension .cfi_gnu_window_save is emitted instead of .cfi_negate_ra_state. GCC 15 fixed this issue, but this behavior is preserved for backward compatibility. The existing sframe test for AArch64 PAC was using .cfi_gnu_window_save. This patch replaces this CFI in the existing test by the preferred one, and adds a new test to check for backward compatibility when using .cfi_gnu_window_save. --- .../gas/cfi-sframe/cfi-sframe-aarch64-3.d | 20 ++++++++++++++ .../gas/cfi-sframe/cfi-sframe-aarch64-3.s | 26 +++++++++++++++++++ .../cfi-sframe-aarch64-pac-ab-key-1.s | 8 +++--- gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 1 + 4 files changed, 51 insertions(+), 4 deletions(-) create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.s diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.d new file mode 100644 index 00000000000..f72b70a970a --- /dev/null +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.d @@ -0,0 +1,20 @@ +#as: --gsframe +#objdump: --sframe=.sframe +#name: SFrame cfi_negate_ra_state test (using cfi_window_save) +#... +Contents of the SFrame section .sframe: + + Header : + + Version: SFRAME_VERSION_2 + Flags: NONE + Num FDEs: 1 + Num FREs: 2 + + Function Index : + func idx \[0\]: pc = 0x0, size = 8 bytes + STARTPC + CFA + FP + RA + +#... + 0+0004 +sp\+16 +u +u\[s\] + + +#pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.s new file mode 100644 index 00000000000..de96b2071a5 --- /dev/null +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-3.s @@ -0,0 +1,26 @@ +## ARMv8.3 adds support for a new security feature named Pointer Authentication. +## The main idea behind this is to use the unused bits in the pointer values. +## Each pointer is patched with a PAC before writing to memory, and is verified +## before using it. +## When the pointers are mangled, the stack trace generator needs to know so it +## can mask off the PAC from the pointer value to recover the return address, +## and conversely, skip doing so if the pointers are not mangled. +## +## .cfi_negate_ra_state CFI directive is usually used to convey this information. +## .cfi_negate_ra_state and .cfi_window_save are both in the processor-specific +## numbering space, but use the same code value in the dwarf tables. +## In GCC 14 and older, the Sparc DWARF extension .cfi_window_save is emitted +## instead of .cfi_negate_ra_state, but it mapped to the same value. GCC 15 fixed +## this naming issue and there is no change to the object file created when the +## source is assembled. Nevertheless the support for the SPARC directive is +## preserved in binutils for backward compatibility with existing GCC releases, +## hence this test. +## +## SFrame has support for this. This testcase ensures that the directive +## is interpreted successfully. + .cfi_startproc + .long 0 + .cfi_def_cfa_offset 16 + .cfi_window_save // really .cfi_negate_ra_state + .long 0 + .cfi_endproc diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.s index d9a408c668c..84230a99e3c 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.s +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-pac-ab-key-1.s @@ -8,12 +8,12 @@ _Z5foo_av: .LFB0: .cfi_startproc hint 25 // paciasp - .cfi_window_save + .cfi_negate_ra_state stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16 .cfi_offset 29, -16 .cfi_offset 30, -8 - ret + ret .cfi_endproc .LFE0: .size _Z5foo_av, .-_Z5foo_av @@ -25,12 +25,12 @@ _Z5foo_bv: .cfi_startproc .cfi_b_key_frame hint 27 // pacibsp - .cfi_window_save + .cfi_negate_ra_state stp x29, x30, [sp, -16]! .cfi_def_cfa_offset 16 .cfi_offset 29, -16 .cfi_offset 30, -8 nop nop - ret + ret .cfi_endproc diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp index 48eb0ed2182..1de2c9f8037 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp @@ -97,5 +97,6 @@ if { [istarget "x86_64-*-*"] && [gas_sframe_check] } then { if { [istarget "aarch64*-*-*"] && [gas_sframe_check] } then { run_dump_test "cfi-sframe-aarch64-1" run_dump_test "cfi-sframe-aarch64-2" + run_dump_test "cfi-sframe-aarch64-3" run_dump_test "cfi-sframe-aarch64-pac-ab-key-1" } From patchwork Mon Jan 13 11:22:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 104685 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 DFC053857722 for ; Mon, 13 Jan 2025 11:26:55 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on20617.outbound.protection.outlook.com [IPv6:2a01:111:f403:2613::617]) by sourceware.org (Postfix) with ESMTPS id 70EAD385782C for ; Mon, 13 Jan 2025 11:22:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 70EAD385782C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 70EAD385782C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2613::617 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767377; cv=pass; b=vlrFT6lt3iuRSbgClJeoGjdhyQA2xuPq/xXzdfck+tx7bkSGV+BRUXf7PjZK7A1WA3PhsrRurycJ39pTzgv/gr9m4mYB29maTAhj+OQPiN5kPZrwVFixwYHnQX9feqclpuAPe5IgIdOkQxenR/hbY1R4Eev3EgcSpsxzLoAjXBo= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767377; c=relaxed/simple; bh=oT2l2gJDg3Y2E6RczpvtmxHjVWsPvDsBlvLnJSByqnU=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=jsJhRElPWl9WnCJT6ZSgrbMT1eq29ShJQDzJ9Spm+pCW5NMnd61uJxU3Z7mBfmULf9BDjfMreeLbcgHRT0uA6D0C4yNT/AlCjII8hSTEvzA0Bq0Yivw7CukrzU5H97kjHL8zT1LImZA5fi81jtMSShoftVMXfU+wWafOJWpVSQo= ARC-Authentication-Results: i=2; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 70EAD385782C Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=njZWn20J ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ppPutDRi8e/cW72AFMgjYTcDP9S/T3oFvaFOyiQk1B6fj8/BeeY1ZaxK/ww5BZDj7uuOnH3IPk4nuGKWuBrpgI3sli7RqhuU8BdYQE4BFeTGUjATVM3cbv7zEI4/Tv9UOOo5PjHIG67uGLzVaftstCaItk/NVflcEw4JbqVGFFq78KobYPXGXsE+H5oQfX7eUhnCdoolUh7GPadkULTPj1x6PhHKxJ2SFtqrVHvrnKGPK4xKmzhLjDDELVDMD+F0+dO6as1gHWtnHW3oj+ybCZBiA+HEbIc2DAR8B7tBpC32zPg0wj5Y0ReFQLXCZQWvHNr14178lcTeBgDGTZx8vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=TxNt7sHglapKDorcTjNtom9+/eZHpN4CJrOm/EPPG2U=; b=ck+u9TxYwhMkMnuh7w8QoiP6crj10S3bnKl3zAzPn79FG9HpxnRKe5trw6dfvMv/XSwMvaqkmmPjZpVh+tPdHtJ0A6fa9YARxAStEopVrSbqpA2a//FUctyy+0KqEgs2SmMeK+ulUj4YrcoKrBjNytZqFhGDh+uEx9ijYFq4666BhQqQYuRXd4jjXilWgw/wwd4w6lHs3bs0f0hFgSAAJOQM65/9Usvk5ZbrvciCTas3yxE9oXmCo8ejkOTcFVhfBgfXk/rJqoUM16twpNeYNyYkRQR2Pnt0Bbz8yyHq+JpOwV059lJeed6qw4FAI8Y3n+pb2dPulpBiGd/pKzrcRg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=TxNt7sHglapKDorcTjNtom9+/eZHpN4CJrOm/EPPG2U=; b=njZWn20JLdEdl4fR08uA2tZOI9um1Wm4Tk1U/9s+euQjowLuJDOGVlKjuYLqFe+UUF19QoBvxOvJL6gceTd0506i/iIewAXBVT/vMcxevFrJMIw3KW0DK3Kvdqll2CsjEzV+gT2bBuqqr3XqCEK3OcGVqIMbt85US6W1s6TH4sE= Received: from AS9PR05CA0258.eurprd05.prod.outlook.com (2603:10a6:20b:493::29) by DU0PR08MB7809.eurprd08.prod.outlook.com (2603:10a6:10:3b7::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.15; Mon, 13 Jan 2025 11:22:50 +0000 Received: from AMS1EPF00000048.eurprd04.prod.outlook.com (2603:10a6:20b:493:cafe::75) by AS9PR05CA0258.outlook.office365.com (2603:10a6:20b:493::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.18 via Frontend Transport; Mon, 13 Jan 2025 11:22:50 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; Received: from nebula.arm.com (172.205.89.229) by AMS1EPF00000048.mail.protection.outlook.com (10.167.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8356.11 via Frontend Transport; Mon, 13 Jan 2025 11:22:50 +0000 Received: from AZ-NEU-EX05.Arm.com (10.240.25.133) by AZ-NEU-EX05.Arm.com (10.240.25.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 13 Jan 2025 11:22:49 +0000 Received: from PW070M4K.arm.com (10.1.32.155) by mail.arm.com (10.240.25.133) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 13 Jan 2025 11:22:48 +0000 From: Matthieu Longo To: , Indu Bhagat CC: Richard Earnshaw , Nick Clifton , Jan Beulich , Matthieu Longo Subject: [PATCH v3 3/4] aarch64 DWARF: add new CFI directive for PAuth_LR Date: Mon, 13 Jan 2025 11:22:05 +0000 Message-ID: <20250113112206.1071596-4-matthieu.longo@arm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113112206.1071596-1-matthieu.longo@arm.com> References: <20250113112206.1071596-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF00000048:EE_|DU0PR08MB7809:EE_ X-MS-Office365-Filtering-Correlation-Id: e0257ee2-9afb-4bc0-d7fa-08dd33c49d42 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|1800799024|36860700013|82310400026|376014; X-Microsoft-Antispam-Message-Info: M7rsoNLwEWOhzQXCqeQn0HYxg0l0hAosmbTb4c55JiSF6XOJK9NNLYRx1kEsUKXOKxYNhl+T26/xEalIoHV164Giwh+T0M9BMUY3zJyeVV0de0dVDret68zizKPhqrLVC+uIZZ5AgybUdSX1YYofpPKT5XDfgzRu46NpHR7ym5yH/W0Y1d0zZqT3IS+DSeqorlrkFOvJZZ+A7k6okYl83bAMUoueoonbvmp+5F71L/8IjZ9Xu0v4eNSlzqZXQV+CUUTUNoIQkCYddoFKWlphu+tTC1PcqWJutVsOxML81YALP+yvXH9U6veOkkr5EtcuCVRd+Z+FSxB0LX0KVqskjXyVIX4IbCMhrugFknKWJlJTdGqBCUKj4yOIEwwGROlGSWAyRwynW+6wsOAgSK8xSURxZuI8Zl9aYZiMUkSQjX1poce2TVwjJCgHds3CRqAIyonDedvwJVa+JxCN1Qi2EDfw9Dj5xtAAYac/AISOEIuVnJCtMja5R0i4/ZIeJ+ovYzofi/VHymxCyaHskGOLj9dxFBVdY0T0Y/SWmh97OK6NOWDt23BJwhm5uvrKkAEQ6hDjHJRVaPf3us4ZDjXYHKxaA5VZoSn9NuocCjUgqKQ9KTZOpvmn8Ga+f1/Vwwu1uGiGkbSC6OTl6piwA5NSamzbGYje4QX39/1XVYOYfJ35u44Qk2dusvzoe1lE16qX5RbvK6i26+d6Be3F3SVoW+2fNmJNCbwmuWmpWligHsEeIkFwU0x2UabuGCBLWOaFtqG+UPUP4bIL+3FSE47fMfeHzqGeWl3Y2fHhn3MB+oj/MRHTEiR4EXEWbGGpWwiL6F5zpnS7YF/dlNRhnnqdbzNWDXFMkqGbanvgIeDoHHBnkn3LGiCP151ec025WACxpiR0siBS41gn860WxMVJJEMtdsRBwWSYWiHUJKYI39wDSjVf40/TJaoQMVa2pZw6uHu4ka5hfYCbEoT64CMXcoG/VP+c6XYrszCQwSSf2borYyzYxaXOkHGlMR8sYKcpgYUxhwpc4xwPyGyKE6h+l50Fn/HJOwWyWcOx/16nzLvguPtX1FaeNl7w+rtlUhOb2moh6BAu8lM5hw93hzDFig/k5ce+T3gql95uaEnsZnI6je1Hl6KCuO9GfPSMFSahT4vp5ridzaReQ8Z9Dy0Kji/ZfzV6bnkiSek8d8tDYjQ3EXucDP32xLgKRw2hxFZGBISpYL3uVKUBWhnUGD/tvlueJ1yT8ZSM1PEOLpvfPk1MPZmSqIt+enkDz0f2bfSA8gJSMbrrRIsPde2qoR9MnnzuTVFl1ywosTl8wYBjmgIZNzXzGfco+mliN38tQJ+HkJUnMkPnFeQtRewx69DOj2Gkt+PBd5q2x5UdyhXziHV5UAADyhAKcAp9Dk+MMFeX4e0gIFFneKEivcod7U1iLK3JzogcR5JRtkqDfcPfDBmyAMTdGE6Jj+yi8ZBOEaAGgrTCua5t9qDLrAZsictOToSZx/Q2SaKE+kliDJBfsaM= X-Forefront-Antispam-Report: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(1800799024)(36860700013)(82310400026)(376014); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 11:22:50.1177 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e0257ee2-9afb-4bc0-d7fa-08dd33c49d42 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[172.205.89.229]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF00000048.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7809 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org This patch adds a new CFI directive (cfi_negate_ra_state_with_pc) which set an additional bit in the RA state to inform that RA was signed with SP but also PC as an additional diversifier. RA state | Description 0b00 | Return address not signed (default if no cfi_negate_ra_state*) 0b01 | Return address signed with SP (cfi_negate_ra_state) 0b10 | Invalid state 0b11 | Return address signed with SP+PC (cfi_negate_ra_state_with_pc) --- bfd/elf-eh-frame.c | 1 + binutils/dwarf.c | 5 +++++ gas/dw2gencfi.c | 10 ++++++++++ gas/scfidw2gen.c | 1 + include/dwarf2.def | 2 ++ 5 files changed, 19 insertions(+) diff --git a/bfd/elf-eh-frame.c b/bfd/elf-eh-frame.c index d903e27a676..b6f5078bb33 100644 --- a/bfd/elf-eh-frame.c +++ b/bfd/elf-eh-frame.c @@ -359,6 +359,7 @@ skip_cfa_op (bfd_byte **iter, bfd_byte *end, unsigned int encoded_ptr_width) case DW_CFA_remember_state: case DW_CFA_restore_state: case DW_CFA_GNU_window_save: + case DW_CFA_AARCH64_negate_ra_state_with_pc: /* No arguments. */ return true; diff --git a/binutils/dwarf.c b/binutils/dwarf.c index 626efb2eb9a..8e004cea839 100644 --- a/binutils/dwarf.c +++ b/binutils/dwarf.c @@ -10408,6 +10408,11 @@ display_debug_frames (struct dwarf_section *section, fc->pc_begin += ofs; break; + case DW_CFA_AARCH64_negate_ra_state_with_pc: + if (! do_debug_frames_interp) + printf (" DW_CFA_AARCH64_negate_ra_state_with_pc\n"); + break; + case DW_CFA_GNU_window_save: if (! do_debug_frames_interp) printf (" %s\n", DW_CFA_GNU_window_save_name[is_aarch64]); diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c index fbeb697af09..c984d8326d0 100644 --- a/gas/dw2gencfi.c +++ b/gas/dw2gencfi.c @@ -714,6 +714,7 @@ const pseudo_typeS cfi_pseudo_table[] = { "cfi_restore_state", dot_cfi, DW_CFA_restore_state }, { "cfi_window_save", dot_cfi, DW_CFA_GNU_window_save }, { "cfi_negate_ra_state", dot_cfi, DW_CFA_AARCH64_negate_ra_state }, + { "cfi_negate_ra_state_with_pc", dot_cfi, DW_CFA_AARCH64_negate_ra_state_with_pc }, { "cfi_escape", dot_cfi_escape, 0 }, { "cfi_signal_frame", dot_cfi, CFI_signal_frame }, { "cfi_personality", dot_cfi_personality, 0 }, @@ -914,6 +915,10 @@ dot_cfi (int arg) cfi_add_CFA_insn (DW_CFA_GNU_window_save); break; + case DW_CFA_AARCH64_negate_ra_state_with_pc: + cfi_add_CFA_insn (DW_CFA_AARCH64_negate_ra_state_with_pc); + break; + case CFI_signal_frame: frchain_now->frch_cfi_data->cur_fde_data->signal_frame = 1; break; @@ -1754,6 +1759,10 @@ output_cfi_insn (struct cfi_insn_data *insn) out_one (DW_CFA_GNU_window_save); break; + case DW_CFA_AARCH64_negate_ra_state_with_pc: + out_one (DW_CFA_AARCH64_negate_ra_state_with_pc); + break; + case CFI_escape: { struct cfi_escape_data *e; @@ -2212,6 +2221,7 @@ cfi_change_reg_numbers (struct cfi_insn_data *insn, segT ccseg) case DW_CFA_remember_state: case DW_CFA_restore_state: case DW_CFA_GNU_window_save: + case DW_CFA_AARCH64_negate_ra_state_with_pc: case CFI_escape: case CFI_label: break; diff --git a/gas/scfidw2gen.c b/gas/scfidw2gen.c index 7463207e170..9b3ad4b13e0 100644 --- a/gas/scfidw2gen.c +++ b/gas/scfidw2gen.c @@ -113,6 +113,7 @@ const pseudo_typeS scfi_pseudo_table[] = { "cfi_restore_state", dot_scfi_ignore, 0 }, { "cfi_window_save", dot_scfi_ignore, 0 }, { "cfi_negate_ra_state", dot_scfi_ignore, 0 }, + { "cfi_negate_ra_state_with_pc", dot_scfi_ignore, 0 }, { "cfi_escape", dot_scfi_ignore, 0 }, { "cfi_personality", dot_scfi_ignore, 0 }, { "cfi_personality_id", dot_scfi_ignore, 0 }, diff --git a/include/dwarf2.def b/include/dwarf2.def index 63cb35560e7..477b2ca20c0 100644 --- a/include/dwarf2.def +++ b/include/dwarf2.def @@ -785,6 +785,8 @@ DW_CFA (DW_CFA_hi_user, 0x3f) /* SGI/MIPS specific. */ DW_CFA (DW_CFA_MIPS_advance_loc8, 0x1d) +/* AArch64 extensions. */ +DW_CFA (DW_CFA_AARCH64_negate_ra_state_with_pc, 0x2c) /* GNU extensions. NOTE: DW_CFA_GNU_window_save is multiplexed on Sparc and AArch64. */ DW_CFA (DW_CFA_GNU_window_save, 0x2d) From patchwork Mon Jan 13 11:22:06 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthieu Longo X-Patchwork-Id: 104684 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 E5F59385828B for ; Mon, 13 Jan 2025 11:25:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5F59385828B Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=arm.com header.i=@arm.com header.a=rsa-sha256 header.s=selector1 header.b=EdZZYr/F X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2062c.outbound.protection.outlook.com [IPv6:2a01:111:f403:2607::62c]) by sourceware.org (Postfix) with ESMTPS id D635D385782C for ; Mon, 13 Jan 2025 11:23:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org D635D385782C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org D635D385782C Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=2a01:111:f403:2607::62c ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767386; cv=pass; b=woaEUYJYtlgMp8vACdeoA8yuoVV9W3liobEV4c3oArG1MWK02Pkb2sYKSORvFYsM4IwBzoC+SPRBK90j1E5gY4KLLanOZrLWPgJNRcAq2c3vl+crXJRUPTe/2GUQti08pWUBhHoFj8l/C4O39bwOXITLzOxXuOuTP4BZ8GttoUw= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1736767386; c=relaxed/simple; bh=CnOfBx0MNbLAbkuBGrd+/kPaAacpXRQhIRAJDcgm/+s=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=HOR9nFzvCRxEJ22d8Iu6PyGoRa+mFYozch5yXTWwIFosLnIp7xBCl9P2HPGkppvl+nncjx8c1aNL2dxAh4Aqv+GyBSPENmxYOhx0gobtCHVFGVe89A7ov12oZAULhHWKC6kwgYxGO5vX4Tgw2urNCNEQSuG3On4NOhwqRw70IsI= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=M5mNe/8FrKROtH9q6wSLK56sqGrPuTGjd21UsGtJPyjG+hxEXBdnqCPM8ELOLkxsQ0N31ulxWKb33u/B6wz83GQljObJg5+J6v/XbT5ngucuRAZLSVwGPDLT3Q3JejXZpEjHMPmlZ3h/Bbr5pVkHzp/7VumqH+YY5YVPEWqEScsjAwKrgVzBajzuM7+vdap/vMO9wEPet4+LLseHNs6Irkrkhy8xKkbxufFq/NaDVSa33VOxFdriHMrKquRG6vKO5HcCQBd57/7ABgtBJZ+hANZf8v27OQN13STl9KS3vs1AkYVU11vBWlHZtFBW55NFsic4bb3Zfonw861mW6AuBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=Zh03b1oaIWblPZaoHoJWCMwOYgtgF0n9vricOdOUUgI=; b=A+ElLysdflwqZ8aDrabaV/Mo94oTFKChC2gm4g57mCIkVPRKwB/yqDU//kXaEPMAZ1E/zTU1FWDmJIeWDzW6T5J7iVlBXerFbb4TC7xJ3VIwTsDmO+hRyqBJGP770OP7J6NAUIrjf2XecY/6MDrYMRERhNcDGvlhUwrNjXoXG5GzdPRpw5cIf3mFkbFZb8etxYxQ/5So+E99U2arQFdn47KazGrMbejyBYS8OnCTKWdNmYTXr8rjAiBoJGuF/ar54hvyOWqc1S7brpirXKRhY9szxlPmw04Nge595LC8kzhWwBoczg/B1EP0lZyY8bhK7+h1zFsrj+gOgF/syPNB/g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=fail (sender ip is 172.205.89.229) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=fail (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arm.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Zh03b1oaIWblPZaoHoJWCMwOYgtgF0n9vricOdOUUgI=; b=EdZZYr/FIQSw1tiq6y2225Z50Nbgr9K8RCeyZqsQKBHJfvaM75QaaMR/rKhYCH/r6aYpk1zLVZD0WHLAh3jukTWrrk4ma0CdXFVd/aQr40+GBqPi5ooOmwXgW4HldVp0jc7WisP0HIZ5pAbkbNsQaEvOKwfCKuwv/eI1OgEeTrA= Received: from AM5PR1001CA0016.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::29) by AS8PR08MB9954.eurprd08.prod.outlook.com (2603:10a6:20b:638::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.17; Mon, 13 Jan 2025 11:22:59 +0000 Received: from AMS1EPF0000004A.eurprd04.prod.outlook.com (2603:10a6:206:2:cafe::ed) by AM5PR1001CA0016.outlook.office365.com (2603:10a6:206:2::29) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.18 via Frontend Transport; Mon, 13 Jan 2025 11:22:59 +0000 X-MS-Exchange-Authentication-Results: spf=fail (sender IP is 172.205.89.229) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=fail action=none header.from=arm.com; Received-SPF: Fail (protection.outlook.com: domain of arm.com does not designate 172.205.89.229 as permitted sender) receiver=protection.outlook.com; client-ip=172.205.89.229; helo=nebula.arm.com; Received: from nebula.arm.com (172.205.89.229) by AMS1EPF0000004A.mail.protection.outlook.com (10.167.16.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.8356.11 via Frontend Transport; Mon, 13 Jan 2025 11:22:59 +0000 Received: from AZ-NEU-EX05.Arm.com (10.240.25.133) by AZ-NEU-EX05.Arm.com (10.240.25.133) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.39; Mon, 13 Jan 2025 11:22:58 +0000 Received: from PW070M4K.arm.com (10.1.32.155) by mail.arm.com (10.240.25.133) with Microsoft SMTP Server id 15.1.2507.39 via Frontend Transport; Mon, 13 Jan 2025 11:22:58 +0000 From: Matthieu Longo To: , Indu Bhagat CC: Richard Earnshaw , Nick Clifton , Jan Beulich , Matthieu Longo Subject: [PATCH v3 4/4] aarch64 SFrame: skip with warning new CFI directive used with pauth_lr Date: Mon, 13 Jan 2025 11:22:06 +0000 Message-ID: <20250113112206.1071596-5-matthieu.longo@arm.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <20250113112206.1071596-1-matthieu.longo@arm.com> References: <20250113112206.1071596-1-matthieu.longo@arm.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AMS1EPF0000004A:EE_|AS8PR08MB9954:EE_ X-MS-Office365-Filtering-Correlation-Id: 66016fe6-7b78-4e23-cda2-08dd33c4a309 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|376014|1800799024|82310400026|36860700013; X-Microsoft-Antispam-Message-Info: kltxEzxYkhiIdmv6xyTOXqmQaspovMUlj+0X6ccG+HzGN9NCvMZALLLpxV5CGxpD89rSS5Y12n2Vfo1lD42u7oi9lO0ACy99FWmnYNZQk94EMOL0AIhjsO7fm2PYEeEIkNCvxPELIpd7dDgWJgWiTZcmPiM7R5rOuon148TtU/6TauYtvIOEEj8PYrEfrX1DtQKDOyvScS6486n+exs9NbGYV90H4Vb2iabOCAESOAmjrJPUZIqGcNgzmCcMfU+tCZNDwc5D1f2Vqtmj76/8v2LarWyQxXRidDhta4u3U3WQ34T5rNBMiA63ElMd2PK5HTa5lq0BkSdUkDg3QrpGxLgHjx4rdZsjAKK7oTq/V8FHfvRZo1dpaTkBsuOAaMLzuiJYyppYs9EUdCRJpPzaDtvhRkLsIGQH1yJGe29InIaOjauSCDhH2G9cF6DJbuy2fuq4MjLlcQWmI7jYcxHUYmEb/x0FJGM3YB8hG0RY/+kNHHLl4WXXXD2yk1KfnBWYYfeAW8O/ARkgp6Dz/jLqisRg6QRu7pTuTJQVfW4d7U1Rc/e3YwDc6pyWfNkbhpsAnKWquPLFINhMMzIFmY72haJzWuYrm1BKwHYlFM+AolUD12yyqlC1kZKW0kMIzcFopilHcIbXSzAoCgN1qIoTIn1rsN7q4ai14TewIhMu5b+k2svOyPcBfFZOlZ0sYr6MRpJibiWvlYTIFP0L/iXDLx4ZLEB9U1Z8WvPxXPXzsf4ti9BxKGePLnj0Zj0Ib1nsUrLHcEIHoA3Qhd97QMdM1Ec5OGVf6PhFYJm3ykliU0yODkWI5adrJosyK4ydjwmtfWoWrHv3hMzfjiylsuAQHPOyl4CqlYc4ZbQ2jrqnZpo31PaQas+Dc3A6IXLpOA1kzI7VjkHNoS+AxsKKpkPRO0b3iLAyr4Pld4v6fQMjTC+qmLpOpCnLSYbiTylLndlPX+lGpzzfL5r7DdZB/cT476Sqd0chzQjk3axBg4zB5HS5ZmUKDbNySch3G0HQtHai7It7/SxJ6rOpT4r0sKhLU6oSAv1vGBew3JqV00DNtgJNdKGCGi/fKouXk5jYtrersWk0NCmEig+1yvLMe/1IrM2iJaDvQuD9Zv/wTVM1a1g1Lb3uqRW+NXtT9j69np0soNXriEgr5JB1JvZ7JSQzXjwzKYZUjbNZNZoM71HupRZR8/YdvnqLcAUte7pEFrpd8rH8A7Ki1c7YAvsGSoro0mSI3C83C4kPCCe5BaW5ilF3HwMkwgIm+A8ODm9oG8dNwZPYgQBZz77zl4fn/h4HFR9AbwkA3HfR4npse/U9ZTEKg572XgydEAVrKl6Be9hLrE14GAS1qf0tceY2+Jex+65ApX6CXlImN6T0lMmMhELGvsGx300aKDvRR7qhAUV+OiGVA5664rsk5p30IzQILynllBCNpfCrKKgOajkyvo+Kx7ODJwm5qvqlcwFHUQBQXNhdATX8ZMXul17gQeVNDtLTKLWmVzWLlCoGzROhN1U= X-Forefront-Antispam-Report: CIP:172.205.89.229; CTRY:IE; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:nebula.arm.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230040)(376014)(1800799024)(82310400026)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Jan 2025 11:22:59.8101 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 66016fe6-7b78-4e23-cda2-08dd33c4a309 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d; Ip=[172.205.89.229]; Helo=[nebula.arm.com] X-MS-Exchange-CrossTenant-AuthSource: AMS1EPF0000004A.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9954 X-Spam-Status: No, score=-11.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FORGED_SPF_HELO, GIT_PATCH_0, SPF_HELO_PASS, SPF_NONE, TXREP 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces~patchwork=sourceware.org@sourceware.org Today, SFrame v2 specification does not describe how to encode the information corresponding to the PAC signing method. SFrame v3 specification should hopefully specify it. In the meantime, if the GNU assembler finds .cfi_negate_ra_state_with_pc and --gsframe is specified, it will output a warning to the user and will fail to generate the FDE entry. A new SFrame test for .cfi_negate_ra_state_with_pc is also added to reflect this issue. --- gas/gen-sframe.c | 16 ++++++++++++ .../gas/cfi-sframe/cfi-sframe-aarch64-4.d | 25 +++++++++++++++++++ .../gas/cfi-sframe/cfi-sframe-aarch64-4.s | 23 +++++++++++++++++ gas/testsuite/gas/cfi-sframe/cfi-sframe.exp | 1 + 4 files changed, 65 insertions(+) create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.d create mode 100644 gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.s diff --git a/gas/gen-sframe.c b/gas/gen-sframe.c index a3c40bdd735..e96b7c02d09 100644 --- a/gas/gen-sframe.c +++ b/gas/gen-sframe.c @@ -1272,6 +1272,19 @@ sframe_xlate_do_aarch64_negate_ra_state (struct sframe_xlate_ctx *xlate_ctx, return SFRAME_XLATE_OK; } +/* Translate DW_CFA_AARCH64_negate_ra_state_with_pc into SFrame context. + Return SFRAME_XLATE_OK if success. */ + +static int +sframe_xlate_do_aarch64_negate_ra_state_with_pc (struct sframe_xlate_ctx *xlate_ctx ATTRIBUTE_UNUSED, + struct cfi_insn_data *cfi_insn ATTRIBUTE_UNUSED) +{ + as_warn (_("skipping SFrame FDE; .cfi_negate_ra_state_with_pc")); + /* The used signing method should be encoded inside the FDE in SFrame v3. + For now, PAuth_LR extension is not supported with SFrame. */ + return SFRAME_XLATE_ERR_NOTREPRESENTED; /* Not represented. */ +} + /* Translate DW_CFA_GNU_window_save into SFrame context. DW_CFA_GNU_window_save is a DWARF Sparc extension, but is multiplexed with a directive of DWARF AArch64 extension: DW_CFA_AARCH64_negate_ra_state. @@ -1387,6 +1400,9 @@ sframe_do_cfi_insn (struct sframe_xlate_ctx *xlate_ctx, case DW_CFA_GNU_window_save: err = sframe_xlate_do_gnu_window_save (xlate_ctx, cfi_insn); break; + case DW_CFA_AARCH64_negate_ra_state_with_pc: + err = sframe_xlate_do_aarch64_negate_ra_state_with_pc (xlate_ctx, cfi_insn); + break; case DW_CFA_register: err = sframe_xlate_do_register (xlate_ctx, cfi_insn); break; diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.d b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.d new file mode 100644 index 00000000000..c81888b0021 --- /dev/null +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.d @@ -0,0 +1,25 @@ +#as: --gsframe +#objdump: --sframe=.sframe +#name: SFrame cfi_negate_ra_state_with_pc test +#warning: Warning: skipping SFrame FDE; \.cfi_negate_ra_state_with_pc + +## The support for .cfi_negate_ra_state_with_pc is currently pending on SFrame +## v3 (currently in development). The unimplemented support is reported to the +## user as a warning. Then the handler returns an error that will cause no +## creation of a SFrame FDE later (hence "Num FDEs: 0"). +## Note: this test will be expected to fail when the support of PAuth_LR in +## SFrame will be added, so will have to be fixed. + +#... +Contents of the SFrame section .sframe: + + Header : + + Version: SFRAME_VERSION_2 + Flags: NONE + Num FDEs: 0 + Num FREs: 0 + + Function Index : + +#pass diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.s b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.s new file mode 100644 index 00000000000..5fec6740047 --- /dev/null +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe-aarch64-4.s @@ -0,0 +1,23 @@ +## ARMv9.5 enhanced the existing PAuth feature with a new extensio called +## PAuth_LR. It aims at hardening the PAC in a signed return address. When +## signing the return address in LR, the PC is used as a diversifier, in +## addition to the SP to generate the PAC code. +## As for PAuth, when the pointers are mangled with PAuth_LR, the stack trace +## generator needs to know so it can mask off the PAC from the pointer value to +## recover the return address, and conversely, skip doing so if the pointers are +## not mangled. +## +## .cfi_negate_ra_state_with_pc CFI directive is used to convey this information. +## +## SFrame has currently no support for this. The support is expected in SFrame +## v3. This testcase ensures that the directive is understood, and outputs +## a warning to the user before failing to generate the FDE. + .cfi_startproc + .long 0 + .cfi_def_cfa_offset 16 + .cfi_negate_ra_state_with_pc + .long 0 + .cfi_offset 29, -16 + .cfi_offset 30, -8 + .long 0 + .cfi_endproc diff --git a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp index 1de2c9f8037..b119b9da73d 100644 --- a/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp +++ b/gas/testsuite/gas/cfi-sframe/cfi-sframe.exp @@ -98,5 +98,6 @@ if { [istarget "aarch64*-*-*"] && [gas_sframe_check] } then { run_dump_test "cfi-sframe-aarch64-1" run_dump_test "cfi-sframe-aarch64-2" run_dump_test "cfi-sframe-aarch64-3" + run_dump_test "cfi-sframe-aarch64-4" run_dump_test "cfi-sframe-aarch64-pac-ab-key-1" }