From patchwork Fri Aug 12 15:40:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 56721 X-Patchwork-Delegate: rearnsha@gcc.gnu.org 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 B70D23858CDA for ; Fri, 12 Aug 2022 15:41:19 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B70D23858CDA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318879; bh=d7PWUxdz4163nrg/5JPRpP7HLMAXint0cpKvS39oZzk=; h=To:Subject:References:Date:In-Reply-To:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc: From; b=ocEHtzp5WheeIDkg4vAhnpWBWFS4ORCHT2MqAgDtx002IyudVN5+hKRlcud/cImXE 5K3qdX2AciHGtn1t/nAoF+/T6JOYW2jHjv9o90zhf/vUlzeTMRvKvXH9I9Xa1Hn3hZ W53uDr7uBKdE1py6ynd743Hdv8S0ep3/eYIhc4ts= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80051.outbound.protection.outlook.com [40.107.8.51]) by sourceware.org (Postfix) with ESMTPS id 9216E3858D28 for ; Fri, 12 Aug 2022 15:40:47 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 9216E3858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=KCwpKd7YPfYvKZzh788L/gqCNI1LJgSbfpaaQ5HxZJAwlnpcLxccMlJYT78wSFns0ZvKDrbWB7pM98vZiwyPNR82nHJgrWjLlDc7jhuF7bL0CWgOVQLY31NtpIzbK9ls/pZXGyoEzsUg4IkImxzxncTpJuOXTkUdDNtYf9cYVZw5jpklNX/b7uvModYFc9GCqkF3RM39KWzYiCWBbmZarmjPywBQ51gq6COTolWPVlhKUgwTqXxDClpRGjonYl/XLqYuWBUWNYMKwZc4zPoLz+mjg6Pq9Bxgs1ewVr4q5cvwqWqwEVQMPexGRWNy9Lf0fghFzQtXLap0H/rQE2HN4Q== ARC-Message-Signature: i=2; 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=d7PWUxdz4163nrg/5JPRpP7HLMAXint0cpKvS39oZzk=; b=oS9ZxApd+UVV8izmiw9eWKYBe9ExZ/25n5kf9wjWLQxCKvdmLd/rehlwaLA14IqqChfyXwl3LHcBUJHKqfaZQy4AFgtGXYpM4nD0nj9yQstnxIChSRpiuLfe71zHyZzQ6FVNy1USh3uSNpXvFF8qHq7jkew6dT1/yEE7zkXwTdlLQed4aQVg61dJPvN83UhpIMgHHGEYxXvD/6t0N6Czj+ep5TQFjY8eEtFHpUJaalDN3r2S/a+oiVqMmY5qzP7W9sH2hn6YAwUv1lyb4/MBnR62fieQ4kqB3djfnxDzjwPWe4kSqeWQ9lTbIE0Cxuh6O1f00+5vbSIw9wCgPNIX2w== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=gcc.gnu.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dmarc=[1,1,header.from=arm.com]) Received: from DU2PR04CA0208.eurprd04.prod.outlook.com (2603:10a6:10:28d::33) by HE1PR08MB2763.eurprd08.prod.outlook.com (2603:10a6:7:36::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.17; Fri, 12 Aug 2022 15:40:30 +0000 Received: from DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:28d:cafe::e1) by DU2PR04CA0208.outlook.office365.com (2603:10a6:10:28d::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.15 via Frontend Transport; Fri, 12 Aug 2022 15:40:30 +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 DBAEUR03FT065.mail.protection.outlook.com (100.127.142.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:40:30 +0000 Received: ("Tessian outbound 2af316122c7a:v123"); Fri, 12 Aug 2022 15:40:30 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 16f7986d39c83a70 X-CR-MTA-TID: 64aa7808 Received: from cc34d9bbfa81.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 6EA84A7B-4617-4947-B337-8D45D5D6526F.1; Fri, 12 Aug 2022 15:40:24 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id cc34d9bbfa81.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:40:24 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JqCCsiSXMFO3BCGT3CnrALbd8xB+3mdwfxAY6v5qytG4jZZqzvhp6A2hIaJlp+fo4nKnZXhZpR/evJWS21jGMPRvlYPHcPabtSrOA+1aUnaXhaiZnhQKpiP7BcBAr/U2y97MeFUP3JT2GOX4zmt2qpQfufahSxC/6G1Ba08j/9K+Pjooyi8OON1j6LqwBK3UmjP6gNl4wSqCjnvdW7ZjABA9eDDkoN10flEPa/968GncJMhwDKD4329AuBLJyCCnqul5z3oj8rcmMCpro4zdIuMSvQ3rMC1123GbbLPCqo2r1jpOpIkIPAmzcj7ixP6soLYk+a7znQVZjyCW10torQ== 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=d7PWUxdz4163nrg/5JPRpP7HLMAXint0cpKvS39oZzk=; b=iRiQGFSaP0r9YXK1GpSlMh7sTStj92hWOa9of1TWLCgQOXvrzXmfO5KlWfmQkli3ZrO6ztbcfssRnMmjuT0fyAUwOG/VBBHrqVOgXpfeHC7L5cZhX0ds6t6WOQmSRu92bhAhuI+z9XWRylHDI5NVP3lauX5622MGs9DbatQrK7Ez6sDuqy+KIw+fQHvS8EyQd/6kHOfEYwHuw5uh8pwReS2hYZpT1B9FsLNHiJSh7iv9YPtiqzXVJAieZnFdhCyJb4Eend9+zGP4sYbr6vo+S+2TGrlVA8eL8f9V+sGyJePA2sO3AVt44U34XQap9OiZwAFzyhXnnwsSzmDcPC+oBw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=gcc.gnu.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 AM6PR10CA0068.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:209:80::45) by AM8PR08MB5667.eurprd08.prod.outlook.com (2603:10a6:20b:1d8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.11; Fri, 12 Aug 2022 15:40:22 +0000 Received: from VE1EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:80:cafe::2c) by AM6PR10CA0068.outlook.office365.com (2603:10a6:209:80::45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10 via Frontend Transport; Fri, 12 Aug 2022 15:40: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 VE1EUR03FT015.mail.protection.outlook.com (10.152.18.176) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:40:21 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256) id 15.1.2507.9; Fri, 12 Aug 2022 15:40:19 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.9; Fri, 12 Aug 2022 15:40:19 +0000 Received: from e124257 (10.34.105.24) by mail.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.9 via Frontend Transport; Fri, 12 Aug 2022 15:40:19 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 11/15] aarch64: Make bti pass generic so it can be used by the arm backend References: Date: Fri, 12 Aug 2022 17:40:18 +0200 In-Reply-To: (Andrea Corallo via Gcc-patches's message of "Fri, 12 Aug 2022 16:26:49 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1.50 (gnu/linux) MIME-Version: 1.0 X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: 11fcb00d-1f33-4a02-8c11-08da7c78fce0 X-MS-TrafficTypeDiagnostic: AM8PR08MB5667:EE_|DBAEUR03FT065:EE_|HE1PR08MB2763:EE_ 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: NAFFHMWZoF2c1s0EH23GVLTFhUy/RlCjuRY6erDHFanlO7OQ9CUpuYag/qikz30zafoceNPLtO8GsDcJ182a9TYSHdJ9oOG1tTXPpGwWDbjZJbOzQXivjBT42HFZHw/6APbqPJnUsUY5/VM9nWsli5FDLMtyEn5CjIdes9FEk8+TqFqrGnHCPOeTPPTpD+VZwMDKYuUA+PTJF+JevOKZZYdQZasIpB1hCp4F/+zKaKqTtiz5je9HFkSrYl7U3m+zls+D2hG+0id3Btd4rbwzWN0cpk1dz3455er+tUqVQ722nkM9nR4mSTSutQk30QCaGtUV+ODRrpPcIQMTSTGdq49Uf1RS/DGcAJFr5/UdhPuuhukT2U0d/dLwEvG43U5ZHDoQcQ1vdi5fWqw5IkIKfm7202xLVh1NNXH1sv3gsWR42HsHcwlb0k4Rzh6XboALSN5T60czxwISvn+7EjvyX6Lxq+YFk67TKiijo4G0VeM2qDXKO0GNt3IBeo+/cbEbUrZz+k7Qc9Ouqc/W+0O3Wh3MOrqec/OznvS87aK+SY+nK6QXCs0+Rf6s2VUO0sE4jxv+gS/eQzcvSsEWXA8vr0qH51DKKWj81gh/wU0/AvMTeIuDU42PXrU8sPKrAFFhy9SMa/iRrk2s0cuSDqk4aPGBaF7E1J1vVCwjO9gKhcYgwHkhVn36Ojd0eJjTLdAb+1Y15lzHyjYVDvgi895zahoXStFETJm9JQAdJHDv9tUhTUvV+JPp3FmmLJK7VkRmKFDIeaK8F0Z5DvmYRLH+Ah0l/VYllK04c0qeu2iPWygIYzOdOxN5SQTWBmy7Ii1OWJ029EqS8FQRUGk7/ZaTf8uXNJGjMWeom8Qp4l5BndwSxFXVEQN2nfeM6+q+ul8MBHeUKQ/B+LfhBQvddu1r3A== 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:(13230016)(4636009)(39860400002)(376002)(396003)(136003)(346002)(40470700004)(36840700001)(46966006)(356005)(5660300002)(235185007)(33964004)(81166007)(41300700001)(26005)(8936002)(86362001)(54906003)(6916009)(40480700001)(478600001)(70206006)(82310400005)(70586007)(426003)(4326008)(8676002)(316002)(2906002)(36860700001)(36756003)(186003)(44832011)(336012)(83380400001)(40460700003)(2616005)(47076005)(82740400003)(41533002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 64/akfM048rJiKjty7zJskf6PXHtmyBaYWyOYjVjFx2RUvTKrUVEMuwkMksZM3Jve1x8lUe5lB9a1OBvPHm6zwhhMfkHTEBGxDdKc/MBqs5SzYZlkF1FfnJN8TNcfbJonOAAHACcXLG+0RDW3DVRJ8Z8n11KsSwKrLlxSWOJq+WZpmMBV/soNTqJLgPpu/jCYdN7Dcr6pFhwkOAalEcbIA5xLV218PYv7cGL+7/D5NoHDNLR30kRq5Bu8mUbXjc++wI/AO5IoFE/qA0+z4vZn+4nvoYhyLFUoB58Cr4N7kpbsb7pbHLaL9c00z8ISyyqyiVaqwPfm7Vuh/4VYf/88neTHBUOcTaCF59OEhMKZzThw+I85Bp2yAm73uriu9PisK6i5J0OO0tXvED1SpgQXWFrZgz63oMPK/ltZMFswtu25RMQcTNpH/AmwbT3sm93zh/Zcs9g20vu8c5+EWpv5n7ljlTbeaMCHX+jAKaDe3nNhR2r3lvtynl5wwB9HaBSnCgQ1Dh4q8RWweVjSO1lExk1NNQw0rBjhpNzZphWfUm1eknE8QJmA0g4+DWOgOp95BC03BvU5qcxCTBKTwK1CYGKXnu0aQw5VmsbUSKcV3CaPn7D6iSbRfdI/FESJjCgktbtV+Q0o4pZZc0/YI4jv5w3AU8JFd0ntLDEAUYikQxz5mNUOfkTxuCVJM9tNre8Fp+QoFSmfdWSU1pl+OSi7Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM8PR08MB5667 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 28edc644-08de-4856-0e62-08da7c78f7b2 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hdxx5a6b01AvFISiXA+2LNLpOT3eml941cmSqPl3TLxyCIOrnngXBY7lIbLY5YvytoNyGk3Z2F2Ym3YwBH/dqVmuFDWjNhOxfeolZeCbZvPAxY0S6WKD7uvClgTjNYvVMtWUkuxLJQJW0lNqIJpxGQnL7iWtx0peZ7L+lVlFC7fDihhIHXEWv9CmIw+m/oOiA2sQr8LnA1skdpo70OdWxzHvHLVxh19L60fS6mCcSW76ox0hjXj63r0eXmt9IXc/Hhe/fmbVNtTSy6489rJvREaNtc330I3gzu6+qVNJ0Q07iPbuFI/NxlpUmG9/dLZ+RlvHD+1vGTHFICjQRAUSYOSZsJMPA9fYkOSztm/52KtW8BNAxGnPAf25ImUp91ZPP6Og6DpqCJ1klNnrznY9uB1guLI1AuW48rrt9O+fiG9AqorT8sBMA2jccKeEdkC93Yp6iF1REMv/6l8EnVL33UR+bvyxqaaKPnOUbeBRXKdQDNOcbtq9ODEGgldmii0671dAf5NfCSzGHfnVLBsjAi7nkZyPQJRokx4cDnwSRULriFbovq/HvvnnOYpg0GC7ZH5LfSdRj6PalhJOS0d3MD8RB17VMBfWh8T7ilkYFP2WG6VHxGa2X1pqso+/qoKZG/XgcQ9O9a2Pgc8bBdqMcfRVtxg6LYnJPjDW0PFlB8LKLYKf92eIjGcAJ3yYO/GDrba6RKhVdjtoL43Rj9ZE0TikOK7Vy/P0nVFa0AzqmKYO23vlJSysQEEatAHnDCcIdCjaAaohk/jI28VPtatc+Ybyt4XlBcbmg99aQ+S+cdO9A1WNc09jlf8LLQjT+T0WinOuB9XGEouPbELgbV8NOqhhqRYKM2nKCP2hb0F4Vcs= 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:(13230016)(4636009)(396003)(346002)(39860400002)(136003)(376002)(40470700004)(36840700001)(46966006)(26005)(336012)(2616005)(4326008)(82310400005)(36756003)(83380400001)(47076005)(186003)(426003)(316002)(41300700001)(36860700001)(2906002)(86362001)(6916009)(33964004)(44832011)(70206006)(40460700003)(82740400003)(54906003)(235185007)(5660300002)(70586007)(478600001)(8676002)(8936002)(40480700001)(81166007)(41533002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:40:30.6684 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 11fcb00d-1f33-4a02-8c11-08da7c78fce0 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: DBAEUR03FT065.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR08MB2763 X-Spam-Status: No, score=-12.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE, 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: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Andrea Corallo via Gcc-patches From: Andrea Corallo Reply-To: Andrea Corallo Cc: Richard Earnshaw , nd Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi all, this patch splits and restructures the aarch64 bti pass code in order to have it usable by the arm backend as well. These changes have no functional impact. The original patch was approved here: . After that Richard E. noted that was better to move the new pass definition for arm in the following patch and so I did. Best Regards Andrea gcc/Changelog * config.gcc (aarch64*-*-*): Rename 'aarch64-bti-insert.o' into 'aarch-bti-insert.o'. * config/aarch64/aarch64-protos.h: Remove 'aarch64_bti_enabled' proto. * config/aarch64/aarch64.cc (aarch_bti_enabled): Rename. (aarch_bti_j_insn_p, aarch_pac_insn_p): New functions. (aarch64_output_mi_thunk) (aarch64_print_patchable_function_entry) (aarch64_file_end_indicate_exec_stack): Update renamed function calls to renamed functions. * config/aarch64/t-aarch64 (aarch-bti-insert.o): Update target. * config/arm/aarch-bti-insert.cc: New file including and generalizing code from aarch64-bti-insert.cc. * config/arm/aarch-common-protos.h: Update. diff --git a/gcc/config.gcc b/gcc/config.gcc index 7b58e1314ff..2021bdf9d2f 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -329,7 +329,7 @@ aarch64*-*-*) c_target_objs="aarch64-c.o" cxx_target_objs="aarch64-c.o" d_target_objs="aarch64-d.o" - extra_objs="aarch64-builtins.o aarch-common.o aarch64-sve-builtins.o aarch64-sve-builtins-shapes.o aarch64-sve-builtins-base.o aarch64-sve-builtins-sve2.o cortex-a57-fma-steering.o aarch64-speculation.o falkor-tag-collision-avoidance.o aarch64-bti-insert.o aarch64-cc-fusion.o" + extra_objs="aarch64-builtins.o aarch-common.o aarch64-sve-builtins.o aarch64-sve-builtins-shapes.o aarch64-sve-builtins-base.o aarch64-sve-builtins-sve2.o cortex-a57-fma-steering.o aarch64-speculation.o falkor-tag-collision-avoidance.o aarch-bti-insert.o aarch64-cc-fusion.o" target_gtfiles="\$(srcdir)/config/aarch64/aarch64-builtins.cc \$(srcdir)/config/aarch64/aarch64-sve-builtins.h \$(srcdir)/config/aarch64/aarch64-sve-builtins.cc" target_has_targetm_common=yes ;; diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc index b0c5a4fd6b6..a9aad3abdc2 100644 --- a/gcc/config/aarch64/aarch64-c.cc +++ b/gcc/config/aarch64/aarch64-c.cc @@ -179,7 +179,7 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) aarch64_def_or_undef (TARGET_RNG, "__ARM_FEATURE_RNG", pfile); aarch64_def_or_undef (TARGET_MEMTAG, "__ARM_FEATURE_MEMORY_TAGGING", pfile); - aarch64_def_or_undef (aarch64_bti_enabled (), + aarch64_def_or_undef (aarch_bti_enabled (), "__ARM_FEATURE_BTI_DEFAULT", pfile); cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index fe2180e95ea..9fdf7f9cc9c 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -891,7 +891,6 @@ void aarch64_register_pragmas (void); void aarch64_relayout_simd_types (void); void aarch64_reset_previous_fndecl (void); bool aarch64_return_address_signing_enabled (void); -bool aarch64_bti_enabled (void); void aarch64_save_restore_target_globals (tree); void aarch64_addti_scratch_regs (rtx, rtx, rtx *, rtx *, rtx *, diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index eec743024c1..2f67f3872f6 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -8534,11 +8534,61 @@ aarch64_return_address_signing_enabled (void) /* Return TRUE if Branch Target Identification Mechanism is enabled. */ bool -aarch64_bti_enabled (void) +aarch_bti_enabled (void) { return (aarch_enable_bti == 1); } +/* Check if INSN is a BTI J insn. */ +bool +aarch_bti_j_insn_p (rtx_insn *insn) +{ + if (!insn || !INSN_P (insn)) + return false; + + rtx pat = PATTERN (insn); + return GET_CODE (pat) == UNSPEC_VOLATILE && XINT (pat, 1) == UNSPECV_BTI_J; +} + +/* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ +bool +aarch_pac_insn_p (rtx x) +{ + if (!INSN_P (x)) + return false; + + subrtx_var_iterator::array_type array; + FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (x), ALL) + { + rtx sub = *iter; + if (sub && GET_CODE (sub) == UNSPEC) + { + int unspec_val = XINT (sub, 1); + switch (unspec_val) + { + case UNSPEC_PACIASP: + case UNSPEC_PACIBSP: + return true; + + default: + return false; + } + iter.skip_subrtxes (); + } + } + return false; +} + +rtx aarch_gen_bti_c (void) +{ + return gen_bti_c (); +} + +rtx aarch_gen_bti_j (void) +{ + return gen_bti_j (); +} + /* The caller is going to use ST1D or LD1D to save or restore an SVE register in mode MODE at BASE_RTX + OFFSET, where OFFSET is in the range [1, 16] * GET_MODE_SIZE (MODE). Prepare for this by: @@ -9918,7 +9968,7 @@ aarch64_output_mi_thunk (FILE *file, tree thunk ATTRIBUTE_UNUSED, rtx_insn *insn; const char *fnname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (thunk)); - if (aarch64_bti_enabled ()) + if (aarch_bti_enabled ()) emit_insn (gen_bti_c()); reload_completed = 1; @@ -22360,7 +22410,7 @@ aarch64_print_patchable_function_entry (FILE *file, bool record_p) { if (cfun->machine->label_is_assembled - && aarch64_bti_enabled () + && aarch_bti_enabled () && !cgraph_node::get (cfun->decl)->only_called_directly_p ()) { /* Remove the BTI that follows the patch area and insert a new BTI @@ -26689,7 +26739,7 @@ aarch64_file_end_indicate_exec_stack () file_end_indicate_exec_stack (); unsigned feature_1_and = 0; - if (aarch64_bti_enabled ()) + if (aarch_bti_enabled ()) feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI; if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) diff --git a/gcc/config/aarch64/t-aarch64 b/gcc/config/aarch64/t-aarch64 index 75b463d2f03..eb6ad3db955 100644 --- a/gcc/config/aarch64/t-aarch64 +++ b/gcc/config/aarch64/t-aarch64 @@ -149,14 +149,14 @@ falkor-tag-collision-avoidance.o: \ $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ $(srcdir)/config/aarch64/falkor-tag-collision-avoidance.cc -aarch64-bti-insert.o: $(srcdir)/config/aarch64/aarch64-bti-insert.cc \ +aarch-bti-insert.o: $(srcdir)/config/arm/aarch-bti-insert.cc \ $(CONFIG_H) $(SYSTEM_H) $(TM_H) $(REGS_H) insn-config.h $(RTL_BASE_H) \ dominance.h cfg.h cfganal.h $(BASIC_BLOCK_H) $(INSN_ATTR_H) $(RECOG_H) \ output.h hash-map.h $(DF_H) $(OBSTACK_H) $(TARGET_H) $(RTL_H) \ $(CONTEXT_H) $(TREE_PASS_H) regrename.h \ $(srcdir)/config/aarch64/aarch64-protos.h $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ - $(srcdir)/config/aarch64/aarch64-bti-insert.cc + $(srcdir)/config/arm/aarch-bti-insert.cc aarch64-cc-fusion.o: $(srcdir)/config/aarch64/aarch64-cc-fusion.cc \ $(CONFIG_H) $(SYSTEM_H) $(CORETYPES_H) $(BACKEND_H) $(RTL_H) $(DF_H) \ diff --git a/gcc/config/aarch64/aarch64-bti-insert.cc b/gcc/config/arm/aarch-bti-insert.cc similarity index 80% rename from gcc/config/aarch64/aarch64-bti-insert.cc rename to gcc/config/arm/aarch-bti-insert.cc index 7caed310bbc..2d1d2e334a9 100644 --- a/gcc/config/aarch64/aarch64-bti-insert.cc +++ b/gcc/config/arm/aarch-bti-insert.cc @@ -42,10 +42,11 @@ #include "tree-pass.h" #include "cgraph.h" -/* This pass enables the support for Branch Target Identification Mechanism - for AArch64. This is a new security feature introduced in ARMv8.5-A - archtitecture. A BTI instruction is used to guard against the execution - of instructions which are not the intended target of an indirect branch. +/* This pass enables the support for Branch Target Identification Mechanism for + Arm/AArch64. This is a security feature introduced in ARMv8.5-A + architecture and ARMv8.1-M. A BTI instruction is used to guard against the + execution of instructions which are not the intended target of an indirect + branch. Outside of a guarded memory region, a BTI instruction executes as a NOP. Within a guarded memory region any target of an indirect branch must be @@ -53,7 +54,8 @@ branch is triggered in a non-guarded memory region). An incompatibility generates a Branch Target Exception. - The compatibility of the BTI instruction is as follows: + The compatibility of the BTI instruction is as follows (AArch64 + examples): BTI j : Can be a target of any indirect jump (BR Xn). BTI c : Can be a target of any indirect call (BLR Xn and BR X16/X17). BTI jc: Can be a target of any indirect call or indirect jump. @@ -90,47 +92,6 @@ const pass_data pass_data_insert_bti = 0, /* todo_flags_finish. */ }; -/* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ -static bool -aarch64_pac_insn_p (rtx x) -{ - if (!INSN_P (x)) - return false; - - subrtx_var_iterator::array_type array; - FOR_EACH_SUBRTX_VAR (iter, array, PATTERN (x), ALL) - { - rtx sub = *iter; - if (sub && GET_CODE (sub) == UNSPEC) - { - int unspec_val = XINT (sub, 1); - switch (unspec_val) - { - case UNSPEC_PACIASP: - /* fall-through. */ - case UNSPEC_PACIBSP: - return true; - - default: - return false; - } - iter.skip_subrtxes (); - } - } - return false; -} - -/* Check if INSN is a BTI J insn. */ -static bool -aarch64_bti_j_insn_p (rtx_insn *insn) -{ - if (!insn || !INSN_P (insn)) - return false; - - rtx pat = PATTERN (insn); - return GET_CODE (pat) == UNSPEC_VOLATILE && XINT (pat, 1) == UNSPECV_BTI_J; -} - /* Insert the BTI instruction. */ /* This is implemented as a late RTL pass that runs before branch shortening and does the following. */ @@ -155,7 +116,7 @@ rest_of_insert_bti (void) && (LABEL_PRESERVE_P (insn) || bb->flags & BB_NON_LOCAL_GOTO_TARGET)) { - bti_insn = gen_bti_j (); + bti_insn = aarch_gen_bti_j (); emit_insn_after (bti_insn, insn); continue; } @@ -177,10 +138,10 @@ rest_of_insert_bti (void) { label = as_a (XEXP (RTVEC_ELT (vec, j), 0)); rtx_insn *next = next_nonnote_nondebug_insn (label); - if (aarch64_bti_j_insn_p (next)) + if (aarch_bti_j_insn_p (next)) continue; - bti_insn = gen_bti_j (); + bti_insn = aarch_gen_bti_j (); emit_insn_after (bti_insn, label); } } @@ -191,7 +152,7 @@ rest_of_insert_bti (void) will return. */ if (CALL_P (insn) && (find_reg_note (insn, REG_SETJMP, NULL))) { - bti_insn = gen_bti_j (); + bti_insn = aarch_gen_bti_j (); emit_insn_after (bti_insn, insn); continue; } @@ -207,9 +168,9 @@ rest_of_insert_bti (void) { bb = ENTRY_BLOCK_PTR_FOR_FN (cfun)->next_bb; insn = BB_HEAD (bb); - if (!aarch64_pac_insn_p (get_first_nonnote_insn ())) + if (!aarch_pac_insn_p (get_first_nonnote_insn ())) { - bti_insn = gen_bti_c (); + bti_insn = aarch_gen_bti_c (); emit_insn_before (bti_insn, insn); } } @@ -229,7 +190,7 @@ public: /* opt_pass methods: */ virtual bool gate (function *) { - return aarch64_bti_enabled (); + return aarch_bti_enabled (); } virtual unsigned int execute (function *) diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index 17a369f7e99..374982752ad 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -42,6 +42,11 @@ extern int arm_no_early_alu_shift_value_dep (rtx, rtx); extern int arm_no_early_mul_dep (rtx, rtx); extern int arm_no_early_store_addr_dep (rtx, rtx); extern bool arm_rtx_shift_left_p (rtx); +extern bool aarch_bti_enabled (void); +extern bool aarch_bti_j_insn_p (rtx_insn *); +extern bool aarch_pac_insn_p (rtx); +extern rtx aarch_gen_bti_c (void); +extern rtx aarch_gen_bti_j (void); /* RTX cost table definitions. These are used when tuning for speed rather than for size and should reflect the _additional_ cost over the cost