From patchwork Fri Aug 12 15:14:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 497 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp937052pxh; Fri, 12 Aug 2022 08:15:42 -0700 (PDT) X-Google-Smtp-Source: AA6agR4YVLzhc6HgA6qkfStJ+VbjrzCx+K1y7tLp5JURynCeqNmXyQu4WxCsIJHHmDqEcEFI97sZ X-Received: by 2002:a05:6402:270c:b0:43d:efd3:883e with SMTP id y12-20020a056402270c00b0043defd3883emr4158740edd.221.1660317341977; Fri, 12 Aug 2022 08:15:41 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id du4-20020a17090772c400b007277dd43476si2334816ejc.347.2022.08.12.08.15.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:15:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=ZksC3TSa; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 78D793858286 for ; Fri, 12 Aug 2022 15:15:40 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 78D793858286 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660317340; bh=cKd7ESms3l4R0mF1FaLcGLkgFs6MnbsjPU7EQuGffNs=; 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=ZksC3TSax17+M9IvqWF+mR6xgF8G91p6xuPeiV869kS3nuiez9sGNsfk69c16d6Gs 8zkrSvql5kpa7iM46ghh2v6/LOzQ7eWUOkQR2z1VcB3zb+HUtfVVnLJdW4ETYXlVhB JaHccs6u3khrx8zTcPWWGGPaVmaMsUmJPgJmG9/U= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2074.outbound.protection.outlook.com [40.107.22.74]) by sourceware.org (Postfix) with ESMTPS id C6AA93858D28 for ; Fri, 12 Aug 2022 15:14:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C6AA93858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=OLMqF8y4wfTWstXeJA9hvtDapwdSN+D3wSU0qL6HPozfSUsYZFMCVEe5Gzy1znWwX7rnjyTV3AXxTuMFfD7SG8PN5MY0WzVWH6fJI6okZ5ymPCk+uXy8ovscj/XBFJdlm8YYYlQhIYBgWSyeCLnR71j9HBUr14jNHcXAv2UZRXcamDUX+iOCnwd3DtfzKIiU31O+qCohbETCOmyD2jEu/bkXGkS3V9ER7HckM4UfW1x/9RwoR6F+IR3b7igdA1oaYSa59FPfk5ekB0Yj4BQUt+oCR1vJ9Czld/S6lsWLTx9D/6sgvyhPlofDr+P5lHwCpWnK1limwJBD2X/RPF+kZg== 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=cKd7ESms3l4R0mF1FaLcGLkgFs6MnbsjPU7EQuGffNs=; b=FlrSfP3wIrjan0jVsqghrPwnF2ZzDE17Yx8pmM3NFO6DHMqzl6OkehqOzBvgVkhsAqOp/Bl1xuYGYqsejS5Hn82eOzofFROagEr2VIBoLbcFfstwCiw9I+EANi65ZW49rF8cFjeungns0zADe2PtwZX0Cj3pBwdrIfQkIcdGiUyvrCEy3FGTuiNGVG169fLjoEmyiYDdu64G8yxMCZJg12BJL1cUfCtdZwVZp+8lf/6DQXjTdBjTrcpRjh9bWaQFRCbcNZp2SWJ4zkejnMfPie2GgzNqKcnvLu2a99GlA9ZysFuG70AJ211Y0mIfSXgIrEMVHspaQyNuPfdQTpwQgQ== 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 AS9PR06CA0154.eurprd06.prod.outlook.com (2603:10a6:20b:45c::28) by DB6PR0801MB1765.eurprd08.prod.outlook.com (2603:10a6:4:38::20) 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:14:42 +0000 Received: from AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45c:cafe::6d) by AS9PR06CA0154.outlook.office365.com (2603:10a6:20b:45c::28) 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:14:42 +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 AM7EUR03FT004.mail.protection.outlook.com (100.127.140.210) 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:14:41 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:14:41 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 54a0b6e787d5f67a X-CR-MTA-TID: 64aa7808 Received: from 0710831676d8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C29AAE99-0D9E-4BFC-ADC9-A59FEB3776D6.1; Fri, 12 Aug 2022 15:14:34 +0000 Received: from EUR05-DB8-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 0710831676d8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:14:34 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhssdmPANbMvTCBMsnuHTZQPp8o+UNnkWO74eXVDiHEgqIZLO+6dc+H8nTgFq6XQgOIP8+iE5BlwZKSWWOBhqgpYSpXQvtHrt1+3tawlfqOpE4D91LyIgG0VHyr+uDCCu+4DUQiKdl5VKMS4YVXEBY995hcHbXPFt9ZaUMUlnioxBtN0ON8e2UmzgopbNqUBrhu9RQbQiuDq9rUm+xHkNph/F0ZXHFnmBZfIZZMxabqy7cR9DmD9h4BL79Ej3U0c0KNT9E3oD6Zta2ZZFFMuO724iNb50ANc17Tw092IqgTxFeBJgQ1YY9LJ0pOT7YK3lt0zbTC/CuT41garyNKAzg== 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=cKd7ESms3l4R0mF1FaLcGLkgFs6MnbsjPU7EQuGffNs=; b=nEIRgEM4k3NRBvw4YLpWeI0ljjELqjKF70leICliWZB/vnxIY31EXR/ovwzaKjPQ4yj0nYpOT9cIt+089M26xGBf2N3f9M5g865wTuq86aKwVy+ub2b3Zdn4gImd8Cth10tKsQAL/qo90Hyf0g9/iwZTihHVyDqMSnKFJSTcI53huojhV3yI/VjogEzEF/xSjPtp7EIrrJ852OtPhZ+FRD3akMygIk4lSvlym40B4vJU3b1nbHxw81rtL08LvYLqy6fLlGYyenRU3/KunUboxtAYtmrU0boQ48jpeMgwJyJj+nMG7Dsn74+20hs681Tjwxu2EAaKxxNz9QlZS46OLQ== 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 FR3P281CA0001.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::10) by VE1PR08MB5760.eurprd08.prod.outlook.com (2603:10a6:800:1af::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:14:32 +0000 Received: from VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1d:cafe::a0) by FR3P281CA0001.outlook.office365.com (2603:10a6:d10:1d::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.10 via Frontend Transport; Fri, 12 Aug 2022 15:14:32 +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 VE1EUR03FT050.mail.protection.outlook.com (10.152.19.209) 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:14:32 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.9; Fri, 12 Aug 2022 15:14:28 +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:14:27 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 1/15] arm: Make mbranch-protection opts parsing common to AArch32/64 References: Date: Fri, 12 Aug 2022 17:14:27 +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: 1ee3ca1b-25d9-4542-054d-08da7c7561cf X-MS-TrafficTypeDiagnostic: VE1PR08MB5760:EE_|AM7EUR03FT004:EE_|DB6PR0801MB1765: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: L00JTESJm9JohEjZL4WLSaterZSFEUVePNjfYlztyloDvITM6/AvEk4iwxkk3m9Mqr8vNw9KyHdvkk7AbYQn5BsEMBEb8nXuWVxFiWWXlPfItrbbGbtdTZwyRx/QP2kgkPLVS5vnZxgCPD36/oqII6SWPocDbqAuCDmOBVh3DdN4DbYWjfHwnPoycJFdYhZa2Oe/6UBfAQV6EXPPuOMJR5BXUQS4qEYleK+xBH40yT9V7DIbQZ724ENLaJKRQak5TB+B/GvYUy5rVP67EfZBo6Dt4h6fXgJmzSFZWlWjtJTngQoWVbZDqF7H2G2SewqD651A9iMQa89sebaEKL8YYJU72iFNajJjxquN2ctT2cYJ+0DM+y52+qz0aurWcVIwt7mSgzpH/Zlyrml+VMFyaFVfeQZKOQXJbDPWAm2/+rSBA5ZcxAMYIUwes+hCUnZlprweVqb8RJXT9PFsFNLtv/GchFp3v3qUdcVtuzhJjZ7Xp4wyQHPA9QSYmzNW20HqAMLeN/lihxATAYZOSDPXmsw6cPfR9fa4RVY3kA39j0EKzCzasEJbhVER9F18ap4sA1/3x3Iz/DdVm6YKHAKgNmf8ApSwkAcw3P88Az4p24oNm7EvUS5iRgzbu0/jpfqf6YJFE1j+qTzfLe1cTmxB9kPFCdFpFxShrttZXSXVw1kTvnbyl9wDbtwVtfkaXTjV8UOAfMgh91X02m0wuTgsF+ydzclsYXU7AN/X2fK+4xlITEg9GT9KwzJJp793z7YHrZM2CMtHJuoPz7458YSDG/nUf9wvFriyJxzMN9OezVCj9DqwUd3UrQoEUj/OgMnJnmM8M/mq36aU4HsHEQB9FZEsn26ZM7TnRpGRVMi/fvRafVdj8ZY7kgnReiB9X1NI 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)(376002)(396003)(39860400002)(136003)(346002)(46966006)(36840700001)(40470700004)(40460700003)(356005)(2906002)(8936002)(5660300002)(235185007)(44832011)(26005)(40480700001)(81166007)(86362001)(82310400005)(47076005)(2616005)(186003)(336012)(33964004)(426003)(41300700001)(36860700001)(83380400001)(478600001)(316002)(6916009)(4326008)(8676002)(82740400003)(70586007)(54906003)(70206006)(36756003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5760 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 5504b4d3-76f1-47b7-6bff-08da7c755c2d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: WLv+uQyC64kHDnqQrEYG7es/oV0oiiKd4yt3IGr1F5jL3dOgYnbEVgzT54MUN9LMiq/B6zXme9K3JZhxiBGm6SHT8gNYQj5gtRnN6H13KFq1tysMyuG9/bnmbSEBoF4/U2RDRkDiwhryy6Y1pro/679kjY112AJBZoQTWUV1za3DvO1cqp/9lPxY/5hcTF7Xn4QuM+ZaKyld+iq9trmytAgD0rzYub4cXepuL6kcwCXuzLERfuGo+HqQjvR8v3jNQ8aa++H4FAxuQkf76kCRMfVX6YUB01b2XkbU6XPZexeLk1e6QA7gNzUdB2o8HqrAQcawcbGwXzbX3V+6E5r0NGMYS+nc9gb86PD+9RJ1z79jQuDxrkPTiqwm730OXgrRgEBwBFgdiYFf6AOHVv2IR9GAfn2toNdPBKpp1hnlNKH31wpkWR/0Fm96dM5h4snaQGxYNJ2yXjtRXVCJosjaxrIWMV0iHQdyD7kQGiI4Q79SRQo9eC7MpLqxns6ZeYVJO3+pjS8/ZMVmsgyWi+JEBw+AesSp+Q5ZSJ+qLvRwCwVc2w2BrAZN+j5awfJUS+fZXDfKMuDXhG7wV8jI2sGcXRl9nzGh1pLi7jI9Glwci+husareqlftEXPXu3RXFt5NVfxZJ311RAGZkkTV1XpAUWvxdybiV7lLFyVQlEJHZQKuG0Y9et+iebEaLALjZoOjp0KjVQ/45x8uDH+tFAUCZS2isN/3AFbl/PPRFg27NyX5fbZYQzA9Wpx6O85Z20R13VNOq+JIirwhdfrWEeDIic/aZuuKqujHg/46zNRVTjMG0JQsZH2dwHkXtO7ecvZ84G9lA1YKWyNmHubumxbdMA== 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)(376002)(39860400002)(396003)(136003)(346002)(40470700004)(46966006)(36840700001)(33964004)(2616005)(336012)(426003)(47076005)(186003)(41300700001)(54906003)(316002)(26005)(478600001)(86362001)(82310400005)(82740400003)(40460700003)(6916009)(83380400001)(81166007)(36860700001)(44832011)(40480700001)(235185007)(5660300002)(8936002)(36756003)(70206006)(8676002)(2906002)(70586007)(4326008); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:14:41.9540 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1ee3ca1b-25d9-4542-054d-08da7c7561cf 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: AM7EUR03FT004.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1765 X-Spam-Status: No, score=-11.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, FORGED_SPF_HELO, GIT_PATCH_0, KAM_DMARC_NONE, KAM_NUMSUBJECT, KAM_SHORT, KAM_STOCKGEN, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740968917076092446?= X-GMAIL-MSGID: =?utf-8?q?1740968917076092446?= Hi all, This change refactors all the mbranch-protection option parsing code and types to make it common to both AArch32 and AArch64 backends. This change also pulls in some supporting types from AArch64 to make it common (aarch_parse_opt_result). The significant changes in this patch are the movement of all branch protection parsing routines from aarch64.c to aarch-common.c and supporting data types and static data structures. This patch also pre-declares variables and types required in the aarch32 back-end for moved variables for function sign scope and key to prepare for the impending series of patches that support parsing the feature mbranch-protection in the aarch32 back-end. Approved here gcc/ChangeLog: * common/config/aarch64/aarch64-common.cc: Include aarch-common.h. (all_architectures): Fix comment. (aarch64_parse_extension): Rename return type, enum value names. * config/aarch64/aarch64-c.cc (aarch64_update_cpp_builtins): Rename factored out aarch_ra_sign_scope and aarch_ra_sign_key variables. Also rename corresponding enum values. * config/aarch64/aarch64-opts.h (aarch64_function_type): Factor out aarch64_function_type and move it to common code as aarch_function_type in aarch-common.h. * config/aarch64/aarch64-protos.h: Include common types header, move out types aarch64_parse_opt_result and aarch64_key_type to aarch-common.h * config/aarch64/aarch64.cc: Move mbranch-protection parsing types and functions out into aarch-common.h and aarch-common.cc. Fix up all the name changes resulting from the move. * config/aarch64/aarch64.md: Fix up aarch64_ra_sign_key type name change and enum value. * config/aarch64/aarch64.opt: Include aarch-common.h to import type move. Fix up name changes from factoring out common code and data. * config/arm/aarch-common-protos.h: Export factored out routines to both backends. * config/arm/aarch-common.cc: Include newly factored out types. Move all mbranch-protection code and data structures from aarch64.cc. * config/arm/aarch-common.h: New header that declares types shared between aarch32 and aarch64 backends. * config/arm/arm-protos.h: Declare types and variables that are made common to aarch64 and aarch32 backends - aarch_ra_sign_key, aarch_ra_sign_scope and aarch_enable_bti. Co-Authored-By: Tejas Belagod diff --git a/gcc/common/config/aarch64/aarch64-common.cc b/gcc/common/config/aarch64/aarch64-common.cc index dfda5b8372a..70a5cf98b75 100644 --- a/gcc/common/config/aarch64/aarch64-common.cc +++ b/gcc/common/config/aarch64/aarch64-common.cc @@ -30,6 +30,7 @@ #include "opts.h" #include "flags.h" #include "diagnostic.h" +#include "config/arm/aarch-common.h" #ifdef TARGET_BIG_ENDIAN_DEFAULT #undef TARGET_DEFAULT_TARGET_FLAGS @@ -192,11 +193,11 @@ static const struct arch_to_arch_name all_architectures[] = /* Parse the architecture extension string STR and update ISA_FLAGS with the architecture features turned on or off. Return a - aarch64_parse_opt_result describing the result. + aarch_parse_opt_result describing the result. When the STR string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -enum aarch64_parse_opt_result +enum aarch_parse_opt_result aarch64_parse_extension (const char *str, uint64_t *isa_flags, std::string *invalid_extension) { @@ -229,7 +230,7 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, adding_ext = 1; if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Scan over the extensions table trying to find an exact match. */ @@ -251,13 +252,13 @@ aarch64_parse_extension (const char *str, uint64_t *isa_flags, /* Extension not found in list. */ if (invalid_extension) *invalid_extension = std::string (str, len); - return AARCH64_PARSE_INVALID_FEATURE; + return AARCH_PARSE_INVALID_FEATURE; } str = ext; }; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } /* Append all architecture extension candidates to the CANDIDATES vector. */ diff --git a/gcc/config/aarch64/aarch64-c.cc b/gcc/config/aarch64/aarch64-c.cc index caf8e332ea0..b0c5a4fd6b6 100644 --- a/gcc/config/aarch64/aarch64-c.cc +++ b/gcc/config/aarch64/aarch64-c.cc @@ -183,14 +183,14 @@ aarch64_update_cpp_builtins (cpp_reader *pfile) "__ARM_FEATURE_BTI_DEFAULT", pfile); cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) { int v = 0; - if (aarch64_ra_sign_key == AARCH64_KEY_A) + if (aarch_ra_sign_key == AARCH_KEY_A) v |= 1; - if (aarch64_ra_sign_key == AARCH64_KEY_B) + if (aarch_ra_sign_key == AARCH_KEY_B) v |= 2; - if (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL) + if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) v |= 4; builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", v); } diff --git a/gcc/config/aarch64/aarch64-opts.h b/gcc/config/aarch64/aarch64-opts.h index 93572fe8330..694d1738374 100644 --- a/gcc/config/aarch64/aarch64-opts.h +++ b/gcc/config/aarch64/aarch64-opts.h @@ -71,16 +71,6 @@ enum aarch64_code_model { AARCH64_CMODEL_LARGE }; -/* Function types -msign-return-address should sign. */ -enum aarch64_function_type { - /* Don't sign any function. */ - AARCH64_FUNCTION_NONE, - /* Non-leaf functions. */ - AARCH64_FUNCTION_NON_LEAF, - /* All functions. */ - AARCH64_FUNCTION_ALL -}; - /* SVE vector register sizes. */ enum aarch64_sve_vector_bits_enum { SVE_SCALABLE, diff --git a/gcc/config/aarch64/aarch64-protos.h b/gcc/config/aarch64/aarch64-protos.h index 46bade28ed6..fe2180e95ea 100644 --- a/gcc/config/aarch64/aarch64-protos.h +++ b/gcc/config/aarch64/aarch64-protos.h @@ -23,6 +23,7 @@ #define GCC_AARCH64_PROTOS_H #include "input.h" +#include "config/arm/aarch-common.h" /* SYMBOL_SMALL_ABSOLUTE: Generate symbol accesses through high and lo relocs that calculate the base address using a PC @@ -650,18 +651,6 @@ enum aarch64_extra_tuning_flags AARCH64_EXTRA_TUNE_ALL = (1u << AARCH64_EXTRA_TUNE_index_END) - 1 }; -/* Enum describing the various ways that the - aarch64_parse_{arch,tune,cpu,extension} functions can fail. - This way their callers can choose what kind of error to give. */ - -enum aarch64_parse_opt_result -{ - AARCH64_PARSE_OK, /* Parsing was successful. */ - AARCH64_PARSE_MISSING_ARG, /* Missing argument. */ - AARCH64_PARSE_INVALID_FEATURE, /* Invalid feature modifier. */ - AARCH64_PARSE_INVALID_ARG /* Invalid arch, tune, cpu arg. */ -}; - /* Enum to distinguish which type of check is to be done in aarch64_simd_valid_immediate. This is used as a bitmask where AARCH64_CHECK_MOV has both bits set. Thus AARCH64_CHECK_MOV will @@ -672,13 +661,7 @@ enum simd_immediate_check { AARCH64_CHECK_MOV = AARCH64_CHECK_ORR | AARCH64_CHECK_BIC }; -/* The key type that -msign-return-address should use. */ -enum aarch64_key_type { - AARCH64_KEY_A, - AARCH64_KEY_B -}; - -extern enum aarch64_key_type aarch64_ra_sign_key; +extern enum aarch_key_type aarch_ra_sign_key; extern struct tune_params aarch64_tune_params; @@ -1029,9 +1012,9 @@ extern bool aarch64_classify_address (struct aarch64_address_info *, rtx, bool aarch64_handle_option (struct gcc_options *, struct gcc_options *, const struct cl_decoded_option *, location_t); const char *aarch64_rewrite_selected_cpu (const char *name); -enum aarch64_parse_opt_result aarch64_parse_extension (const char *, - uint64_t *, - std::string *); +enum aarch_parse_opt_result aarch64_parse_extension (const char *, + uint64_t *, + std::string *); void aarch64_get_all_extension_candidates (auto_vec *candidates); std::string aarch64_get_extension_string_for_isa_flags (uint64_t, uint64_t); diff --git a/gcc/config/aarch64/aarch64.cc b/gcc/config/aarch64/aarch64.cc index 18f80499079..eec743024c1 100644 --- a/gcc/config/aarch64/aarch64.cc +++ b/gcc/config/aarch64/aarch64.cc @@ -81,6 +81,8 @@ #include "rtlanal.h" #include "tree-dfa.h" #include "asan.h" +#include "config/arm/aarch-common.h" +#include "config/arm/aarch-common-protos.h" /* This file should be included last. */ #include "target-def.h" @@ -321,12 +323,8 @@ bool aarch64_pcrelative_literal_loads; /* Global flag for whether frame pointer is enabled. */ bool aarch64_use_frame_pointer; -#define BRANCH_PROTECT_STR_MAX 255 char *accepted_branch_protection_string = NULL; -static enum aarch64_parse_opt_result -aarch64_parse_branch_protection (const char*, char**); - /* Support for command line parsing of boolean flags in the tuning structures. */ struct aarch64_flag_desc @@ -2711,7 +2709,7 @@ static const struct processor *selected_arch; static const struct processor *selected_cpu; static const struct processor *selected_tune; -enum aarch64_key_type aarch64_ra_sign_key = AARCH64_KEY_A; +enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A; /* The current tuning set. */ struct tune_params aarch64_tune_params = generic_tunings; @@ -2780,100 +2778,6 @@ aarch64_cc; #define AARCH64_INVERSE_CONDITION_CODE(X) ((aarch64_cc) (((int) X) ^ 1)) -struct aarch64_branch_protect_type -{ - /* The type's name that the user passes to the branch-protection option - string. */ - const char* name; - /* Function to handle the protection type and set global variables. - First argument is the string token corresponding with this type and the - second argument is the next token in the option string. - Return values: - * AARCH64_PARSE_OK: Handling was sucessful. - * AARCH64_INVALID_ARG: The type is invalid in this context and the caller - should print an error. - * AARCH64_INVALID_FEATURE: The type is invalid and the handler prints its - own error. */ - enum aarch64_parse_opt_result (*handler)(char*, char*); - /* A list of types that can follow this type in the option string. */ - const aarch64_branch_protect_type* subtypes; - unsigned int num_subtypes; -}; - -static enum aarch64_parse_opt_result -aarch64_handle_no_branch_protection (char* str, char* rest) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NONE; - aarch64_enable_bti = 0; - if (rest) - { - error ("unexpected %<%s%> after %<%s%>", rest, str); - return AARCH64_PARSE_INVALID_FEATURE; - } - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_standard_branch_protection (char* str, char* rest) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; - aarch64_ra_sign_key = AARCH64_KEY_A; - aarch64_enable_bti = 1; - if (rest) - { - error ("unexpected %<%s%> after %<%s%>", rest, str); - return AARCH64_PARSE_INVALID_FEATURE; - } - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_protection (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; - aarch64_ra_sign_key = AARCH64_KEY_A; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_leaf (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_scope = AARCH64_FUNCTION_ALL; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_pac_ret_b_key (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_ra_sign_key = AARCH64_KEY_B; - return AARCH64_PARSE_OK; -} - -static enum aarch64_parse_opt_result -aarch64_handle_bti_protection (char* str ATTRIBUTE_UNUSED, - char* rest ATTRIBUTE_UNUSED) -{ - aarch64_enable_bti = 1; - return AARCH64_PARSE_OK; -} - -static const struct aarch64_branch_protect_type aarch64_pac_ret_subtypes[] = { - { "leaf", aarch64_handle_pac_ret_leaf, NULL, 0 }, - { "b-key", aarch64_handle_pac_ret_b_key, NULL, 0 }, - { NULL, NULL, NULL, 0 } -}; - -static const struct aarch64_branch_protect_type aarch64_branch_protect_types[] = { - { "none", aarch64_handle_no_branch_protection, NULL, 0 }, - { "standard", aarch64_handle_standard_branch_protection, NULL, 0 }, - { "pac-ret", aarch64_handle_pac_ret_protection, aarch64_pac_ret_subtypes, - ARRAY_SIZE (aarch64_pac_ret_subtypes) }, - { "bti", aarch64_handle_bti_protection, NULL, 0 }, - { NULL, NULL, NULL, 0 } -}; /* The condition codes of the processor, and the inverse function. */ static const char * const aarch64_condition_codes[] = @@ -8621,10 +8525,10 @@ aarch64_return_address_signing_enabled (void) if (crtl->calls_eh_return) return false; - /* If signing scope is AARCH64_FUNCTION_NON_LEAF, we only sign a leaf function + /* If signing scope is AARCH_FUNCTION_NON_LEAF, we only sign a leaf function if its LR is pushed onto stack. */ - return (aarch64_ra_sign_scope == AARCH64_FUNCTION_ALL - || (aarch64_ra_sign_scope == AARCH64_FUNCTION_NON_LEAF + return (aarch_ra_sign_scope == AARCH_FUNCTION_ALL + || (aarch_ra_sign_scope == AARCH_FUNCTION_NON_LEAF && known_ge (cfun->machine->frame.reg_offset[LR_REGNUM], 0))); } @@ -8632,7 +8536,7 @@ aarch64_return_address_signing_enabled (void) bool aarch64_bti_enabled (void) { - return (aarch64_enable_bti == 1); + return (aarch_enable_bti == 1); } /* The caller is going to use ST1D or LD1D to save or restore an SVE @@ -9624,12 +9528,12 @@ aarch64_expand_prologue (void) /* Sign return address for functions. */ if (aarch64_return_address_signing_enabled ()) { - switch (aarch64_ra_sign_key) + switch (aarch_ra_sign_key) { - case AARCH64_KEY_A: + case AARCH_KEY_A: insn = emit_insn (gen_paciasp ()); break; - case AARCH64_KEY_B: + case AARCH_KEY_B: insn = emit_insn (gen_pacibsp ()); break; default: @@ -9930,12 +9834,12 @@ aarch64_expand_epilogue (bool for_sibcall) if (aarch64_return_address_signing_enabled () && (for_sibcall || !TARGET_ARMV8_3)) { - switch (aarch64_ra_sign_key) + switch (aarch_ra_sign_key) { - case AARCH64_KEY_A: + case AARCH_KEY_A: insn = emit_insn (gen_autiasp ()); break; - case AARCH64_KEY_B: + case AARCH_KEY_B: insn = emit_insn (gen_autibsp ()); break; default: @@ -17077,12 +16981,12 @@ static void initialize_aarch64_code_model (struct gcc_options *); /* Parse the TO_PARSE string and put the architecture struct that it selects into RES and the architectural features into ISA_FLAGS. - Return an aarch64_parse_opt_result describing the parse result. + Return an aarch_parse_opt_result describing the parse result. If there is an error parsing, RES and ISA_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_arch (const char *to_parse, const struct processor **res, uint64_t *isa_flags, std::string *invalid_extension) { @@ -17098,7 +17002,7 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, len = strlen (to_parse); if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Loop through the list of supported ARCHes to find a match. */ @@ -17112,32 +17016,32 @@ aarch64_parse_arch (const char *to_parse, const struct processor **res, if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ - enum aarch64_parse_opt_result ext_res + enum aarch_parse_opt_result ext_res = aarch64_parse_extension (ext, &isa_temp, invalid_extension); - if (ext_res != AARCH64_PARSE_OK) + if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successful. Confirm the result arch and ISA flags. */ *res = arch; *isa_flags = isa_temp; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* ARCH name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse the TO_PARSE string and put the result tuning in RES and the - architecture flags in ISA_FLAGS. Return an aarch64_parse_opt_result + architecture flags in ISA_FLAGS. Return an aarch_parse_opt_result describing the parse result. If there is an error parsing, RES and ISA_FLAGS are left unchanged. When the TO_PARSE string contains an invalid extension, a copy of the string is created and stored to INVALID_EXTENSION. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_cpu (const char *to_parse, const struct processor **res, uint64_t *isa_flags, std::string *invalid_extension) { @@ -17153,7 +17057,7 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, len = strlen (to_parse); if (len == 0) - return AARCH64_PARSE_MISSING_ARG; + return AARCH_PARSE_MISSING_ARG; /* Loop through the list of supported CPUs to find a match. */ @@ -17167,29 +17071,29 @@ aarch64_parse_cpu (const char *to_parse, const struct processor **res, if (ext != NULL) { /* TO_PARSE string contains at least one extension. */ - enum aarch64_parse_opt_result ext_res + enum aarch_parse_opt_result ext_res = aarch64_parse_extension (ext, &isa_temp, invalid_extension); - if (ext_res != AARCH64_PARSE_OK) + if (ext_res != AARCH_PARSE_OK) return ext_res; } /* Extension parsing was successfull. Confirm the result cpu and ISA flags. */ *res = cpu; *isa_flags = isa_temp; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* CPU name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse the TO_PARSE string and put the cpu it selects into RES. - Return an aarch64_parse_opt_result describing the parse result. + Return an aarch_parse_opt_result describing the parse result. If the parsing fails the RES does not change. */ -static enum aarch64_parse_opt_result +static enum aarch_parse_opt_result aarch64_parse_tune (const char *to_parse, const struct processor **res) { const struct processor *cpu; @@ -17200,12 +17104,12 @@ aarch64_parse_tune (const char *to_parse, const struct processor **res) if (strcmp (cpu->name, to_parse) == 0) { *res = cpu; - return AARCH64_PARSE_OK; + return AARCH_PARSE_OK; } } /* CPU name not found in list. */ - return AARCH64_PARSE_INVALID_ARG; + return AARCH_PARSE_INVALID_ARG; } /* Parse TOKEN, which has length LENGTH to see if it is an option @@ -17783,22 +17687,22 @@ aarch64_validate_mcpu (const char *str, const struct processor **res, uint64_t *isa_flags) { std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_cpu (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing cpu name in %<-mcpu=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-mcpu%>", str); aarch64_print_hint_for_core (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-mcpu=%s%>", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -17883,110 +17787,6 @@ aarch64_validate_sls_mitigation (const char *const_str) free (str_root); } -/* Parses CONST_STR for branch protection features specified in - aarch64_branch_protect_types, and set any global variables required. Returns - the parsing result and assigns LAST_STR to the last processed token from - CONST_STR so that it can be used for error reporting. */ - -static enum -aarch64_parse_opt_result aarch64_parse_branch_protection (const char *const_str, - char** last_str) -{ - char *str_root = xstrdup (const_str); - char* token_save = NULL; - char *str = strtok_r (str_root, "+", &token_save); - enum aarch64_parse_opt_result res = AARCH64_PARSE_OK; - if (!str) - res = AARCH64_PARSE_MISSING_ARG; - else - { - char *next_str = strtok_r (NULL, "+", &token_save); - /* Reset the branch protection features to their defaults. */ - aarch64_handle_no_branch_protection (NULL, NULL); - - while (str && res == AARCH64_PARSE_OK) - { - const aarch64_branch_protect_type* type = aarch64_branch_protect_types; - bool found = false; - /* Search for this type. */ - while (type && type->name && !found && res == AARCH64_PARSE_OK) - { - if (strcmp (str, type->name) == 0) - { - found = true; - res = type->handler (str, next_str); - str = next_str; - next_str = strtok_r (NULL, "+", &token_save); - } - else - type++; - } - if (found && res == AARCH64_PARSE_OK) - { - bool found_subtype = true; - /* Loop through each token until we find one that isn't a - subtype. */ - while (found_subtype) - { - found_subtype = false; - const aarch64_branch_protect_type *subtype = type->subtypes; - /* Search for the subtype. */ - while (str && subtype && subtype->name && !found_subtype - && res == AARCH64_PARSE_OK) - { - if (strcmp (str, subtype->name) == 0) - { - found_subtype = true; - res = subtype->handler (str, next_str); - str = next_str; - next_str = strtok_r (NULL, "+", &token_save); - } - else - subtype++; - } - } - } - else if (!found) - res = AARCH64_PARSE_INVALID_ARG; - } - } - /* Copy the last processed token into the argument to pass it back. - Used by option and attribute validation to print the offending token. */ - if (last_str) - { - if (str) strcpy (*last_str, str); - else *last_str = NULL; - } - if (res == AARCH64_PARSE_OK) - { - /* If needed, alloc the accepted string then copy in const_str. - Used by override_option_after_change_1. */ - if (!accepted_branch_protection_string) - accepted_branch_protection_string = (char *) xmalloc ( - BRANCH_PROTECT_STR_MAX - + 1); - strncpy (accepted_branch_protection_string, const_str, - BRANCH_PROTECT_STR_MAX + 1); - /* Forcibly null-terminate. */ - accepted_branch_protection_string[BRANCH_PROTECT_STR_MAX] = '\0'; - } - return res; -} - -static bool -aarch64_validate_mbranch_protection (const char *const_str) -{ - char *str = (char *) xmalloc (strlen (const_str)); - enum aarch64_parse_opt_result res = - aarch64_parse_branch_protection (const_str, &str); - if (res == AARCH64_PARSE_INVALID_ARG) - error ("invalid argument %<%s%> for %<-mbranch-protection=%>", str); - else if (res == AARCH64_PARSE_MISSING_ARG) - error ("missing argument for %<-mbranch-protection=%>"); - free (str); - return res == AARCH64_PARSE_OK; -} - /* Validate a command-line -march option. Parse the arch and extensions (if any) specified in STR and throw errors if appropriate. Put the results, if they are valid, in RES and ISA_FLAGS. Return whether the @@ -17997,22 +17797,22 @@ aarch64_validate_march (const char *str, const struct processor **res, uint64_t *isa_flags) { std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_arch (str, res, isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing arch name in %<-march=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-march%>", str); aarch64_print_hint_for_arch (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs in %<-march=%s%>", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -18032,18 +17832,18 @@ aarch64_validate_march (const char *str, const struct processor **res, static bool aarch64_validate_mtune (const char *str, const struct processor **res) { - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_tune (str, res); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) return true; switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing cpu name in %<-mtune=%s%>", str); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("unknown value %qs for %<-mtune%>", str); aarch64_print_hint_for_core (str); break; @@ -18131,7 +17931,7 @@ aarch64_override_options (void) aarch64_validate_sls_mitigation (aarch64_harden_sls_string); if (aarch64_branch_protection_string) - aarch64_validate_mbranch_protection (aarch64_branch_protection_string); + aarch_validate_mbranch_protection (aarch64_branch_protection_string); /* -mcpu=CPU is shorthand for -march=ARCH_FOR_CPU, -mtune=CPU. If either of -march or -mtune is given, they override their @@ -18209,12 +18009,12 @@ aarch64_override_options (void) if (!selected_tune) selected_tune = selected_cpu; - if (aarch64_enable_bti == 2) + if (aarch_enable_bti == 2) { #ifdef TARGET_ENABLE_BTI - aarch64_enable_bti = 1; + aarch_enable_bti = 1; #else - aarch64_enable_bti = 0; + aarch_enable_bti = 0; #endif } @@ -18224,9 +18024,9 @@ aarch64_override_options (void) if (!TARGET_ILP32 && accepted_branch_protection_string == NULL) { #ifdef TARGET_ENABLE_PAC_RET - aarch64_ra_sign_scope = AARCH64_FUNCTION_NON_LEAF; + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; #else - aarch64_ra_sign_scope = AARCH64_FUNCTION_NONE; + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; #endif } @@ -18240,7 +18040,7 @@ aarch64_override_options (void) /* Convert -msve-vector-bits to a VG count. */ aarch64_sve_vg = aarch64_convert_sve_vector_bits (aarch64_sve_vector_bits); - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE && TARGET_ILP32) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE && TARGET_ILP32) sorry ("return address signing is only supported for %<-mabi=lp64%>"); /* Make sure we properly set up the explicit options. */ @@ -18367,7 +18167,7 @@ aarch64_option_restore (struct gcc_options *opts, = ptr->x_aarch64_branch_protection_string; if (opts->x_aarch64_branch_protection_string) { - aarch64_parse_branch_protection (opts->x_aarch64_branch_protection_string, + aarch_parse_branch_protection (opts->x_aarch64_branch_protection_string, NULL); } @@ -18491,10 +18291,10 @@ aarch64_handle_attr_arch (const char *str) { const struct processor *tmp_arch = NULL; std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_arch (str, &tmp_arch, &aarch64_isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_arch); selected_arch = tmp_arch; @@ -18504,14 +18304,14 @@ aarch64_handle_attr_arch (const char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing name in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name %qs in % pragma or attribute", str); aarch64_print_hint_for_arch (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %s of value %qs in " "% pragma or attribute", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -18530,10 +18330,10 @@ aarch64_handle_attr_cpu (const char *str) { const struct processor *tmp_cpu = NULL; std::string invalid_extension; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_cpu (str, &tmp_cpu, &aarch64_isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_cpu); selected_tune = tmp_cpu; @@ -18546,14 +18346,14 @@ aarch64_handle_attr_cpu (const char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing name in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name %qs in % pragma or attribute", str); aarch64_print_hint_for_core (str); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs of value %qs in " "% pragma or attribute", invalid_extension.c_str (), str); aarch64_print_hint_for_extensions (invalid_extension); @@ -18571,23 +18371,23 @@ aarch64_handle_attr_cpu (const char *str) aarch64_handle_attr_branch_protection (const char* str) { char *err_str = (char *) xmalloc (strlen (str) + 1); - enum aarch64_parse_opt_result res = aarch64_parse_branch_protection (str, - &err_str); + enum aarch_parse_opt_result res = aarch_parse_branch_protection (str, + &err_str); bool success = false; switch (res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing argument to % pragma or" " attribute"); break; - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid protection type %qs in % pragma or attribute", err_str); break; - case AARCH64_PARSE_OK: + case AARCH_PARSE_OK: success = true; /* Fall through. */ - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: break; default: gcc_unreachable (); @@ -18602,10 +18402,10 @@ static bool aarch64_handle_attr_tune (const char *str) { const struct processor *tmp_tune = NULL; - enum aarch64_parse_opt_result parse_res + enum aarch_parse_opt_result parse_res = aarch64_parse_tune (str, &tmp_tune); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { gcc_assert (tmp_tune); selected_tune = tmp_tune; @@ -18615,7 +18415,7 @@ aarch64_handle_attr_tune (const char *str) switch (parse_res) { - case AARCH64_PARSE_INVALID_ARG: + case AARCH_PARSE_INVALID_ARG: error ("invalid name %qs in % pragma or attribute", str); aarch64_print_hint_for_core (str); break; @@ -18634,7 +18434,7 @@ aarch64_handle_attr_tune (const char *str) static bool aarch64_handle_attr_isa_flags (char *str) { - enum aarch64_parse_opt_result parse_res; + enum aarch_parse_opt_result parse_res; uint64_t isa_flags = aarch64_isa_flags; /* We allow "+nothing" in the beginning to clear out all architectural @@ -18648,7 +18448,7 @@ aarch64_handle_attr_isa_flags (char *str) std::string invalid_extension; parse_res = aarch64_parse_extension (str, &isa_flags, &invalid_extension); - if (parse_res == AARCH64_PARSE_OK) + if (parse_res == AARCH_PARSE_OK) { aarch64_isa_flags = isa_flags; return true; @@ -18656,11 +18456,11 @@ aarch64_handle_attr_isa_flags (char *str) switch (parse_res) { - case AARCH64_PARSE_MISSING_ARG: + case AARCH_PARSE_MISSING_ARG: error ("missing value in % pragma or attribute"); break; - case AARCH64_PARSE_INVALID_FEATURE: + case AARCH_PARSE_INVALID_FEATURE: error ("invalid feature modifier %qs of value %qs in " "% pragma or attribute", invalid_extension.c_str (), str); break; @@ -18909,10 +18709,10 @@ aarch64_process_target_attr (tree args) leading '+'. */ uint64_t isa_temp = 0; auto with_plus = std::string ("+") + token; - enum aarch64_parse_opt_result ext_res + enum aarch_parse_opt_result ext_res = aarch64_parse_extension (with_plus.c_str (), &isa_temp, nullptr); - if (ext_res == AARCH64_PARSE_OK) + if (ext_res == AARCH_PARSE_OK) error ("arch extension %<%s%> should be prefixed by %<+%>", token); else @@ -22606,7 +22406,7 @@ void aarch64_post_cfi_startproc (FILE *f, tree ignored ATTRIBUTE_UNUSED) { if (cfun->machine->frame.laid_out && aarch64_return_address_signing_enabled () - && aarch64_ra_sign_key == AARCH64_KEY_B) + && aarch_ra_sign_key == AARCH_KEY_B) asm_fprintf (f, "\t.cfi_b_key_frame\n"); } @@ -26892,7 +26692,7 @@ aarch64_file_end_indicate_exec_stack () if (aarch64_bti_enabled ()) feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_BTI; - if (aarch64_ra_sign_scope != AARCH64_FUNCTION_NONE) + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) feature_1_and |= GNU_PROPERTY_AARCH64_FEATURE_1_PAC; if (feature_1_and) diff --git a/gcc/config/aarch64/aarch64.md b/gcc/config/aarch64/aarch64.md index c98525075a0..072264b89d8 100644 --- a/gcc/config/aarch64/aarch64.md +++ b/gcc/config/aarch64/aarch64.md @@ -890,7 +890,7 @@ if (aarch64_return_address_signing_enabled () && (TARGET_PAUTH)) { - if (aarch64_ra_sign_key == AARCH64_KEY_B) + if (aarch_ra_sign_key == AARCH_KEY_B) ret = "retab"; else ret = "retaa"; diff --git a/gcc/config/aarch64/aarch64.opt b/gcc/config/aarch64/aarch64.opt index 92220b26ee2..61937fb92cf 100644 --- a/gcc/config/aarch64/aarch64.opt +++ b/gcc/config/aarch64/aarch64.opt @@ -21,6 +21,9 @@ HeaderInclude config/aarch64/aarch64-opts.h +HeaderInclude +config/arm/aarch-common.h + TargetVariable enum aarch64_processor explicit_tune_core = aarch64_none @@ -34,7 +37,7 @@ TargetVariable uint64_t aarch64_isa_flags = 0 TargetVariable -unsigned aarch64_enable_bti = 2 +unsigned aarch_enable_bti = 2 ; The TLS dialect names to use with -mtls-dialect. @@ -161,21 +164,21 @@ Target RejectNegative Joined Var(aarch64_branch_protection_string) Save Use branch-protection features. msign-return-address= -Target WarnRemoved RejectNegative Joined Enum(aarch64_ra_sign_scope_t) Var(aarch64_ra_sign_scope) Init(AARCH64_FUNCTION_NONE) Save +Target WarnRemoved RejectNegative Joined Enum(aarch_ra_sign_scope_t) Var(aarch_ra_sign_scope) Init(AARCH_FUNCTION_NONE) Save Select return address signing scope. Enum -Name(aarch64_ra_sign_scope_t) Type(enum aarch64_function_type) +Name(aarch_ra_sign_scope_t) Type(enum aarch_function_type) Supported AArch64 return address signing scope (for use with -msign-return-address= option): EnumValue -Enum(aarch64_ra_sign_scope_t) String(none) Value(AARCH64_FUNCTION_NONE) +Enum(aarch_ra_sign_scope_t) String(none) Value(AARCH_FUNCTION_NONE) EnumValue -Enum(aarch64_ra_sign_scope_t) String(non-leaf) Value(AARCH64_FUNCTION_NON_LEAF) +Enum(aarch_ra_sign_scope_t) String(non-leaf) Value(AARCH_FUNCTION_NON_LEAF) EnumValue -Enum(aarch64_ra_sign_scope_t) String(all) Value(AARCH64_FUNCTION_ALL) +Enum(aarch_ra_sign_scope_t) String(all) Value(AARCH_FUNCTION_ALL) mlow-precision-recip-sqrt Target Var(flag_mrecip_low_precision_sqrt) Optimization diff --git a/gcc/config/arm/aarch-common-protos.h b/gcc/config/arm/aarch-common-protos.h index ae0465159f7..17a369f7e99 100644 --- a/gcc/config/arm/aarch-common-protos.h +++ b/gcc/config/arm/aarch-common-protos.h @@ -153,4 +153,10 @@ rtx_insn *arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, vec &clobbers, HARD_REG_SET &clobbered_regs, location_t loc); +/* Parsing routine for branch-protection common to AArch64 and Arm. */ +enum aarch_parse_opt_result aarch_parse_branch_protection (const char*, char**); + +/* Validation routine for branch-protection common to AArch64 and Arm. */ +bool aarch_validate_mbranch_protection (const char *); + #endif /* GCC_AARCH_COMMON_PROTOS_H */ diff --git a/gcc/config/arm/aarch-common.cc b/gcc/config/arm/aarch-common.cc index 04a53d75093..6d254101f6a 100644 --- a/gcc/config/arm/aarch-common.cc +++ b/gcc/config/arm/aarch-common.cc @@ -36,6 +36,7 @@ #include "expr.h" #include "function.h" #include "emit-rtl.h" +#include "aarch-common.h" /* Return TRUE if X is either an arithmetic shift left, or is a multiplication by a power of two. */ @@ -657,3 +658,187 @@ arm_md_asm_adjust (vec &outputs, vec & /*inputs*/, return saw_asm_flag ? seq : NULL; } + +#define BRANCH_PROTECT_STR_MAX 255 +extern char *accepted_branch_protection_string; +extern enum aarch_key_type aarch_ra_sign_key; + +static enum aarch_parse_opt_result +aarch_handle_no_branch_protection (char* str, char* rest) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NONE; + aarch_enable_bti = 0; + if (rest) + { + error ("unexpected %<%s%> after %<%s%>", rest, str); + return AARCH_PARSE_INVALID_FEATURE; + } + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_standard_branch_protection (char* str, char* rest) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; + aarch_enable_bti = 1; + if (rest) + { + error ("unexpected %<%s%> after %<%s%>", rest, str); + return AARCH_PARSE_INVALID_FEATURE; + } + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_protection (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_NON_LEAF; + aarch_ra_sign_key = AARCH_KEY_A; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_leaf (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_scope = AARCH_FUNCTION_ALL; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_pac_ret_b_key (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_ra_sign_key = AARCH_KEY_B; + return AARCH_PARSE_OK; +} + +static enum aarch_parse_opt_result +aarch_handle_bti_protection (char* str ATTRIBUTE_UNUSED, + char* rest ATTRIBUTE_UNUSED) +{ + aarch_enable_bti = 1; + return AARCH_PARSE_OK; +} + +static const struct aarch_branch_protect_type aarch_pac_ret_subtypes[] = { + { "leaf", aarch_handle_pac_ret_leaf, NULL, 0 }, + { "b-key", aarch_handle_pac_ret_b_key, NULL, 0 }, + { NULL, NULL, NULL, 0 } +}; + +static const struct aarch_branch_protect_type aarch_branch_protect_types[] = { + { "none", aarch_handle_no_branch_protection, NULL, 0 }, + { "standard", aarch_handle_standard_branch_protection, NULL, 0 }, + { "pac-ret", aarch_handle_pac_ret_protection, aarch_pac_ret_subtypes, + ARRAY_SIZE (aarch_pac_ret_subtypes) }, + { "bti", aarch_handle_bti_protection, NULL, 0 }, + { NULL, NULL, NULL, 0 } +}; + +/* Parses CONST_STR for branch protection features specified in + aarch64_branch_protect_types, and set any global variables required. Returns + the parsing result and assigns LAST_STR to the last processed token from + CONST_STR so that it can be used for error reporting. */ + +enum aarch_parse_opt_result +aarch_parse_branch_protection (const char *const_str, char** last_str) +{ + char *str_root = xstrdup (const_str); + char* token_save = NULL; + char *str = strtok_r (str_root, "+", &token_save); + enum aarch_parse_opt_result res = AARCH_PARSE_OK; + if (!str) + res = AARCH_PARSE_MISSING_ARG; + else + { + char *next_str = strtok_r (NULL, "+", &token_save); + /* Reset the branch protection features to their defaults. */ + aarch_handle_no_branch_protection (NULL, NULL); + + while (str && res == AARCH_PARSE_OK) + { + const aarch_branch_protect_type* type = aarch_branch_protect_types; + bool found = false; + /* Search for this type. */ + while (type && type->name && !found && res == AARCH_PARSE_OK) + { + if (strcmp (str, type->name) == 0) + { + found = true; + res = type->handler (str, next_str); + str = next_str; + next_str = strtok_r (NULL, "+", &token_save); + } + else + type++; + } + if (found && res == AARCH_PARSE_OK) + { + bool found_subtype = true; + /* Loop through each token until we find one that isn't a + subtype. */ + while (found_subtype) + { + found_subtype = false; + const aarch_branch_protect_type *subtype = type->subtypes; + /* Search for the subtype. */ + while (str && subtype && subtype->name && !found_subtype + && res == AARCH_PARSE_OK) + { + if (strcmp (str, subtype->name) == 0) + { + found_subtype = true; + res = subtype->handler (str, next_str); + str = next_str; + next_str = strtok_r (NULL, "+", &token_save); + } + else + subtype++; + } + } + } + else if (!found) + res = AARCH_PARSE_INVALID_ARG; + } + } + /* Copy the last processed token into the argument to pass it back. + Used by option and attribute validation to print the offending token. */ + if (last_str) + { + if (str) + strcpy (*last_str, str); + else + *last_str = NULL; + } + + if (res == AARCH_PARSE_OK) + { + /* If needed, alloc the accepted string then copy in const_str. + Used by override_option_after_change_1. */ + if (!accepted_branch_protection_string) + accepted_branch_protection_string + = (char *) xmalloc (BRANCH_PROTECT_STR_MAX + 1); + strncpy (accepted_branch_protection_string, const_str, + BRANCH_PROTECT_STR_MAX + 1); + /* Forcibly null-terminate. */ + accepted_branch_protection_string[BRANCH_PROTECT_STR_MAX] = '\0'; + } + return res; +} + +bool +aarch_validate_mbranch_protection (const char *const_str) +{ + char *str = (char *) xmalloc (strlen (const_str)); + enum aarch_parse_opt_result res = + aarch_parse_branch_protection (const_str, &str); + if (res == AARCH_PARSE_INVALID_ARG) + error ("invalid argument %<%s%> for %<-mbranch-protection=%>", str); + else if (res == AARCH_PARSE_MISSING_ARG) + error ("missing argument for %<-mbranch-protection=%>"); + free (str); + return res == AARCH_PARSE_OK; +} diff --git a/gcc/config/arm/aarch-common.h b/gcc/config/arm/aarch-common.h new file mode 100644 index 00000000000..b5591d60c5a --- /dev/null +++ b/gcc/config/arm/aarch-common.h @@ -0,0 +1,73 @@ +/* Types shared between arm and aarch64. + + Copyright (C) 2009-2021 Free Software Foundation, Inc. + Contributed by Arm Ltd. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published + by the Free Software Foundation; either version 3, or (at your + option) any later version. + + GCC is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +#ifndef GCC_AARCH_COMMON_H +#define GCC_AARCH_COMMON_H + +/* Enum describing the various ways that the + aarch*_parse_{arch,tune,cpu,extension} functions can fail. + This way their callers can choose what kind of error to give. */ + +enum aarch_parse_opt_result +{ + AARCH_PARSE_OK, /* Parsing was successful. */ + AARCH_PARSE_MISSING_ARG, /* Missing argument. */ + AARCH_PARSE_INVALID_FEATURE, /* Invalid feature modifier. */ + AARCH_PARSE_INVALID_ARG /* Invalid arch, tune, cpu arg. */ +}; + +/* Function types -msign-return-address should sign. */ +enum aarch_function_type { + /* Don't sign any function. */ + AARCH_FUNCTION_NONE, + /* Non-leaf functions. */ + AARCH_FUNCTION_NON_LEAF, + /* All functions. */ + AARCH_FUNCTION_ALL +}; + +/* The key type that -msign-return-address should use. */ +enum aarch_key_type { + AARCH_KEY_A, + AARCH_KEY_B +}; + +struct aarch_branch_protect_type +{ + /* The type's name that the user passes to the branch-protection option + string. */ + const char* name; + /* Function to handle the protection type and set global variables. + First argument is the string token corresponding with this type and the + second argument is the next token in the option string. + Return values: + * AARCH_PARSE_OK: Handling was sucessful. + * AARCH_INVALID_ARG: The type is invalid in this context and the caller + should print an error. + * AARCH_INVALID_FEATURE: The type is invalid and the handler prints its + own error. */ + enum aarch_parse_opt_result (*handler)(char*, char*); + /* A list of types that can follow this type in the option string. */ + const struct aarch_branch_protect_type* subtypes; + unsigned int num_subtypes; +}; + +#endif /* GCC_AARCH_COMMON_H */ diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 9d142096cb6..cff7ff1da2a 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -586,6 +586,8 @@ struct cpu_option extern const arch_option all_architectures[]; extern const cpu_option all_cores[]; +extern enum aarch_key_type aarch_ra_sign_key; + const cpu_option *arm_parse_cpu_option_name (const cpu_option *, const char *, const char *, bool = true); const arch_option *arm_parse_arch_option_name (const arch_option *, diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 14e2fdfeafa..60f3eae82a4 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -72,6 +72,8 @@ #include "selftest.h" #include "tree-vectorizer.h" #include "opts.h" +#include "aarch-common.h" +#include "aarch-common-protos.h" /* This file should be included last. */ #include "target-def.h" @@ -2417,6 +2419,11 @@ const struct tune_params arm_fa726te_tune = tune_params::SCHED_AUTOPREF_OFF }; +/* Key type for Pointer Authentication extension. */ +enum aarch_key_type aarch_ra_sign_key = AARCH_KEY_A; + +char *accepted_branch_protection_string = NULL; + /* Auto-generated CPU, FPU and architecture tables. */ #include "arm-cpu-data.h" diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index 3209b6c623b..f54ec8356c3 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -21,6 +21,15 @@ HeaderInclude config/arm/arm-opts.h +HeaderInclude +config/arm/aarch-common.h + +TargetVariable +enum aarch_function_type aarch_ra_sign_scope = AARCH_FUNCTION_NONE + +TargetVariable +unsigned aarch_enable_bti = 2 + Enum Name(tls_type) Type(enum arm_tls_type) TLS dialect to use: From patchwork Fri Aug 12 15:15: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: 498 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp937521pxh; Fri, 12 Aug 2022 08:16:25 -0700 (PDT) X-Google-Smtp-Source: AA6agR6BmKaISd+MKpOBYIo9D9Nlk/h94piOgZMArB5ATJtd+qgU0x8xX0D87AsKfbcGHQ/6OdZ0 X-Received: by 2002:a05:6402:241e:b0:443:be9:83c0 with SMTP id t30-20020a056402241e00b004430be983c0mr4074317eda.24.1660317384809; Fri, 12 Aug 2022 08:16:24 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d4-20020a170906c20400b007315c334c0fsi1819362ejz.182.2022.08.12.08.16.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:16:24 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OvUig0iD; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 569FE385840F for ; Fri, 12 Aug 2022 15:16:23 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 569FE385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660317383; bh=oern6JZzTuBJuFHRNmvWuttHDLJYPWNXpefGUtMugIo=; 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=OvUig0iDheyhuLERsVJVwnDi4XDmup8ySaZZyZPCKUe2PAJhv282kRRyPCKmGoNlV R91sCrm7ni1itmKj7Ak80VlgUPTCyKuXhO86WC4HSnj48B/KGJXNPCk1MYVSUPITbV oGB4mmPf0VhDI9S45MEScla+0dZjcRI/YFLvhTNI= 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-eopbgr80047.outbound.protection.outlook.com [40.107.8.47]) by sourceware.org (Postfix) with ESMTPS id 2E2523858427 for ; Fri, 12 Aug 2022 15:15:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 2E2523858427 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=GgVSokFktk/gW6yMqPUN7NmrUos7zRjhYClq7bDkiFS/szkAq6MUZmFubW03R9XMpWaYwZVL33uSlBYJdQHwozuoWeboB52XKT9owwwUp4+FTaMglenNrn//AhLb/bPc6wffDc9uOcyaHxTUqaK6IQqZY2CaQ1IUhb5eVzpYtIfg9VjT80GnYXzgXgrP4VNW/V9s/ras9P8HrACvw/HZAJpeytfdwXPW2/qfO0s13xFXUQEDHBjgQGs23DQoKzAlyO71SO2ISsYtINSswWx/Rt0JYTQ1F28SVFESsinMDbZlT2GosDPf3OA6pm+BpEcUlmCbhEDaMGolZUxvzDnZ8A== 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=oern6JZzTuBJuFHRNmvWuttHDLJYPWNXpefGUtMugIo=; b=iBl3I7p3fSiJdq8hRhNsHUwZTnyh5sh+ceo0rKzt8MQpt+/l6Tor+CrF6t788kc1VIQ9ZhF6ljaLxQq/Fl4TT1PdDZgBZ1mR4jTGm1ZUf/KNNAL0kJAzB1INTGJmU1ryfc8ahyBDydwXCJpDn50ozBffD5ksF1082ZukfG36ZWVek65oHf/sUs/GWqq/Z3HxSqUEdV8hiFMFpekvmgXwNZK2jmUNSliGrBVram8I+Qr4YJKECuqccA9qnXsoaZNHNsd2/nt08j/p5CRIvjL65k7EJ4bgmzrTfE3Er/V9MNwMSb6iYEzKKpi4VKJvpY7F4jbKm6bwOZjZxsTIIZ2rgw== 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 FR3P281CA0162.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a2::14) by VE1PR08MB5262.eurprd08.prod.outlook.com (2603:10a6:803:106::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 12 Aug 2022 15:15:35 +0000 Received: from VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a2:cafe::21) by FR3P281CA0162.outlook.office365.com (2603:10a6:d10:a2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.8 via Frontend Transport; Fri, 12 Aug 2022 15:15:35 +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 VE1EUR03FT051.mail.protection.outlook.com (10.152.19.75) 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:15:34 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:15:34 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 250e29847aef1dee X-CR-MTA-TID: 64aa7808 Received: from 458d1337e22a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id D4FD5D14-94C1-4796-A0A9-8FFE2EF205E6.1; Fri, 12 Aug 2022 15:15:27 +0000 Received: from EUR05-AM6-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 458d1337e22a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:15:27 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mvVw8h5jOS4g2TDwJkGa+Y9MIZi1abz3TEjfs3//Ucme7Jc8zLoi0KrGLAhp0mtXuCM5RETe8fSZINjVHWs5E/J9KL7cDxPmVtfg6J92HINerf4Rj4yjTlV0c65hyoiwnRtQhehdh+LZ1iDJcQA1PkOYMX1Vwm9sjXx2y8x81Xm7JEA+JUajVMMiDKuRDr0ckj9ivP5E/oDEevaoGLZcn3Zesj3IhUG7f4sHwi7aiIk7UjnKoD41pvCcTbTHQ3+Xk9lEGn/RZPUvPZNBv8PZ5ytU0Nv4K2pMTpkLknrFrB9TuaidnmEiIZt2yseYWvqN6paSeuRGhY2Cr7kmUVbbPA== 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=oern6JZzTuBJuFHRNmvWuttHDLJYPWNXpefGUtMugIo=; b=YTmulri4QUAQ0KmhGHO/NYhe0v7Pk0y6dZhkif8o9yjYZRTSZW1DgB7Qgn9+HXIGZe+Sp5eOXpFx/U+2vwVMwlz+Lz8wU43pezYGfS41fYPtFp4/dLWxJ1k/WNd78oSkWCLy1FzCrC6OoRZQ+q4X+SF1gQNOQHAEQ0u0n10ZG3kEztBzzeYwUtzHt/hvF1IYwWAPMF8b1oaGXfNVu6fws/rqpKt0XlnHj6XVOjDr4ZU0gDIttbR1h6gs3/MAtYx8EYMX45vzJlSP9qM4MXHVWPOZB97GTadyac8/SBFq2S7oQ5saNlpy7iU+AmN//n0w/7VDTBLvXVLHXSfXOzi9PA== 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 FR3P281CA0016.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1d::21) by AM0PR08MB4049.eurprd08.prod.outlook.com (2603:10a6:208:12c::33) 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:15:25 +0000 Received: from VE1EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1d:cafe::1) by FR3P281CA0016.outlook.office365.com (2603:10a6:d10:1d::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.10 via Frontend Transport; Fri, 12 Aug 2022 15:15:25 +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 VE1EUR03FT050.mail.protection.outlook.com (10.152.19.209) 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:15:25 +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:15: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:15: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:15:18 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 2/15] arm: Add Armv8.1-M Mainline target feature +pacbti References: Date: Fri, 12 Aug 2022 17:15: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: 242d5d4d-f11d-419e-86f4-08da7c758149 X-MS-TrafficTypeDiagnostic: AM0PR08MB4049:EE_|VE1EUR03FT051:EE_|VE1PR08MB5262: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: wIyUgjJchbStH6dCqZ86uUTSeg6+3Vp1Z5M/6hQuimfmwI7LJZz09WBPcsovw0IRNoGj3WW458XDbNV/l4fTRg/cev+U6AA/xGMsZ4X6hbU2Vc2bRT72iHCk5Uv9pq2SM6UtmuoislT3iyhSRprpl1MZJ5Xu8w9g1jjils9HXa3/q3Q8bjghMr5i/kkD/PJl8dYXjFit7MLTWz0tvxL0vMBduMw62AQQlIAGTSt0v6jVocg4Wlrc6eGwBgvHXY+ZnfZQqe/StLdPSpPN19RJv8ZsV779R8MMvBVYCdXJaXjlPCLATkdIJhjXdYL3Z1johZkpsZ+HE05zQm53dZYKxG5P4eVXPkX6ITv8qQD2blPJKapkjWiarTJZspmKySE4I9Qjg1XrnB4UZDTitb3HJE96OwqDOWZ3XN2N7x1V288gvyF1MCMbn+/7AF3QQY/HBZPq503HZMfrzPFxeApHENZ5To364p31FnIga/TW2xneT9jiKZu3VYfGHA54z6tt2sHs0VO3MAKQWHvDrlBRAcmrrWc/+zST1EznxJ5gSHpdchKZZWRY6FtpqeVncA7Rq6KojL82qANtwykyP06y/97tvl3CK9yINtZJBSE6GO9j/GiXXQ+Eu/qMIVDzIT8KaQLdtE7YakEwFJl+zNx0yPIWpL134BeEjJbeWBgmgzjX6jfh3iSjgEdxxTylMYS3YzZ7Ao4jiyETgbdksYfC97c8kIQNUwZpoby78MbbLLaADHqo3RzN3rOnDGAJl7/DtcEtvO/K3tHhgbcR+nwUyAbpUBu8G5xPtTYyhj6tLKxUgyBzrAQv0zDGEyy2b7+2OT4UDr+QLYfrziFPtXt091LyFbr2N2qEdcml43HVhI+GmrNeXoTc54ci2I4ryltT 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)(136003)(39860400002)(346002)(376002)(396003)(40470700004)(46966006)(36840700001)(82740400003)(478600001)(6916009)(186003)(86362001)(33964004)(47076005)(26005)(36860700001)(54906003)(41300700001)(81166007)(83380400001)(336012)(426003)(40460700003)(8936002)(44832011)(2616005)(8676002)(4326008)(5660300002)(235185007)(2906002)(82310400005)(316002)(40480700001)(70206006)(70586007)(36756003)(356005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB4049 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 9c6e0b57-5c3b-4295-83db-08da7c757bc6 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: u90ff1fkIFgRmd0/37+/oHFKQrbh5yI0vdNgs5U0SdWO+4HEonWDllsf7s1GvdJGxkyE+eHOQr2AV5BTlNz+SchUXfVObIBbCSbsZM0poicz00ydUyUMpCBNUFUhaeQ7nHNfYhclDI97PX7S1YLMcijuKED+qQ8Iv6ftHLiql2G3p0t2HYs6DP5DbKS3MVSKOClRaMjIl+ezraFf4Qepy594u2LihLIHhpk9jr7yyKMeJiHfXfoB/miBgTz8q5KympSFRsUkSyR8e66qna3DjmU5cl/3hOAc+mFlM/53TnxWBFdjAnigiH+Sfbfy9M06wI4dunESkdhq/4S1WGfwXzjQI9YdyW8mFvgDNO6vkIPJDqvyvT5Uswgl7tGYffUr5CqLQsJvBg7eJ3xudUg4xVQs2SOTu6EeL0tYpdzBtAnc4RKy6teM5QK4R8dJ5G9N5msRuSU0zvL6JPSGruONYLm6MKFA3MaFQSQGEJzW5Vq7Ii5KpTuxnv3dkgSL3Yz7jzwO97F0DcRg5F5e0q7fJDUmEGLstHfDx2Q1W9N+N7+UquPAWzuJf4TcDEjrvZkqKyuNIrOTJHPhIyMofiaiVrxS5Rt/y0WxNt7Ewjlf7SWiZfeGB24rXQ3Txrgqsa9AIWMtdoLTYlXAAWy6Pe8P/icEjzl/hDSfrv3Fz6Y4b9yTeKa9xeZAFA7d9W7DuUXeFvU+HQmBkDI8205VIb4/CjyXDm3d0MvfSLgo3qlBrjPk/n3ApZCasBSx7Q/gm3uWezT+xqhW6VACxyjY6K4WwHWfpqbmHGLRWz/nCzLyZr/HzaD4LV72fqzIZpP8+0CtYGNrutx7gHfUhBKLs7HDfA== 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)(39860400002)(136003)(376002)(346002)(46966006)(40470700004)(36840700001)(70206006)(70586007)(5660300002)(235185007)(44832011)(8936002)(8676002)(4326008)(2906002)(316002)(6916009)(86362001)(54906003)(82310400005)(40480700001)(36756003)(82740400003)(41300700001)(36860700001)(33964004)(26005)(478600001)(40460700003)(47076005)(186003)(336012)(426003)(2616005)(83380400001)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:15:34.7193 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 242d5d4d-f11d-419e-86f4-08da7c758149 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: VE1EUR03FT051.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5262 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740968962478580441?= X-GMAIL-MSGID: =?utf-8?q?1740968962478580441?= This patch adds the -march feature +pacbti to Armv8.1-M Mainline. This feature enables pointer signing and authentication instructions on M-class architectures. Pre-approved here . gcc/Changelog: * config/arm/arm.h (TARGET_HAVE_PACBTI): New macro. * config/arm/arm-cpus.in (pacbti): New feature. * doc/invoke.texi (Arm Options): Document it. Co-Authored-By: Tejas Belagod diff --git a/gcc/config/arm/arm-cpus.in b/gcc/config/arm/arm-cpus.in index 0d3082b569f..9502a34fa97 100644 --- a/gcc/config/arm/arm-cpus.in +++ b/gcc/config/arm/arm-cpus.in @@ -229,6 +229,10 @@ define feature cdecp5 define feature cdecp6 define feature cdecp7 +# M-profile control flow integrity extensions (PAC/AUT/BTI). +# Optional from Armv8.1-M Mainline. +define feature pacbti + # Feature groups. Conventionally all (or mostly) upper case. # ALL_FPU lists all the feature bits associated with the floating-point # unit; these will all be removed if the floating-point unit is disabled @@ -743,6 +747,7 @@ begin arch armv8.1-m.main isa ARMv8_1m_main # fp => FPv5-sp-d16; fp.dp => FPv5-d16 option dsp add armv7em + option pacbti add pacbti option fp add FPv5 fp16 option fp.dp add FPv5 FP_DBL fp16 option nofp remove ALL_FP diff --git a/gcc/config/arm/arm.h b/gcc/config/arm/arm.h index f479540812a..3495ab857ea 100644 --- a/gcc/config/arm/arm.h +++ b/gcc/config/arm/arm.h @@ -335,6 +335,12 @@ emission of floating point pcs attributes. */ isa_bit_mve_float) \ && !TARGET_GENERAL_REGS_ONLY) +/* Non-zero if this target supports Armv8.1-M Mainline pointer-signing + extension. */ +#define TARGET_HAVE_PACBTI (arm_arch8_1m_main \ + && bitmap_bit_p (arm_active_target.isa, \ + isa_bit_pacbti)) + /* MVE have few common instructions as VFP, like VLDM alias VPOP, VLDR, VSTM alia VPUSH, VSTR and VMOV, VMSR and VMRS. In the same manner it updates few registers such as FPCAR, FPCCR, FPDSCR, FPSCR, MVFR0, MVFR1 and MVFR2. All diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 3936aef69d0..079e34ed98c 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -21002,6 +21002,9 @@ Disable the floating-point extension. @item +cdecp0, +cdecp1, ... , +cdecp7 Enable the Custom Datapath Extension (CDE) on selected coprocessors according to the numbers given in the options in the range 0 to 7. + +@item +pacbti +Enable the Pointer Authentication and Branch Target Identification Extension. @end table @item armv8-m.main From patchwork Fri Aug 12 15:21:00 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 499 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp940886pxh; Fri, 12 Aug 2022 08:22:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR6qfWGPYuwprumhsH4AyXGYtiQp+sLHyDNc+0mTscnofgKzDMtNK34H3yGUo3cWkS+vZbi0 X-Received: by 2002:a17:907:7395:b0:732:fdfb:8aed with SMTP id er21-20020a170907739500b00732fdfb8aedmr2966522ejc.691.1660317730625; Fri, 12 Aug 2022 08:22:10 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id l3-20020a170906794300b00732f74749d0si2957816ejo.286.2022.08.12.08.22.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=idUlJCqT; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 343AF3858D28 for ; Fri, 12 Aug 2022 15:22:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 343AF3858D28 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660317729; bh=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; 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=idUlJCqTjjrb5U+6FfSUO6g/R7OutySwwI3Qj0Q7M87eHvA4l9O5Cw96LVfwSNrji ynunRh2bM1kPrYJ0wXpcGCYJc9wzWsJXX12Qa7PFPlZbswCVnF93ay7IOyeFVIvzxW wOB8YP3h+rqDcsC7HK5VQPXCy8VKMiCrCDVCwUX0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130071.outbound.protection.outlook.com [40.107.13.71]) by sourceware.org (Postfix) with ESMTPS id 969423858C56 for ; Fri, 12 Aug 2022 15:21:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 969423858C56 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=gEeb+y5TywjpSPxaLF1wr4o+lmnuniH3FwlUammDL649KNA0jR42lLVigsLOhfYGJGahv1gr8cWx4eV+IR/MsYHZfJl8REVWdFL+1uk+JnY6TEVLItLeGuL177KypJXId06oVRq5EDH2qAB9Q0kiLOhP8Y2Ns3nQvqW4bvWtCQsPzlzH5wc7y4xvFmG57fGXSvZ5+xG4gTrLG9LPJSEGSLJ8xz6UbuEFR5gLvZ290V1g2/6yAuvA1Oxs6CdB8SEz7HbM0wlshkNvh0DtoUveq2DGv/zW5q65qHmw3tlH1e9pFwG4IfvBvKM6F+kuIHqKmpVabWTxaSP8Sr1h74jdQw== 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=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; b=YfyNWpJiMEbolQqLiqvZPpI17tZZeD+cFQuLztjU2DegybTtvih87qBUfOFb7PPlMBgVC8730YGS+gC/o8uyGjqa06VsrY/tibzhaFT0INiTYfxTA+OoI9KThNL2w+v7p/HX79OwrGaqULK39222YsXIeiJnIwPtSe+PWWwtP0bwncUrpuNAT7Anv8Gb2682NBGQ4H6nh+4HQyOD1doBeknVwkH6fsSvUblfi3GL0Gae/0EXm/dNTomjtZr42uIkxvK0IGpZZdUgeaTfhEZaHfiu4fEoXiKoW3VLRISwtlaFkf/zv96YcL8yVRTRzjMHaCq9rs4EHD7kiVHnYwZWrg== 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 DBBPR09CA0021.eurprd09.prod.outlook.com (2603:10a6:10:c0::33) by DU0PR08MB7567.eurprd08.prod.outlook.com (2603:10a6:10:317::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:21:19 +0000 Received: from DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:c0:cafe::a7) by DBBPR09CA0021.outlook.office365.com (2603:10a6:10:c0::33) 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:21:19 +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 DBAEUR03FT022.mail.protection.outlook.com (100.127.142.217) 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:21:18 +0000 Received: ("Tessian outbound fccf984e7173:v123"); Fri, 12 Aug 2022 15:21:18 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7358ca300bb4dc34 X-CR-MTA-TID: 64aa7808 Received: from 760f068cb02d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 2D3D10DF-7B24-4051-A514-B8136D9CBCA4.1; Fri, 12 Aug 2022 15:21:12 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 760f068cb02d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:21:12 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jfjDu/0U9cnkjaV1D+UI71OGOt9xPTEfU0knrn/HJ5H05zRgS4Hc2yGTPpT0Zoxn7odPvrMuvZbcYyEYDRZ3ecvsloJb3X58Nom1V/5RLJgJXtaRgKf1NeCgon6OeCryhJdGRGhzUloMH3WWbyXc1FOczs2HYdx4YspQ8R90OlR9NpbtnoF+/PFHj+egurFMk10CotyWuHMH2vbG/JqdTDXkIX4h0V3XuJloe50mENSsbk7XqlviNuZiX/3fpyTU4hI4FByXeVQBSBbNn9SECK0CBoPABqxdDACASBTWzoezYWjhEMxUzeNwjbColyAIRSbhHKENRyCCmwSQwzcUWA== 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=ZtfaIXC8wiiHN9Pexf+DVnZyyPQQD0tfStd/RNOckCk=; b=PCF3qJkUTF5WBv+Lu1ROMhC9iZBwC5XB02i12j7nbFk8EX3Bc6t/eGeinKJ37t5dvUYzdSpdffIYxsOks4ubFNOKtb7gGZW4o7bxwbDJQ2Bsgqm2Tg5aZkH7NpTitgQrozK4Cjjl3RWD3xQst3aFCX9vpLuZFcyHTLj+/2bZS/jo9aoFeYryhzPfmJfKFInxeqeXXWNSuLdjV2GGGwygWyVic4Y8icD/0QuzODg7SQ1fwhOif8baNIlDhnzfwWMFPl6H3T84U2SdHFF1b0qOqoxel0m5DxwD+XXkUsfTfBOQ333t6YTW5FBnWWPrBdLFh3o+qbJJ9hw6sqfKammFiA== 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 AM6P192CA0036.EURP192.PROD.OUTLOOK.COM (2603:10a6:209:83::49) by GV2PR08MB8171.eurprd08.prod.outlook.com (2603:10a6:150:7b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.19; Fri, 12 Aug 2022 15:21:05 +0000 Received: from AM7EUR03FT063.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:83:cafe::d0) by AM6P192CA0036.outlook.office365.com (2603:10a6:209:83::49) 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:21:05 +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 AM7EUR03FT063.mail.protection.outlook.com (100.127.140.221) 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:21:05 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:21:01 +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:21:00 +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:21:00 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 3/15] arm: Add option -mbranch-protection References: Date: Fri, 12 Aug 2022 17:21:00 +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: 4ebd2c79-6683-455f-768d-08da7c764e50 X-MS-TrafficTypeDiagnostic: GV2PR08MB8171:EE_|DBAEUR03FT022:EE_|DU0PR08MB7567: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: N8fDXcpbFNiQWPlMe1yjvFUfmSV8jv/wfTyg9MlijzNuAN8C/F0pYo8pEqVWQovHAr1MKFJJTm5vOZyox1U9Ve2af9HHGzkE/qzuLCT+qFOj/sPXeuhXK08sMk5XYy89F5lIDMR5mFfJxY4IXLmFf0n3huXcrRNy4XFc9pZ3cykcW07Hd9oVMVGCiS+bVVdSJeC7S8aSI/u2nMHn9yZ3Z1qfp4D7WSL+boXnIMkhXqcKRQrMB0Pl5HWaZL2kWVeUc+UgTY5xyk6fLYUO3lVI7R9a4eP1sYIMVQASXbh0642Joy7N6QOfvJRn8fTowj56SO1r6i7GvLdIFHcNSXwm3F37PP+H/0rfU9CGAVbWtvv1lTv6PUc9gn2pQvx/lqg7B22+oujcR7nDd27oBiS1YoOjJl48OZyU8AZWwcs0+p2gHK88imMmr9wZjCT5xrttamycJD3FIW/4WLlVcttNDYrNMKe19r6U/oOqDiJ1I5IqDRbkZ6FacZcSnohTPdVg4lvaElWSg/TvdHx0cXIkNvl7Tb8P7FCz4z7DxBPeKXlkzFoRg/wQmq8FRifOAU2RrpSak4Y0N8ZMiXEXWCLc/u3XbDogYBnV1H47J6ooNWvNdF0aB268/muOrwJlldBFG1a/x2DYt1YSs+0vLfWidTE1JVZrIEPckZv8gtMFC4TLCEL4fImhgHtjhOqRZL2EIUbzW9VppurfMuju7e+wDkvq2e26/23fq5RnY1hN4OsVTbcZJ2Ah0uEiD4p+pQEzqhn0vskVk+B9VsyYuqxeg6Z+4cgM3x3KwWVpI4cWz5HBRZRm2TAT3Lc3H+Qklxrqbvn8dGGc8EyuCHru7Nx8TXyLIsM/8hhHeHEqMFCi3ApzTK4ROaXveUwHK6YKVtig 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)(346002)(136003)(396003)(46966006)(40470700004)(36840700001)(336012)(40460700003)(316002)(47076005)(426003)(83380400001)(356005)(40480700001)(81166007)(44832011)(82740400003)(36860700001)(82310400005)(86362001)(70586007)(8676002)(70206006)(6916009)(26005)(186003)(36756003)(41300700001)(2616005)(478600001)(2906002)(33964004)(4326008)(5660300002)(235185007)(54906003)(8936002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV2PR08MB8171 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 830a69a5-0c14-4372-ccbd-08da7c764660 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: x/R5GEyks1DKfdt307KfqekU9UF5dqJpA23pmf6TBCTI4FS2K7oxI3Awur/y6IFa5TwPY6EidHAKpGgwDtKgWFjKdFMJG2FO6SMn18HSU+Lm5TxzfZ2uyUaIVD5csRDUgRK4g+x0kyksycgXAkJWgziuU/A5uLiy3PbEOj754Qc4iNIjtT0S9WaGCJNLRa+rPp4RUSPiyEioTGoju7lGBCDVzgHImTdy4+fl/63ez/jO4BqNZ4FOcyd5b6U7/54RTY5mUhr/SyHXSBDcgG3RozV4GHWxkW649IGRU9qQcHh9Z1t+R59rOyboC8b7gC6mu43kCVGw0XAQnP3eUIhtsIhXq3LCvnbbrc94qJM0XViBOq0q+HKKEKin/x3ALJsbOQ7iNGZcPDNwWf2ZIMuwNDTj+o8oPOu2pFx2f66MYnTSqCYfSfFix6tntMxaoz/seawXrDJjwBrmjI6I9eoi2acQOuvTyfI/ab1gyczU0VzIvdElFNWsz0HafmOotFzhspmshpm158Do75nThaMKZL7zGbHeXQEa4JUk2SWIC5ov11Drjg7mVHBmqpY7zIZsq8rWI4rmgCKrCjeBRvfj7C5eXgq+HlJdKA5Woc9rvjR3rdlUeJLzbNtw0cs2CW6/qnQ0qhjmjhAZclkqaJs2pzYP+ISAvl50GcAsZOncAJ5UJvVSz8XCsSF+NWYAiN+GD59lf+Ej7YhtFJKpw/hyrXItYgZSgKV/MD0EI+okMKZ1e8VDtMJsBzBpsSSDBLUhQYXs1BFAjwTLIGhOFPZJhgUQMtJ+4BLGSQwzYSXWasdqxJ0CGeIPejD9/PfQdlKRZJ1cvfeySNFsfc20yIpdyg== 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)(136003)(376002)(346002)(39860400002)(396003)(40470700004)(46966006)(36840700001)(316002)(6916009)(478600001)(54906003)(41300700001)(2906002)(4326008)(40480700001)(40460700003)(82310400005)(70206006)(8676002)(44832011)(70586007)(235185007)(5660300002)(8936002)(82740400003)(36756003)(36860700001)(86362001)(426003)(2616005)(81166007)(186003)(47076005)(336012)(26005)(83380400001)(33964004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:21:18.8227 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ebd2c79-6683-455f-768d-08da7c764e50 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: DBAEUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7567 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740969324717041972?= X-GMAIL-MSGID: =?utf-8?q?1740969324717041972?= Hi all, this adds -mbranch-protection option. This option enables the code-generation of pointer signing and authentication instructions in function prologues and epilogues. gcc/ChangeLog: * config/arm/arm.c (arm_configure_build_target): Parse and validate -mbranch-protection option and initialize appropriate data structures. * config/arm/arm.opt (-mbranch-protection): New option. * doc/invoke.texi (Arm Options): Document it. Co-Authored-By: Tejas Belagod Co-Authored-By: Richard Earnshaw Approved here diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 60f3eae82a4..0068817b0f2 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -3263,6 +3263,17 @@ arm_configure_build_target (struct arm_build_target *target, tune_opts = strchr (opts->x_arm_tune_string, '+'); } + if (opts->x_arm_branch_protection_string) + { + aarch_validate_mbranch_protection (opts->x_arm_branch_protection_string); + + if (aarch_ra_sign_key != AARCH_KEY_A) + { + warning (0, "invalid key type for %<-mbranch-protection=%>"); + aarch_ra_sign_key = AARCH_KEY_A; + } + } + if (arm_selected_arch) { arm_initialize_isa (target->isa, arm_selected_arch->common.isa_bits); diff --git a/gcc/config/arm/arm.opt b/gcc/config/arm/arm.opt index f54ec8356c3..d292e23ea11 100644 --- a/gcc/config/arm/arm.opt +++ b/gcc/config/arm/arm.opt @@ -323,6 +323,10 @@ mbranch-cost= Target RejectNegative Joined UInteger Var(arm_branch_cost) Init(-1) Cost to assume for a branch insn. +mbranch-protection= +Target RejectNegative Joined Var(arm_branch_protection_string) Save +Use branch-protection features. + mgeneral-regs-only Target RejectNegative Mask(GENERAL_REGS_ONLY) Save Generate code which uses the core registers only (r0-r14). diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index 079e34ed98c..a2be3446594 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -825,7 +825,9 @@ Objective-C and Objective-C++ Dialects}. -mcmse @gol -mfix-cmse-cve-2021-35465 @gol -mstack-protector-guard=@var{guard} -mstack-protector-guard-offset=@var{offset} @gol --mfdpic} +-mfdpic @gol +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}] +[+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]]} @emph{AVR Options} @gccoptlist{-mmcu=@var{mcu} -mabsdata -maccumulate-args @gol @@ -21521,6 +21523,40 @@ The opposite @option{-mno-fdpic} option is useful (and required) to build the Linux kernel using the same (@code{arm-*-uclinuxfdpiceabi}) toolchain as the one used to build the userland programs. +@item +-mbranch-protection=@var{none}|@var{standard}|@var{pac-ret}[+@var{leaf}][+@var{bti}]|@var{bti}[+@var{pac-ret}[+@var{leaf}]] +@opindex mbranch-protection +Enable branch protection features (armv8.1-m.main only). +@samp{none} generate code without branch protection or return address +signing. +@samp{standard[+@var{leaf}]} generate code with all branch protection +features enabled at their standard level. +@samp{pac-ret[+@var{leaf}]} generate code with return address signing +set to its standard level, which is to sign all functions that save +the return address to memory. +@samp{leaf} When return address signing is enabled, also sign leaf +functions even if they do not write the return address to memory. ++@samp{bti} Add landing-pad instructions at the permitted targets of +indirect branch instructions. + +If the @samp{+pacbti} architecture extension is not enabled, then all +branch protection and return address signing operations are +constrained to use only the instructions defined in the +architectural-NOP space. The generated code will remain +backwards-compatible with earlier versions of the architecture, but +the additional security can be enabled at run time on processors that +support the @samp{PACBTI} extension. + +Branch target enforcement using BTI can only be enabled at runtime if +all code in the application has been compiled with at least +@samp{-mbranch-protection=bti}. + +Any setting other than @samp{none} is supported only on armv8-m.main +or later. + +The default is to generate code without branch protection or return +address signing. + @end table @node AVR Options From patchwork Fri Aug 12 15:22:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 500 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp941790pxh; Fri, 12 Aug 2022 08:23:46 -0700 (PDT) X-Google-Smtp-Source: AA6agR6MrOIJsyySPx3lx5rf0GkBHc4P2HguRjiV1/8wiT5GqDYJ7wD79uxNv86FE0AUADF4860Y X-Received: by 2002:a05:6402:5107:b0:43d:6b26:bdc5 with SMTP id m7-20020a056402510700b0043d6b26bdc5mr4063364edd.156.1660317826472; Fri, 12 Aug 2022 08:23:46 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id qb23-20020a1709077e9700b0073155c0e7cfsi2231741ejc.695.2022.08.12.08.23.46 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:23:46 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=Y2ZQ1qfc; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0F29E3858415 for ; Fri, 12 Aug 2022 15:23:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0F29E3858415 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660317825; bh=86AdRSobdnOzVIrPfC7+PDiE+OOfF+0Yn6CKC6fK2ts=; 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=Y2ZQ1qfcRpCfFWROMayY8mEqXyTTcS6kSJN/R2xBo+Biaxeq7xeJ2nqZrbmtlpInZ 0O4GPVZiC3fpyMxHgdQ4Wskz40E/LYy2CaLPAFkX4pluRU1cDIBc5+yn3POtjUgz11 TilKQ8QpmbohyvnOrzDNU9dgHZxtSTMz5VXMuM0w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR01-HE1-obe.outbound.protection.outlook.com (mail-eopbgr130050.outbound.protection.outlook.com [40.107.13.50]) by sourceware.org (Postfix) with ESMTPS id BBBA13858D28 for ; Fri, 12 Aug 2022 15:22:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org BBBA13858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=CJ5krxo0a++MpY67dP8yoC1LjlhfRl1YVz7ogM77OHY5ahZU5WEhY2/iYQu0Eyp//hFkvBB17nDnQg2Ieud6lzu5BheO/FXuGkOdl1lBQH0PoJDZTYtMPTn+fQ82129Lzm1PuwWs7SnRwMM6gR2W0AfzN+ln2iiyeRAAdcfkNlOVZU6s/xP1zKbJXnLsIbqWrsehWeuS3dlrimBcfIHZRxYCMF0BRq15GyBdKmZdqVUDDiYzhl88bKHFDjUeOWWwiciA0nVU1vK/tvKfNcmlgIT22I6NpvhaXeA89cd9xYQvaN8jccGTzIwj/mDJTDD3Fbzz0C4yQu/5klGCwi+5bQ== 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=86AdRSobdnOzVIrPfC7+PDiE+OOfF+0Yn6CKC6fK2ts=; b=mH4mRkgq3T532RcC81oblkHULSoppI5I12+Ee69G8hQi3AtRSBJhWtyOMuvSUZ68/xRA0pueXqj96yUaL6m/Nkll0Xo9XW9lnluX/XI+cDc8hMTNgIkO7Gdi8FhTzRNo/i68ieIVrDYUN0ZVHWkGnk620V8ijeEDXUxE4gMMDbhntPI3IQwrNpNqUnLZ46OHOxHS596cwUuLyoNtuHA/rh0mWBI+e/BAB2aYf3ZojMz2yAjvEhSzLeJgYIz08VL9ZUq+g2qV36SWIFvVjt+AQRxVcdmue2YRNjkICBOwba2aTEzj7cLHAfnC7nKg9hkX+A8+fR/4AbsxD+mF8eVT5w== 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 DB8PR04CA0028.eurprd04.prod.outlook.com (2603:10a6:10:110::38) by VI1PR08MB3117.eurprd08.prod.outlook.com (2603:10a6:803:42::22) 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:22:56 +0000 Received: from DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:110:cafe::90) by DB8PR04CA0028.outlook.office365.com (2603:10a6:10:110::38) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:22:56 +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 DBAEUR03FT032.mail.protection.outlook.com (100.127.142.185) 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:22:56 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:22:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: aad359c8b4d3d753 X-CR-MTA-TID: 64aa7808 Received: from 216906d1b640.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 40F26553-3E05-424D-AA04-7B4862FB5D58.1; Fri, 12 Aug 2022 15:22:49 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 216906d1b640.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:22:49 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P+wb4GBnvAFBaMdndift28Fv9i5LnvMdKmJJvk8G0TksMDtNLeaPWhomhbvvN+3AGtguRhcS6rYr/ZOSdM6FSIB7AaKpaiBHtp5MrRtOd2W3+sn0E9AD2AXjWvAG5d5lZKhycwJoeRL24MIMjvE9jSTwwLFXn9JxtQe98kDIHal19/EBwlFf0P3H3COKdVzzhnDCtZakC6b9sxMroVWGFdfHM2IWBtXiOEyh5/BGxMaHWlqGYH3tZc96yi4aGclzE01FduCc9Ib1RzcgE+cb0SlB7t8uv4T8HXiuKzepUMJQLwX1/g0o/rYdP8cknE7tiDs4H5gt8juBSc+VjUeuEg== 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=86AdRSobdnOzVIrPfC7+PDiE+OOfF+0Yn6CKC6fK2ts=; b=iLw9jUjc1DJ5lBItIRQaFqqQqpTRrV5iedjr903dCU28/1wb+3NR3o6A88fOTFJJq6TnqST/QqNbutudeboIgbhTupG6E6OroNddSo1a3twCD5R6y0M31oJCGY1un+qp3F7j+7eGZMoXfaJuZEnccImZ6/v53fLgVzA8MNAHBCjBi/aJwoWe72FChJpo5TA97f2NBBqm4dDHCzYJ8ZdkGy59HWbsF6DjiPg8Spbkcy8mk1R6BmMwxPlSh7raC6zGAdd9wTxoeYoGdFpDcaUTKJsk6g0xe+C4B8j15oPqxMGZKfiBilZEZKZ30TDqJ6KDTQgQC+5Sdq7jE27YIJm0ag== 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 AM7PR02CA0017.eurprd02.prod.outlook.com (2603:10a6:20b:100::27) by PAXPR08MB6623.eurprd08.prod.outlook.com (2603:10a6:102:155::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:22:47 +0000 Received: from VE1EUR03FT004.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:100:cafe::5) by AM7PR02CA0017.outlook.office365.com (2603:10a6:20b:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.13 via Frontend Transport; Fri, 12 Aug 2022 15:22:47 +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 VE1EUR03FT004.mail.protection.outlook.com (10.152.18.106) 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:22:47 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.9; Fri, 12 Aug 2022 15:22:46 +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:22:45 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 4/15] arm: Add testsuite library support for PACBTI target References: Date: Fri, 12 Aug 2022 17:22:45 +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: b6109157-254f-4dce-37e1-08da7c768842 X-MS-TrafficTypeDiagnostic: PAXPR08MB6623:EE_|DBAEUR03FT032:EE_|VI1PR08MB3117: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: syWxgHshlA3I7UmsJ6mr8kJlpAMLm8kyU4iA3tnMqHfK3AccPMEJEumgHDfdHwLLirafHUpnhIWUIGUBoQFnCLqtgfukF4w7eRGi1wz8GSh33iuFSZm6CIW939+KYX7E4AjacOuo6HsylpcXuF3Vho9SEakgHe1IPcg1uiW21mYQo2duCoUPxE/stxETp1aICLSTHd9nTCx1hqeheIjQM4AFXT46Nsm342JFiBpxMFU8mXRM3CjV8tGaz34FycBPV38kPvGfGue6w5P7R2AV3nDV+fJPvcDhKdmIhXYDKoybComhJXz5A/E0qT2rYWUlTFwqv7/mLVHpAPkBx2cyJkV2dlEX8zOwnLUUluviuPa3BP+wosXhmeXMrYSshL7dj9DYeM3dhEDTBmjXRhkIhH+U3jOxVklWsnCMsEVjXOzC8HywW+oxOOocT+lyNuJdtHb+Sh5Uc3aIgIGA0bZFVpgptwsTlkueg+K+t4pm1jFvB58kViNjB2Ol9JY5Ms5nKbDihPoxs0dQHmGfUbrkmHm+JiwULWUajqkOAl3UMtml9zUctpHt6qiBRWQyy+dqGEXkFAUMsvCvZjoDSIZeuQMg5gZEit8oyg06pMD2asIAGulI1isShTC3IsbpOOQdRr6lIMGPY0LhaDdDoCSSFxqpBL9sNkjG3y5jeY0STsP1V4AS8HmpCKoBH+ttnUzltfk4exT9L45t5p+xh0f+GJoIuy4oSflhblahecwhZxX8o/uXw5FaW4A4cizNYeh+SGDNwd/esULqTHAkVbeidTiLLF6OngE8XFxex6KejzOIB3xVdo2mfNAb+uERBK1RWJZlU1+h4C/pPh38XowjOG18SGrORsb3jshtV1ob9AaoYthYREm2ZkCAXXTpPV8U 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)(396003)(346002)(376002)(136003)(39860400002)(40470700004)(36840700001)(46966006)(356005)(82740400003)(81166007)(316002)(82310400005)(40460700003)(5660300002)(235185007)(86362001)(478600001)(8936002)(26005)(33964004)(8676002)(4326008)(44832011)(2906002)(70586007)(2616005)(70206006)(6916009)(54906003)(40480700001)(426003)(336012)(36756003)(83380400001)(41300700001)(36860700001)(186003)(47076005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6623 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 4500fa23-d99a-4656-17d8-08da7c768333 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CS1VmNnYfm6o3qhNXhTOiIqtctnAeYX9qVTpBl3GFoouxJ9KT9Wz76FFY/lh5kqV0zB3X/ERgCBaHhIXhLGi1yidsz4oqo+/lpjQ/dy7bDgnpbxeC6rU370iRug0fleM1DBgKgQe2QYcihElovb7GqFKTbNCe6EVgU0ahuC8Fjz2EP0OBOM431cFqJLRUgBlPLLKpLreCE66V0otpUdv/QOBhyn89FAZusbvd8IlYNbFlAva3yvkfSvuJ0P2lXVPV++uVXahPcjzxP7HCZUJfdNjAy2q3y42w9UJflXdqCgFBVsBNd1aWx6m3t3fxWi6lSVLX3J6p24ZKaoFm6EKho1ooZSN7CK+L2Zwl96fK5Mzxpim7IeQQ46oV1odbu3OLdmr8pDcoJjj2zcl6LZ7DFR1Tto42Eq6x3+V08RC022hLzlHrnbodvqvRQcQEp+m5k6QpG0lXVA0/5jHJnHdwy9JO3ClLDpETchGJWjV0xVxDnV5ENazQLAAeJ6WBiCFhv5JxDB6iDenvQN3R2FylheCLFgeP57jFZfcBzxN5wqebTQpIS4afxbZJKFAtOZc8goupITZp6W8S4XhAqGMjKEznaxqeV0CjUl57fJUtaNxU2HwdCq3P0gfy3g6wHbNcxvADGQfnVD+/Hy8mUf87moQrCELZ2q5uNDIOsVXD7lT11LrXL9nX8Gg21Ddg5RbqASwyQ4HaL6G8rwhyOmQr50m9uMcejwIApIzaA0zK0zQxwADC4opXgt+k/cE9U7tTGFeeRvE1/ULV0OA+A0P8n6CMdFPFf/qOrVlG3rmeiMOnL0+JPNE3ktpSvIBA+vj+plDRQ1hkQhRzqx7KG0vjg== 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)(39860400002)(136003)(346002)(376002)(40470700004)(36840700001)(46966006)(36756003)(86362001)(5660300002)(82740400003)(81166007)(36860700001)(2616005)(83380400001)(186003)(336012)(426003)(47076005)(26005)(478600001)(33964004)(41300700001)(316002)(54906003)(6916009)(4326008)(8676002)(70206006)(70586007)(8936002)(235185007)(44832011)(2906002)(40480700001)(82310400005)(40460700003); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:22:56.0372 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b6109157-254f-4dce-37e1-08da7c768842 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: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3117 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740969425086202265?= X-GMAIL-MSGID: =?utf-8?q?1740969425086202265?= Hi all, this adds targeting-checking entities for PACBTI in testsuite framework. Pre-approved with the requested changes here . gcc/testsuite/ChangeLog: * testsuite/lib/target-supports.exp: (check_effective_target_arm_pacbti_hw): New. * doc/sourcebuild.texi: Document arm_pacbti_hw. Co-Authored-By: Tejas Belagod diff --git a/gcc/doc/sourcebuild.texi b/gcc/doc/sourcebuild.texi index 613ac29967b..a3f60e9c0cb 100644 --- a/gcc/doc/sourcebuild.texi +++ b/gcc/doc/sourcebuild.texi @@ -2167,6 +2167,10 @@ ARM target supports options to generate instructions from ARMv8.1-M with the Custom Datapath Extension (CDE) and M-Profile Vector Extension (MVE). Some multilibs may be incompatible with these options. +@item arm_pacbti_hw +Test system supports executing Pointer Authentication and Branch Target +Identification instructions. + @item arm_prefer_ldrd_strd ARM target prefers @code{LDRD} and @code{STRD} instructions over @code{LDM} and @code{STM} instructions. @@ -2256,6 +2260,12 @@ ARM target generates Thumb-2 code for @code{-mthumb} but does not support executing the Armv8.1-M Mainline Low Overhead Loop instructions @code{DLS} and @code{LE}. +@item mbranch_protection_ok +ARM target supporting @code{-mbranch-protection=standard}. + +@item arm_pacbti_hw +Test system supports for executing non nop pacbti instructions. + @end table @subsubsection AArch64-specific attributes diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index ff8edbd3e17..aa828bd3a07 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5090,6 +5090,22 @@ proc check_effective_target_arm_cmse_clear_ok {} { } "-mcmse"]; } +# Return 1 if the target supports executing PACBTI instructions, 0 +# otherwise. + +proc check_effective_target_arm_pacbti_hw {} { + return [check_runtime arm_pacbti_hw_available { + __attribute__ ((naked)) int + main (void) + { + asm ("pac r12, lr, sp"); + asm ("mov r0, #0"); + asm ("autg r12, lr, sp"); + asm ("bx lr"); + } + } "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mthumb -mfloat-abi=hard"] +} + # Return 1 if this compilation turns on string_ops_prefer_neon on. proc check_effective_target_arm_tune_string_ops_prefer_neon { } { From patchwork Fri Aug 12 15:26:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 501 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp945303pxh; Fri, 12 Aug 2022 08:30:19 -0700 (PDT) X-Google-Smtp-Source: AA6agR5P8ZjBk7Yu0bV8r/PF8m8HmW0g6SttoGO3/8tId/rtnkxHn6FO80tDLGVDI9ZzDkYgckFm X-Received: by 2002:a05:6402:35c1:b0:43d:fd2c:ae15 with SMTP id z1-20020a05640235c100b0043dfd2cae15mr4226402edc.63.1660318219146; Fri, 12 Aug 2022 08:30:19 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id gn29-20020a1709070d1d00b007341ad4b028si2322044ejc.642.2022.08.12.08.30.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:30:19 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=cGASobih; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2250138582AF for ; Fri, 12 Aug 2022 15:30:11 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2250138582AF DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318211; bh=Szqw6UnlTqZEJ2ub4pJR60dIwhCtge0uvV/pPH0NWLU=; 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=cGASobihe3Du00GXVEmRWGom4w2w+88Qbq+8ukG0qYVaKEBw/wEOQWh4tCFblOOPt bA35tjLZ5nNJ0D3/T8oUT/tIqFJJJ0UD8mhGvtk5QGM406NKjqzol1xEUmY1yk7CRi nZnhQ77xrsOcltrZ2ac7i0DE/q7GrU8YKOYRGwfA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR02-AM5-obe.outbound.protection.outlook.com (mail-eopbgr00053.outbound.protection.outlook.com [40.107.0.53]) by sourceware.org (Postfix) with ESMTPS id DA9583858D28 for ; Fri, 12 Aug 2022 15:29:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DA9583858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=CgcuLugntCmz9Oh63T8hDPOYhjfXVHJoFAdKrYxjAwHnd0Y3QWdUIEFwNvbQFiTH12Wg6EAhdeh+L4XNDWtkKQxyzpzALvMPKU10S6s50Ct/j9hl24nL2G/IrPQjeiyA8aNASVhVVQZ6AdDTva3ZGPbYnlhmu6iiasI1fXIofTG2m5vHSB3Bgp6iPaYyRsUp+5+MXATKraBn4Gj9tlvkoITE29vQZoA6edFjbr2SQGtNnQTf9QWifycwyLLqm5mt3xKGGkn+uVLDM8Lv1ASAyRPTRIWrCROWE1jGR39svWqTzHtyHeQYhzmPfCcSVA4b7f2jQW//Y86pKsBwAjuheA== 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=Szqw6UnlTqZEJ2ub4pJR60dIwhCtge0uvV/pPH0NWLU=; b=eMfqR2QwN4toPR9Fp8vIZIh94e2iiS/i5FHWIQu5yMdafbNgfB8jTBJqvk+OUIMNi9SLRg7qoxZQAJ5Add4wehqPb4MUjLHVgyTvTMK7y9PyN739q1aPt85MY24Lxf3/lwAin2wAOf8xJBn1pNqK1Vhk61nQ+G/ju3jDj4ZKkWpOcOl8EE8lE+OyHp/68AmR4km3Y90v2i5R/InyeGNtMU+QVC7ln8V1Z4/kKHuirjFA7KxalIIrcPxFEg26m2PP3PjevsJisu60wn035NXV7qmawGQv7j2KLZrtc/faiczach3gkz74oZIhrQ2VU+u1y7t+hLC4WiR/WIo5kydiDQ== 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 AS9PR06CA0295.eurprd06.prod.outlook.com (2603:10a6:20b:45a::12) by DB6PR0801MB1942.eurprd08.prod.outlook.com (2603:10a6:4:75::11) 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:29:21 +0000 Received: from AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:45a:cafe::20) by AS9PR06CA0295.outlook.office365.com (2603:10a6:20b:45a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.12 via Frontend Transport; Fri, 12 Aug 2022 15:29:21 +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 AM7EUR03FT043.mail.protection.outlook.com (100.127.140.160) 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:29:21 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:29:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: d2d80713bfe437ce X-CR-MTA-TID: 64aa7808 Received: from 9adf1ac45115.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9143BA28-3483-41BA-A114-D10570D5AB08.1; Fri, 12 Aug 2022 15:29:14 +0000 Received: from EUR02-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9adf1ac45115.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:29:14 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WA4/8XNBblyMBeH00c0nN+XeKIBWjgoGFOXLonNWDWwWK/TFaFaU/oMajORFyfvtSqqg0JxvPMPwd5wOKsLcUh9jcDKyHUjOO0aI4dCE6HkwHnIPCRPcVqcCm+nrK4NPMf5Zo0FRBSjd6v2GyPWUNedlqJ5k9Fvixfo9m+qV9VE/XrUqw5Medo1l7LxyTuklKIbEmWdDXTt/AkbLmZ3obb2YP7HEIUBdWJswkhm55yMeKz1cRAxHUVqVOKbo4HdTez99AYc2bAKQlnpDl6nq8vwkwlqz8CkG12pb/WP0tRkajXIZy2VZMCsX3jIL3hMM2m6PlEbljLwGGCTXCQ908g== 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=Szqw6UnlTqZEJ2ub4pJR60dIwhCtge0uvV/pPH0NWLU=; b=WfKJVw+bU5dHsXoM8at8vQs6Vc423JkylkOeCinrhQNIctIZF3M8QB0KMvyumASq9WnIpuFfGTFNdPB0IMRoMmlejzk2PMrvftCSNu5C/J3gNnuhjl8ucbPreezpF2a9rpc+Qvdfj/XEWpULZy8Lh5cqQT65HlECN2bhxYVwuQahsHiAjMbMJc88x80Tb0J9syILvgTvll4AxgkeVZJ+KI0GFaKxV/+Mbh35/Bsjvu8pe1CzuRPsn5GHwbK+U29scLcXbjH9Mk6tFs2I10SBOf+vl3EqHSiatQVf5q1VQQ5tJPzJhLUGPpaAeXwYWn1Vh+iAALTU59hyxCza+zUwAg== 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 AS9PR04CA0116.eurprd04.prod.outlook.com (2603:10a6:20b:531::17) by DB7PR08MB3676.eurprd08.prod.outlook.com (2603:10a6:10:4d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Fri, 12 Aug 2022 15:27:01 +0000 Received: from VE1EUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:531:cafe::7f) by AS9PR04CA0116.outlook.office365.com (2603:10a6:20b:531::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:27:01 +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 VE1EUR03FT036.mail.protection.outlook.com (10.152.19.204) 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:27:00 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.9; Fri, 12 Aug 2022 15:26:37 +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:26:37 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 5/15] arm: Implement target feature macros for PACBTI References: Date: Fri, 12 Aug 2022 17:26:37 +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: 2ca6f592-d93e-46da-fe2a-08da7c776dec X-MS-TrafficTypeDiagnostic: DB7PR08MB3676:EE_|AM7EUR03FT043:EE_|DB6PR0801MB1942: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: +n4CNADLjZnJmsEOrlVS4qtZjFvimojPzmlUF9d1tCfWo+9Jplx+KuHd8k4ZXVAi2cQJxMqUozHG7Hrh6xATPe/5b4Iq+gURb8FaSKWOONBpeof6f1BVzlTwY6fl28WJJ6KFP/BHNe1lUnXzJA/2x+ztaJQgZ/A0qngjsYh810e9UEF1uD6a1Ea0PRdiuufxfKlDvZNngLrSHpsixxXyYnmrh4TM7ZGcQyOkdOTMeVtHvvdXw/gT+eRrPeHAeSNGrP7xpXppxQNWyXRy3iozNY5eMOpJirig69EFNIN0+MXGx+NVsaq2GiUZt0zTPqnnlEJXF21QwRQzTknb26DD2Ox9GGkTo3xoe5+5gvuVoXElZrMAkuDVT2TDIrtuHRN08hDZa9taHyoC+Y9hLSCyuKh4VLKRmrSEFmYIB6el6qjNFNyDXEHR6LbcPCFXIulgr+jGz7aq5MlDPLcBmSm5jlthfcBxPl7O/0ASrZpaDJI2fcJ5CWddL57ch7ERrmZzlqlg2+/4gHhufVkW2cSlqudou8kYG0xtXY+5e0kXZ+Uov9y0c8MXeAJcu/p0Mz53uGqkS7+BgGI4uLEHpuecR/AoBBtcedUE3yjg1m6zhVGSNtZS5IZaNUr3FS9hyEOvA97dRvwzxk3TjOYH6rFolDYxmXcRZmNcPaFuFYstPYjB9qJ7SnY8yQJH/ZkfkayeTinR8Om7EBE+nBjqBA+vbCXIwsYkrVL2odp4DTcndOI/PB0Vr4FpbMvDxi5SelnQDxb29Ikqet4fW/ewEev8mBjviX1T8HYsCOZETCdElz86F1lp0+bBoUuezyqUWbogmP3Dk3FI+uv8Iq0Xji8eiJweNBzEHx04UE9XyXhoykxaOCCTItyxohi6osELviVE 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)(46966006)(40470700004)(36840700001)(26005)(186003)(4326008)(8676002)(33964004)(2906002)(70586007)(70206006)(83380400001)(36756003)(47076005)(336012)(426003)(2616005)(5660300002)(235185007)(36860700001)(498600001)(8936002)(44832011)(84970400001)(40460700003)(82310400005)(86362001)(6916009)(54906003)(356005)(81166007)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: k+WiYrHobZ2dsOWPQypfDIQcWdum0GBMaf2qZeuZlp60H4tiveHrzujbV8iqPeal5Qhig9BfQJDvCIGeNdiEcu2zZnUP3S4J9LwQ7xwOkAuDqJRWzUhbK7z5Yk+9lKgd/wY6TdN6E2n0bnyuE0CYNteEfbjRuakSHfgfgNSEChYY/RLhSDtGFKNL9Z2Rfnj6s8bX+D8Aow7GkUtzlv7Ag7w1nb3K03qsEgQydxROGi7y1VW5GM1lcdwAl0EG6+Uac2hhKf3JWyhwvW7JR252Onc+rQsOXuWtYrkIEv+SwY+qtwpjZjv/rdHU2EhRuFiPOd7UTnKw11AA0X1OOhubNe8DTcNv89ny3qnrfIFNQkuRPs9U6r/6H++nfB+ODey8paBvn5JO5QU4WGgVqyi9RxNbI0/dAxRa5nMcOZpflnuU17N3l+uNgUTe0eBojKcRttpz04yrjeFbzByePnLdYKNIq5PZN3PcU3bFee/ixaS1eOs+DLLEl7K9jlEKaobFqAY8mxQnPWy9pc3Q4qml9k+AbVOnwH4hJ6vjG8dyRkzWjTG6oAPdROHzx211J7BOO1PVjdNzp/9W/FYdjm5VRUQp6ysipIiMEdiU6DCUzflc5DUhNbkViNc5yLw8ea/FwJQZIO8wEUESxxLKNQKeW7zXrjgYg7OYiJw70abyOkOSltLyS3tYsVZFUvX3SiPTeBkXoc0bgJwoMifDotESEw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB7PR08MB3676 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 7fece05f-ba47-4072-7d0f-08da7c771a4e X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gAfgIUWaf4LZz11w51qRvGBKW07QH+zMAPZpeQ9Hh4GL4Oqm1StHY4uMOr5cUh1fqowxv1YXUk3mPZG/jpqeBVUT2bBvCgO8oG/OhoGa7rtsxQE70ZwouAR+nkbDWOa/1u7l8mG763G5qgMkLbaPuTZ5Notem4XVObZLRaSaE1CPUAJ0eBc8wBNjJPI6doOxVm9FwzlFS+/CHCFibn6rhtI8B1b97+VGTeqoVWCLRGb5kKibfW9LCKA1mPr3HJouUBV1eC9vsu8b7asvET1zbNhNdLIaS6+TnWLed1bFBX+MLn+j63Pmy851SzgZcgNyK1IwOPwnpCOYwSO3lbVI7ZI9SQVYlFG62KMkSNxNhekMWZ6Md4mpGjD+dk9jKBa3ZAwRxzIjIVspy3/Bdz8T1liojafar7VZUrag/QjXB/WxwjfG3T6XfYbgUYU3g9eXHs2j49R5P3y4rVvqzM68Sv1G3Ib+Yq3nUS9T2drqTpxdUXSMpvt1IlJMIgnZt93SribRktN7bwx0MzbXDvmBnhI8+WmkIDS2nTS3LRKjRVKdi4ifXFT0yO+nzGCPMLP02hVqCZLFiHRuiImQN6EubPaglTioUMBizkH548OuLjntkmKHk1zclH8x6PuCC9bBNul+1ddQkwU4603S3KDVWl3ka94CJJ+7/tO+tahusoxIMBRZpMSPKbkofdk+WhHr+tICc4fskrcfY8Qr6tZ3jDxYtIY6P8XGhczAkG//PWVVtpXctRucbDHQsFiLgd0EWBYCQ01pZHnZZw5RMw0K1g0VgeUf22lCXCMpFUtDDpx7ljVUsTXVouLK2Ct+pRhVjlNXPcXU1k041sbt9OVIdL8kH+t4M4aD65jg5tjZBx2YP4l3HAq4v9qB664yVWOx 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)(376002)(136003)(346002)(39860400002)(396003)(36840700001)(46966006)(40470700004)(81166007)(47076005)(26005)(82740400003)(426003)(336012)(2616005)(41300700001)(33964004)(235185007)(82310400005)(40480700001)(186003)(40460700003)(86362001)(478600001)(84970400001)(4326008)(6916009)(8676002)(5660300002)(316002)(70206006)(54906003)(70586007)(36860700001)(36756003)(83380400001)(2906002)(8936002)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:29:21.2609 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2ca6f592-d93e-46da-fe2a-08da7c776dec 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: AM7EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0801MB1942 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740969836649210447?= X-GMAIL-MSGID: =?utf-8?q?1740969836649210447?= This patch implements target feature macros when PACBTI is enabled through the -march option or -mbranch-protection. The target feature macros __ARM_FEATURE_PAC_DEFAULT and __ARM_FEATURE_BTI_DEFAULT are specified in ARM ACLE __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI are specified in the pull-request . Approved here . gcc/ * config/arm/arm-c.c (arm_cpu_builtins): Define __ARM_FEATURE_BTI_DEFAULT, __ARM_FEATURE_PAC_DEFAULT, __ARM_FEATURE_PAUTH and __ARM_FEATURE_BTI. gcc/testsuite/ * lib/target-supports.exp (check_effective_target_mbranch_protection_ok): New function. * gcc.target/arm/acle/pacbti-m-predef-2.c: New test. * gcc.target/arm/acle/pacbti-m-predef-4.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-5.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-8.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-9.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-10.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-11.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-12.c: Likewise. Co-Authored-By: Tejas Belagod diff --git a/gcc/config/arm/arm-c.cc b/gcc/config/arm/arm-c.cc index a8697b8c62f..190099b2c37 100644 --- a/gcc/config/arm/arm-c.cc +++ b/gcc/config/arm/arm-c.cc @@ -212,6 +212,24 @@ arm_cpu_builtins (struct cpp_reader* pfile) def_or_undef_macro (pfile, "__ARM_FEATURE_COMPLEX", TARGET_COMPLEX); def_or_undef_macro (pfile, "__ARM_32BIT_STATE", TARGET_32BIT); + def_or_undef_macro (pfile, "__ARM_FEATURE_PAUTH", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI", TARGET_HAVE_PACBTI); + def_or_undef_macro (pfile, "__ARM_FEATURE_BTI_DEFAULT", + aarch_enable_bti == 1); + + cpp_undef (pfile, "__ARM_FEATURE_PAC_DEFAULT"); + if (aarch_ra_sign_scope != AARCH_FUNCTION_NONE) + { + unsigned int pac = 1; + + gcc_assert (aarch_ra_sign_key == AARCH_KEY_A); + + if (aarch_ra_sign_scope == AARCH_FUNCTION_ALL) + pac |= 0x4; + + builtin_define_with_int_value ("__ARM_FEATURE_PAC_DEFAULT", pac); + } + cpp_undef (pfile, "__ARM_FEATURE_MVE"); if (TARGET_HAVE_MVE && TARGET_HAVE_MVE_FLOAT) { diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c new file mode 100644 index 00000000000..52d18238109 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-10.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti+pac-ret -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c new file mode 100644 index 00000000000..9f2711097ac --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-11.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" "-mfloat-abi=*" } } */ +/* { dg-options "-march=armv8.1-m.main+pacbti" } */ + +#if (__ARM_FEATURE_BTI != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAUTH != 1) +#error "Feature test macro __ARM_FEATURE__PAUTH should be defined to 1." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c new file mode 100644 index 00000000000..db40b17c3b0 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-12.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8-m.main+fp -mfloat-abi=softfp" } */ + +#if defined (__ARM_FEATURE_BTI) +#error "Feature test macro __ARM_FEATURE_BTI should not be defined." +#endif + +#if defined (__ARM_FEATURE_PAUTH) +#error "Feature test macro __ARM_FEATURE_PAUTH should not be defined." +#endif diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c new file mode 100644 index 00000000000..cd418ce0c7f --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-2.c @@ -0,0 +1,24 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=bti+pac-ret+leaf -mthumb -mfloat-abi=hard" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 5) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c new file mode 100644 index 00000000000..ce4b45ab464 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-4.c @@ -0,0 +1,20 @@ +/* { dg-do run } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard" } */ + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +int +main() +{ + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c new file mode 100644 index 00000000000..6d48b7c31a5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-5.c @@ -0,0 +1,25 @@ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-skip-if "do not override march" { *-*-* } { "-march=*" } { "-march=armv8.1-m.main" } } */ +/* { dg-additional-options "-march=armv8.1-m.main -mbranch-protection=bti+pac-ret" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +int +main() +{ + if (__ARM_FEATURE_BTI_DEFAULT != 1) + __builtin_abort (); + + if (__ARM_FEATURE_PAC_DEFAULT != 1) + __builtin_abort (); + + return 0; +} diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c new file mode 100644 index 00000000000..3538c186397 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-8.c @@ -0,0 +1,12 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti+pac-ret+leaf -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_BTI_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined to 1." +#endif + +#if (__ARM_FEATURE_PAC_DEFAULT != 5) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 5." +#endif + diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c new file mode 100644 index 00000000000..27c1c8f521c --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-9.c @@ -0,0 +1,11 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret -mfloat-abi=hard" } */ + +#if (__ARM_FEATURE_PAC_DEFAULT != 1) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined to 1." +#endif + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif diff --git a/gcc/testsuite/lib/target-supports.exp b/gcc/testsuite/lib/target-supports.exp index aa828bd3a07..c98cb1c8303 100644 --- a/gcc/testsuite/lib/target-supports.exp +++ b/gcc/testsuite/lib/target-supports.exp @@ -5090,6 +5090,16 @@ proc check_effective_target_arm_cmse_clear_ok {} { } "-mcmse"]; } +# Return 1 if this is an ARM target supporting +# -mbranch-protection=standard, 0 otherwise. + +proc check_effective_target_mbranch_protection_ok {} { + + return [check_no_compiler_messages mbranch_protection_ok object { + int main (void) { return 0; } + } "-mbranch-protection=standard"] +} + # Return 1 if the target supports executing PACBTI instructions, 0 # otherwise. From patchwork Fri Aug 12 15:29:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 502 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp945890pxh; Fri, 12 Aug 2022 08:31:14 -0700 (PDT) X-Google-Smtp-Source: AA6agR45r6nZqeBz/kDTX90GfFQfpnaCaYbKXYVmq8BIC37v0waYssgDSDacoWa3eEeEw9j7neIH X-Received: by 2002:a17:906:53c7:b0:711:d2e9:99d4 with SMTP id p7-20020a17090653c700b00711d2e999d4mr2988320ejo.716.1660318274170; Fri, 12 Aug 2022 08:31:14 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id q14-20020a056402518e00b0043d84f9413dsi2615893edd.604.2022.08.12.08.31.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:31:14 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="O9JJ4U3/"; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0B7FE3858288 for ; Fri, 12 Aug 2022 15:31:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0B7FE3858288 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318273; bh=5tCAZOhg7PY7j+opIRtabGB+kps1BjOEdxhhr6CDoGE=; 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=O9JJ4U3/viFueSvm8db7iM+WV+DB86RRE7aoPk4WvW8SopLGN6auZhFp6mnGvb9Au UqDktDMXBepST/O5BvzK37VSYgGm98go6eVLJ3XNZOTMVo+F/t8xrsL4qvPw3BLCda 1mRbzN0N5UIsX7yNRpdzTfyZv+pQA59qwhLy30/s= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70040.outbound.protection.outlook.com [40.107.7.40]) by sourceware.org (Postfix) with ESMTPS id 692E83856DE2 for ; Fri, 12 Aug 2022 15:30:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 692E83856DE2 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Cl+8aSppNKSK/+Uzla/tcKrBG3SoMd9rCYedyUwRpvE5MujrIWz/DaivFGOrtv9xmWNr6Jl9HTWxYZwPqwnn3S0buwN7yU55g4zZGJDHRMCOf8ad2uz4MuyKLKh6TIEbY+LSnrobVzGWGJrBXxQGBL0EejaDuNn5r4jZfXxMStzmbMBilfhJfIFXlag6DAv9AjnFBibPZ5Id9+omn75gQm2OVrOUS+HRtVipX8+/REbc9DEDYxeyTFzZMc9g+vDTdy998DGVq7yo49sSjGozShZugOcoby1HZLl/83oHnJr+/O3DsVb9RP9zG62/fV2hZqAebpOEZjxZf8B+lyh04A== 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=5tCAZOhg7PY7j+opIRtabGB+kps1BjOEdxhhr6CDoGE=; b=OA+N7OD4j4inKCV4d90y6fF37Zqtnaf3nfxIu+xF5S+CT/4HlFAzZcca8INKHvMBzOFBqKXdm0dcJsb7qht4FgQS7IHWyDoUwgb5R4ZO5Zf0SScOFSuB0oC8Q2mL/+ec3fAK97o4LODTySDQJQGnFj/Ih9BbN2KAf1PZfzzXllM7HGyzUmqLqBdJvaeIad/4L0Fnyg+Rby4gtNCkHqdqNNONjhalTFfCC8W6F33CyT4ZWXqBQhwQUx/nu5fahdmy0vko7D/2ugHAf1g2L2Rl7c5i0GoPjzSKelps/ZT4GnmMCiQsA2nNy8DTMsheTKSuPy+JcOXsJvEgdRDDiGAehQ== 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 DB6PR0202CA0037.eurprd02.prod.outlook.com (2603:10a6:4:a5::23) by DU0PR08MB8188.eurprd08.prod.outlook.com (2603:10a6:10:3ef::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.22; Fri, 12 Aug 2022 15:30:06 +0000 Received: from DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:a5:cafe::7e) by DB6PR0202CA0037.outlook.office365.com (2603:10a6:4:a5::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:30:06 +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 DBAEUR03FT032.mail.protection.outlook.com (100.127.142.185) 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:30:05 +0000 Received: ("Tessian outbound cc6a8ab50b6b:v123"); Fri, 12 Aug 2022 15:30:05 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fe43483ec824cb73 X-CR-MTA-TID: 64aa7808 Received: from 9fd66949e87d.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 28DC5B3D-AB5E-463F-BB79-1F5E7CEF8E7A.1; Fri, 12 Aug 2022 15:29:58 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 9fd66949e87d.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:29:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=du52iERwLOlTk86wlA7usvgY4/iWx6xYVbr6a9mqZc75nPmmOcoYhOYhoLsv4q2UbRzddVIDD/r8v6kHpM8r7tjdBXdPbmEY9OQ3Xle9bEBJn4+VhQ3bcchLmRJWEsT5BsDu1mpmFw2OPLVf9dyD+dG95r38GsrBx1HhTw2RSKp45pK5yw4sgmZEovGmTr5Tk5uUrJ7+O/494ifl9Bj0b7ZiyaZioXYPqzb95E2Z0ek6ArytBjlT7ZmjSZYyHMeyp7DYqSORE7JySRwigrfJz5bw8+cftgup3lFbSXfdczTzLzYVc14mh6qwrUUISQTLfpoHSmkZCFjhHjse0mthiA== 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=5tCAZOhg7PY7j+opIRtabGB+kps1BjOEdxhhr6CDoGE=; b=HIScHSvkbrTIk3HfmG54F2ws6KwGpa+bgHtixcCVJqWCYUgWCg60T+0yeZB3LmxPll/3WdQS3ARw5P9tBquPnhbw4xwPsiIKbBVAshAA4cYBnUkummBwfONUFOO0kXQvZ2UJ+HGXV2Kt2r+SzVsPQq+DBLXZvGhjf71rywTKN32vnq7dzDLXN/axTE6X4foiSf37tvRHkQ+HJXznlYJRuzh/cwyT6xsemYyE8wYFMpxhS5CBbYCtTMmmgyO3s607JBp+W8/f9XO9RQrehD407aCSRT2Ju15G/Nd/nHFBjqY+j4gDh0dk80bCVcgGB02ZCNpnSAiUEx3gGnwgcU1Kxw== 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 DB6PR07CA0110.eurprd07.prod.outlook.com (2603:10a6:6:2c::24) by VE1PR08MB5119.eurprd08.prod.outlook.com (2603:10a6:803:114::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 12 Aug 2022 15:29:56 +0000 Received: from DBAEUR03FT059.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:2c:cafe::8f) by DB6PR07CA0110.outlook.office365.com (2603:10a6:6:2c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:29:56 +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 DBAEUR03FT059.mail.protection.outlook.com (100.127.142.102) 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:29:56 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:29:56 +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:29:55 +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:29:55 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 6/15] arm: Add pointer authentication for stack-unwinding runtime References: Date: Fri, 12 Aug 2022 17:29:55 +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: b3cd3562-d155-4792-548a-08da7c778886 X-MS-TrafficTypeDiagnostic: VE1PR08MB5119:EE_|DBAEUR03FT032:EE_|DU0PR08MB8188: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: c41NLzZ5WkikYvBrS1OjJ0V94Crj/5tcMOuKepBf2z2Zv2FGog4YV56IdtCCQ5ewyEDElBzSqLSWxo9piVMvScgvoSubZsuWVvhJBrHwjb1lYCmq/7Jb9Av8KaNNmAr5cXR0FZ/GcAYU0QZiMl6icvVwWtr2AqzMwcFUNO2KzL+WrQlmgdn4Mn8ZbBCG1EEf5D/ztANMLV5v4sUf71XFwl2PG3IkeD4OaK8PGUPkgtr9V2FjXj4UtQXs7cyqX7pbdAOB457X1GmcaK8IllH7vNci37zupAo/kzB7x3WY82+m+fHC3oFw1ymKV++UJRDypgWT2bimWfhhXwcc7sLcO6S/tlj5+4Ismxdo4YRIttXEKtMcGcrbX+pQp7x5T29sBi90ioo57MHh7/yfZCjp4w9YnkrL4y8ie2GeSnxMRRsLx+rGusVaCQR95L54EZtpzErnXjV3lvvDSPhJWGzZ7TTncBmJ2gglDIPevWvS1ZH9UlB6cTA9vpg/bsTazElt7d3Bz7mZIfEhKuO4oiprLT0iEAjeX563I9dtUzq6xBt3w/QO2GF6c6LM8Ft45CHqmAPG13YgGGnu305N7zqXa/OSEFEy+WU0a+E1q7AKMX0wHPZWqhqfcflj7Y9vmjeC3PaMWvRG/DNgzYQMrjcfw7csgh0Sx5/RlyQqBeYtNuz9rKOQrb1fTCDXIh8ozAROdm3Nl2WJyKuzMKJV3x3DJ3tWs/eE2WA8b24crKk5vQTghO8SYnpjOhP9Hi3hfyy7CKl7hyBNPQL7LDjHMPE/ODahBd/21UWdAsUz8J8KoZLa3ejuHcxW7kYCPaBqTWKdrxHMR52m0fyLyhCWs/daC2Za5ZmLt0y6pkvqt1aBxDtkU1cf/7Xc7WyZhiVv8039 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)(376002)(39860400002)(396003)(136003)(346002)(46966006)(36840700001)(40470700004)(81166007)(86362001)(70206006)(82740400003)(316002)(82310400005)(47076005)(356005)(36860700001)(186003)(70586007)(83380400001)(426003)(336012)(40460700003)(41300700001)(2616005)(33964004)(40480700001)(8936002)(5660300002)(235185007)(26005)(478600001)(6916009)(8676002)(36756003)(4326008)(54906003)(2906002)(44832011)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: tEXJZO+uzMzCx1treU2to/2oCpzvlTZjQUFKxDtv4x+YeH8ey/3YRtgroOM9KHdKGFd8tsoJljKNuT+DTCaeqLwaNkaT+XXSC79TW2maESw1JaGuS0BRTsx2YdhM65A114GhyQxoBjaIZnTMQ6HEfEsBzQSzNiLC4cBYt+b+MyckDjDRHW8wnfB1SQewdgwohUIHh5iQX35aJkS4Vx+ua5U70mtxmSB6FY9gUeKBQJyNlu1A8ctgfvyrw37qIU+EC0IRp3XMI2ERbTV/ZT/DnLavEwOJJN6SnGiJnh6mjSBy7rkGDtVpZWkHFDixOadrBpg1yldrdYHgKi1p4E1RNmznWbfzeBjAvcMN/DNwel0FG3tDTVz7+X6LJ41L4Vw5neS3fp1eQHpyWZEeEtP3ppGN1rT41xDD0ne2C/qPMfZagRgwGmGAm+mtnj+6Jyobtd5FwANi/9WgRbo6Fs624JrBCkhjc/p6R9il6QvUO0sVyzUcH6HWpXxJ7yCpTMAhyYBSCIWqKRfHMCHXN3FqYLEK6MERnzjVHYoZkOghIcG9xQe8i68heNilbPOhNLVgevLUs0rf+BRQVWkKCI0M1xXT8MWAlSh5qQ/KVz9DLJPUewq/xYvgItK6SASpaY8wFdOPi+C3F3MzTNo5mNGWULSWVyA44izRxGh1anDlJf2MGKN1oDWmWHhAoVo68ENRDbcYvO9+qfT2aD2ZDerJVQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VE1PR08MB5119 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 699e465f-01ee-49cc-4f81-08da7c7782e9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qwmECnG5RKA4XcTVXTig1Rpi5nXYEzJOgKnHVVpxc0nuyjk/YaZGJ6SY572QB/Fzk7JmWeMQ9TDs4rZECGX9NffWAafqNqH8rSIAoESk/DxDVLyy9V3QL6ZzcWe/gPyoRM6AI2Cw+FpGnRV4iQmdXex9N0MsomDTw/l3b5UnH5XsD9oa3QitcDVCoP3XNtvOUqzH/0swCZK348Lcn/Yy4FazqN3z5evHLqlMlFBGakk0SjxxEx3sP5BThewiUB3OBCfVSv6FeS9T0KQ4KT5/8QQFoY/ksF6ExYZaro7DX0pvQwliS1SvyvK30sRHFhevnkFeW95IueGN/EjhvG+vVGJa059uMd2lDIWAaDK9/Dp3AervCncldP1LUEXM1nj7HMqesAutfgmPtvEFRzu+bF//aeuBiyZmQ8b57TpPuynR7Fpm/D3iycxnacfch1kYerin4tQ/mGt5CjltQo+lI1VrAXbURdjrPcIYoYsal7sDeAUyYXJ6CtddxnckwfvAjZZ5m5QzVFE0FRuGXuLc2Fa/evkw4c0aaZ3xSL2yDUk+SavKhWFJpf5KnETvzSBDEkBo/lHMvU7f/hMWbFCg4RsD/DbqzP/8V1VPvkUoNwL+sRNFZ65O9Be/d8KbQr6VIjyCoJwtUybjojwXctPYu5yNdQ2CdNegp+wCDKVjJJEP8JomIzNdEh8hlh3Oae59OlIw5if7uXkoWQinlDOOD0AR5dTlFka/EZXAD1qRT4ubH5EuxbL0+KHYXAKSNtJvhPcwOOYm5XqPd9saQBormfaePfghIxFwn7YU6zGyqgqz3Ba4Yk1mHDsgAwwIAiWKX6vf8Tsj2UZUqqQYVRxPKQ== 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)(346002)(136003)(396003)(376002)(39860400002)(40470700004)(46966006)(36840700001)(86362001)(44832011)(8936002)(2906002)(235185007)(5660300002)(40460700003)(33964004)(8676002)(316002)(54906003)(70206006)(70586007)(82310400005)(36756003)(40480700001)(6916009)(81166007)(478600001)(82740400003)(4326008)(36860700001)(26005)(83380400001)(336012)(41300700001)(186003)(426003)(47076005)(2616005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:30:05.9803 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b3cd3562-d155-4792-548a-08da7c778886 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: DBAEUR03FT032.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB8188 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740969894957420870?= X-GMAIL-MSGID: =?utf-8?q?1740969894957420870?= Hi all, this patch adds authentication for when the stack is unwound when an exception is taken. All the changes here are done to the runtime code in libgcc's unwinder code for Arm target. All the changes are guarded under defined (__ARM_FEATURE_PAC_DEFAULT) and activated only if the +pacbti feature is switched on for the architecture. This means that switching on the target feature via -march or -mcpu is sufficient and -mbranch-protection need not be enabled. This ensures that the unwinder is authenticated only if the PACBTI instructions are available in the non-NOP space as it uses AUTG. Just generating PAC/AUT instructions using -mbranch-protection will not enable authentication on the unwinder. Arroved here: gcc/ChangeLog: * ginclude/unwind-arm-common.h (_Unwind_VRS_RegClass): Introduce new pseudo register class _UVRSC_PAC. * libgcc/config/arm/pr-support.c (__gnu_unwind_execute): Decode exception opcode (0xb4) for saving RA_AUTH_CODE and authenticate with AUTG if found. * libgcc/config/arm/unwind-arm.c (struct pseudo_regs): New. (phase1_vrs): Introduce new field to store pseudo-reg state. (phase2_vrs): Likewise. (_Unwind_VRS_Get): Load pseudo register state from virtual reg set. (_Unwind_VRS_Set): Store pseudo register state to virtual reg set. (_Unwind_VRS_Pop): Load pseudo register value from stack into VRS. Co-Authored-By: Tejas Belagod diff --git a/gcc/ginclude/unwind-arm-common.h b/gcc/ginclude/unwind-arm-common.h index d3831f6c60a..f26702e8c6c 100644 --- a/gcc/ginclude/unwind-arm-common.h +++ b/gcc/ginclude/unwind-arm-common.h @@ -127,7 +127,8 @@ extern "C" { _UVRSC_VFP = 1, /* vfp */ _UVRSC_FPA = 2, /* fpa */ _UVRSC_WMMXD = 3, /* Intel WMMX data register */ - _UVRSC_WMMXC = 4 /* Intel WMMX control register */ + _UVRSC_WMMXC = 4, /* Intel WMMX control register */ + _UVRSC_PAC = 5 /* Armv8.1-M Mainline PAC/AUTH pseudo-register */ } _Unwind_VRS_RegClass; diff --git a/libgcc/config/arm/pr-support.c b/libgcc/config/arm/pr-support.c index 2de96c2a447..e48854587c6 100644 --- a/libgcc/config/arm/pr-support.c +++ b/libgcc/config/arm/pr-support.c @@ -106,6 +106,7 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) { _uw op; int set_pc; + int set_pac = 0; _uw reg; set_pc = 0; @@ -114,6 +115,27 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) op = next_unwind_byte (uws); if (op == CODE_FINISH) { + /* When we reach end, we have to authenticate R12 we just popped + earlier. + + Note: while the check provides additional security against a + corrupted unwind chain, it isn't essential for correct unwinding + of an uncorrupted chain. */ +#if defined(TARGET_HAVE_PACBTI) + if (set_pac) + { + _uw sp; + _uw lr; + _uw pac; + _Unwind_VRS_Get (context, _UVRSC_CORE, R_SP, _UVRSD_UINT32, &sp); + _Unwind_VRS_Get (context, _UVRSC_CORE, R_LR, _UVRSD_UINT32, &lr); + _Unwind_VRS_Get (context, _UVRSC_PAC, R_IP, + _UVRSD_UINT32, &pac); + __asm__ __volatile__ + ("autg %0, %1, %2" : : "r"(pac), "r"(lr), "r"(sp) :); + } +#endif + /* If we haven't already set pc then copy it from lr. */ if (!set_pc) { @@ -227,6 +249,16 @@ __gnu_unwind_execute (_Unwind_Context * context, __gnu_unwind_state * uws) return _URC_FAILURE; continue; } + /* Pop PAC off the stack into VRS pseudo.pac. */ + if (op == 0xb4) + { + if (_Unwind_VRS_Pop (context, _UVRSC_PAC, 0, _UVRSD_UINT32) + != _UVRSR_OK) + return _URC_FAILURE; + set_pac = 1; + continue; + } + if ((op & 0xfc) == 0xb4) /* Obsolete FPA. */ return _URC_FAILURE; diff --git a/libgcc/config/arm/unwind-arm.c b/libgcc/config/arm/unwind-arm.c index 386406564af..89f945d047e 100644 --- a/libgcc/config/arm/unwind-arm.c +++ b/libgcc/config/arm/unwind-arm.c @@ -64,6 +64,12 @@ struct wmmxc_regs _uw wc[4]; }; +/* Holds value of pseudo registers eg. PAC. */ +struct pseudo_regs +{ + _uw pac; +}; + /* The ABI specifies that the unwind routines may only use core registers, except when actually manipulating coprocessor state. This allows us to write one implementation that works on all platforms by @@ -78,6 +84,9 @@ typedef struct /* The first fields must be the same as a phase2_vrs. */ _uw demand_save_flags; struct core_regs core; + /* Armv8.1-M Mainline PAC/AUTH values. This field should be in the same field + order as phase2_vrs. */ + struct pseudo_regs pseudo; _uw prev_sp; /* Only valid during forced unwinding. */ struct vfp_regs vfp; struct vfpv3_regs vfp_regs_16_to_31; @@ -99,6 +108,7 @@ typedef struct { _uw demand_save_flags; struct core_regs core; + struct pseudo_regs pac; } phase2_vrs; /* Coprocessor register state manipulation functions. */ @@ -175,6 +185,10 @@ _Unwind_VRS_Result _Unwind_VRS_Get (_Unwind_Context *context, case _UVRSC_WMMXC: return _UVRSR_NOT_IMPLEMENTED; + case _UVRSC_PAC: + *(_uw *) valuep = vrs->pseudo.pac; + return _UVRSR_OK; + default: return _UVRSR_FAILED; } @@ -206,6 +220,10 @@ _Unwind_VRS_Result _Unwind_VRS_Set (_Unwind_Context *context, case _UVRSC_WMMXC: return _UVRSR_NOT_IMPLEMENTED; + case _UVRSC_PAC: + vrs->pseudo.pac = *(_uw *) valuep; + return _UVRSR_OK; + default: return _UVRSR_FAILED; } @@ -246,6 +264,14 @@ _Unwind_VRS_Result _Unwind_VRS_Pop (_Unwind_Context *context, } return _UVRSR_OK; + case _UVRSC_PAC: + { + if (discriminator != 0) + return _UVRSR_FAILED; + vrs->pseudo.pac = *(_uw *) vrs->core.r[R_SP]; + return _UVRSR_OK; + } + case _UVRSC_VFP: { _uw start = discriminator >> 16; From patchwork Fri Aug 12 15:30:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 503 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp946426pxh; Fri, 12 Aug 2022 08:32:01 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+ArTNEIvsbjcJhajAWZQf6KQagPiyjHJJyhakdo0kNZZBIVq2K5P4IFctONlFILv6WFcz X-Received: by 2002:a17:907:3f95:b0:733:1e1f:d75c with SMTP id hr21-20020a1709073f9500b007331e1fd75cmr3046399ejc.727.1660318321147; Fri, 12 Aug 2022 08:32:01 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id v23-20020a1709061dd700b00722e7756f3dsi1937354ejh.462.2022.08.12.08.32.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:32:01 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=hD7sMLaE; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 64B06385828F for ; Fri, 12 Aug 2022 15:31:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 64B06385828F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318319; bh=xziHA/uwH77taf8TsCrs1k+DwYqa8Rpwu4TQHpEQFH0=; 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=hD7sMLaE7SumDinClGDAJqbnISif8i1lHw83ANZ1HkPpC7GxaiA3zuJIwPOt+luDq z6vsQ/67qlzfFKe/roVa8BBN7x3zHvVZjwDMlghGlUF6vVqTnkswSGZvTr1n3aj1SX G7b8Z48e3TqmUEKQcr13KpRCly61sTmOCc7PGJSg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70074.outbound.protection.outlook.com [40.107.7.74]) by sourceware.org (Postfix) with ESMTPS id D904B3858427 for ; Fri, 12 Aug 2022 15:31:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D904B3858427 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=b5EeYEmNfVakFHZi6QbjQxzMUreqFMpGjSZ41fKoWubg6F6MeFjNfDGaZSBvKBScXc8+RbbJBOc8+OXof5rpWftMgOn0KSO3zXWmFvVLpNeOv/gfx7+O7q8GdgCvOC/TRrYAePq5Se0C24tqVETTWjc0qtYtCODxAZ439zKHxtiNDtnx+4ec881PTJ8QMWPomCsts4StM3MA7rWy2Pe9GrBs1eJx50x8T0ErJE4jcqRe4TC7qa5pXdVe5ZuFrQJaHxIL+ijzQDEG62AahSofKa2Tr3+BteGQdmH/58cya7g9tg7k4urNEoffnJ2oNwiSZk6iWYKfZsIKCE3i5+4Z5w== 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=xziHA/uwH77taf8TsCrs1k+DwYqa8Rpwu4TQHpEQFH0=; b=cZX17wc45MVzqBkQqdYvtW8ellKCONnacPrhkanVwsMO47uguEkIV2PS99MZm4CXtsWBE86LXAMKWcoc1tgteSr51MCX4Uyg1SlnJhjIBi9CpHdaFX69D+BKJWhPiCe1lwrJQWGzWMDLWQsuCbHhNfZIxYc+oi8rrE68yITgkNYkD5GcdI4pjx0FyjS+We/p3l9I+G4CCf03jtbod2e3UoXUCO3P/Y4IEO6+Me/q95acZmZzF1JMsjPAztJ99krhn2gCF/aWNXiNuwI2GtjJpPemfnLhRFce1fLbFvoOmlHpWz/nFAfMKf0XefnsrVQ+Dlr3fjXOi40IK8US0sEAHQ== 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 AM6P193CA0085.EURP193.PROD.OUTLOOK.COM (2603:10a6:209:88::26) by GVXPR08MB7678.eurprd08.prod.outlook.com (2603:10a6:150:3e::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.25; Fri, 12 Aug 2022 15:31:08 +0000 Received: from AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:209:88:cafe::73) by AM6P193CA0085.outlook.office365.com (2603:10a6:209:88::26) 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:31:08 +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 AM7EUR03FT041.mail.protection.outlook.com (100.127.140.233) 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:31:08 +0000 Received: ("Tessian outbound fa99bf31ee7d:v123"); Fri, 12 Aug 2022 15:31:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 1d23035e3b690094 X-CR-MTA-TID: 64aa7808 Received: from f685b892a2f6.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5FD99732-63F6-4926-81CB-46E1180175C7.1; Fri, 12 Aug 2022 15:31:01 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f685b892a2f6.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:31:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=e87g7Apye8ldurQ998vpvWY+J12dGcmR+4ydfhbLWpF69yClaHYE9FnjyrB6a+S9Iwr971LNUhOJNIhixuAeD9AymZK3/mR0zgNxE4HmLjde+8or27F8p1QElM3ZPMk8dMB7YGXmeX9q9uwuBARZnwX04PMZFGoOb4h6y6W6lrRgV42r+hEqzAzOPTaxASZRHlYeVj5AMV7+0kOgN6rQ78AmxevqVMib940zROAyrj9H6xIs0TpGLKt+K/DU3zD4PRmLIDylKbXrW3e+qPgKVycrenltaVvXUdxh3Mg/THxdxQFfCAC1odkXBOA/nej+9UVyca24Xa6CzzyEJN0maA== 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=xziHA/uwH77taf8TsCrs1k+DwYqa8Rpwu4TQHpEQFH0=; b=bb6KFN7OpIWxgU12b7Y0ozjNEgoCCK9RCYCqZygZjcbdzGp3BBH9qr1X2jGXp5eAq9UavJ0LyrfNs4/eulAwR8EJ0j1G/xqp34tgUoTGfzMk35fErEd7ulbehlqdoV4AHXkVghEbnDn4y2JcSEeG393dG8eI6p3GuGiOe8U3iPPfVYlFGi1apX0yytjkSASWFtVXDgK1Q+DT9XQf7/SaIpt29etMTe9HexIohzIYmr67A2lTbu1nLHF20Ldl1vapFkdyhxfVM8WGpZlEk+f4SV95zzQTzl8ex27WeeY8i2kLB12QUYdTQx4GRAtWWGLtSDQyR5izuGpzt/CXl5WTEQ== 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 DB8PR06CA0040.eurprd06.prod.outlook.com (2603:10a6:10:120::14) by AM6PR08MB5032.eurprd08.prod.outlook.com (2603:10a6:20b:ea::20) 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:30:58 +0000 Received: from DBAEUR03FT014.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:120:cafe::9b) by DB8PR06CA0040.outlook.office365.com (2603:10a6:10:120::14) 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:30:58 +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 DBAEUR03FT014.mail.protection.outlook.com (100.127.143.22) 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:30:58 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:30:57 +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:30:57 +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:30:57 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 7/15] arm: Emit build attributes for PACBTI target feature References: Date: Fri, 12 Aug 2022 17:30:56 +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: 09570720-cfcf-4df7-3131-08da7c77adc3 X-MS-TrafficTypeDiagnostic: AM6PR08MB5032:EE_|AM7EUR03FT041:EE_|GVXPR08MB7678: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: mdwZX4G2WGN6WqHyjoccJUJR3d1iOQTBKZUzD0HVhyseylrU3hMS+qCKvn6SKotPKlAq9mfFNKFzGssg/mgjn71BxdOnikOCkz5wutQkEfry23WHCggg3wUWUWusF8dfTdUobKWdF3VU+pc+i9HQNArSPIpRXcsRvN2fG+8cmpMEXXUIMS9Vs5GpEdFIsVxgfNpO1ZcErjftTDtWW0MH1bWRH7PEBnPpW+LuDYSw2YXFI2d6/P5JZCJUxWEri9YaHyIZi8p1cbBwlPWq3RTmjjLe8dlzYnAbXyIhYbsMOEaO9q/9tkK8ARmQ5AONe+PLekgRsVjfyiCUp/IE8jEDBub20OEatbfYAnn67XKfPK8so83hioYfFGy14lJbCC/mv8HXd5Cy3tic9WHLqT78wXxP4zasXortCEPd/wBqN35NKF7qTSuB/Qsaoic4uX9t1DIb4AHeJCPqmemMDi+9Dc9AfjrKT6/Q8UpC2ApVRsTAJ0l0kLdHJRQNpUmKVRMIG21DQMiSyGiWmnxgSzE61g/cdUgpRU0VnSlB+m06inXhy3gK0a9pgZiZp+awC9TM7Dvyh4ABEH9DVaMJO0CFk/BKUg4bJ/tHZa1H7+YeN5XsIyFDOEXbov09xBeMn/Fi4LXkuisbkz/asRuFXkZKXnpHUgrz3sECDovjmgYhzwJ+n6EVkoQY2iX/8WxEwI7XKAee0jj9s6W++D4yoC/9mMUpvSpSI1pUkuxiNMal/IV4ttWmE7IguRXzpuqNaf/aNgGvlakqIJkHjtGtHZL8S9sbtypVWlQkfZAkOVsN2xE= 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)(136003)(39860400002)(346002)(396003)(376002)(36840700001)(40470700004)(46966006)(40460700003)(36860700001)(41300700001)(47076005)(2616005)(83380400001)(426003)(82740400003)(44832011)(2906002)(82310400005)(478600001)(36756003)(86362001)(235185007)(5660300002)(84970400001)(70206006)(40480700001)(356005)(8936002)(336012)(54906003)(6916009)(316002)(186003)(70586007)(4326008)(8676002)(81166007)(33964004)(26005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB5032 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 109310a4-3697-4647-e45c-08da7c77a7b9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: fNhOm7bBZj8IUcdCzK8RYOFSJ8kGld6CY2fQnPaoza7xOWR86Fh2j2k1VT1oqVPxZVcswriGwCmNzlHP/GPfZq1BhocM51uFIGocqkSe6tlDX21jbpaISn57RvHMYqgHhLcM8YOumJRANRnh7yifqpAfoHaMOe3DQFxzYB7Z0iiXIkuXq0V6nrvovc83J5c3mjDlAdWsvjbstfkEY9nfU4F9F5vKqNnbfGL0amY0Mggb0XH8E7lPF54TQWan0tGXxxWdBmp3HWzMUdh4k5iEjjBjoCzbyTqPgI8Qf0gug6Vg0sqOF/Up1lgVkerrlj3sydJjFsKSVxUqzUMMzxIwIfMopbBHKQWmKP9o5glL7mj+ZLebxZjBBNXR1bIfNxD03yB/TikJs8ynxnCBgeq/OPFXa8SslRBxlMlSRi7KzJRtkaFFj9Qj9IUQfXEOJ32JSpyuXbwmVLxJnon0ZtFBhoFvpEuObyP1f1v3kBvMS4EJxk22nkLI2+J+il0gPN8FqFFN0x/2Ne+00IFygOHR4tmC7yQCpfiEW5TYs6HRtQ+SVDzgSRoh4THRr5CTtkAACL8mLSB4bwZck96Ul6BWsbmotvX6wDP1ZYsPaXK0DJtudatNlQkWEUkGIKO8iUO4D0RHBaYYoTCzdDxKmeMKOX1smw1kbHEYTorE50EzL4V8EqZdpSW8XPkXAI3hzPkWfHhEA8YEy6i4XozQ9CAJjXxkjaB+vzbbyjj4XDDMGN4fBtRvhQNqLnO7XJSRDJl4 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)(39860400002)(376002)(136003)(346002)(40470700004)(36840700001)(46966006)(235185007)(5660300002)(44832011)(41300700001)(8936002)(36860700001)(84970400001)(40460700003)(6916009)(40480700001)(54906003)(316002)(81166007)(478600001)(86362001)(82310400005)(70206006)(70586007)(8676002)(82740400003)(4326008)(2906002)(336012)(47076005)(186003)(26005)(36756003)(83380400001)(2616005)(426003)(33964004); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:31:08.4080 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 09570720-cfcf-4df7-3131-08da7c77adc3 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: AM7EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR08MB7678 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740969943814408376?= X-GMAIL-MSGID: =?utf-8?q?1740969943814408376?= This patch emits assembler directives for PACBTI build attributes as defined by the ABI. gcc/ChangeLog: * config/arm/arm.c (arm_file_start): Emit EABI attributes for Tag_PAC_extension, Tag_BTI_extension, TAG_BTI_use, TAG_PACRET_use. gcc/testsuite/ChangeLog: * gcc.target/arm/acle/pacbti-m-predef-1.c: New test. * gcc.target/arm/acle/pacbti-m-predef-3: Likewise. * gcc.target/arm/acle/pacbti-m-predef-6.c: Likewise. * gcc.target/arm/acle/pacbti-m-predef-7.c: Likewise. Co-Authored-By: Tejas Belagod diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 0068817b0f2..ceec14f84b6 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -28349,6 +28349,8 @@ static void arm_file_start (void) { int val; + bool pac = (aarch_ra_sign_scope != AARCH_FUNCTION_NONE); + bool bti = (aarch_enable_bti == 1); arm_print_asm_arch_directives (asm_out_file, TREE_TARGET_OPTION (target_option_default_node)); @@ -28419,6 +28421,22 @@ arm_file_start (void) arm_emit_eabi_attribute ("Tag_ABI_FP_16bit_format", 38, (int) arm_fp16_format); + if (TARGET_HAVE_PACBTI) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 2); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 2); + } + else if (pac || bti) + { + arm_emit_eabi_attribute ("Tag_PAC_extension", 50, 1); + arm_emit_eabi_attribute ("Tag_BTI_extension", 52, 1); + } + + if (bti) + arm_emit_eabi_attribute ("TAG_BTI_use", 74, 1); + if (pac) + arm_emit_eabi_attribute ("TAG_PACRET_use", 76, 1); + if (arm_lang_output_object_attributes_hook) arm_lang_output_object_attributes_hook(); } diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c new file mode 100644 index 00000000000..122f7a762a7 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-1.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret+bti -mfloat-abi=hard --save-temps" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c new file mode 100644 index 00000000000..b94f3447ad9 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-3.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret+leaf -mfloat-abi=hard --save-temps" } */ + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +#if !defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be defined." +#endif + +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 74" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 76, 1" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c new file mode 100644 index 00000000000..ed52afc83c5 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-6.c @@ -0,0 +1,16 @@ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-additional-options "-march=armv8.1-m.main+fp -mbranch-protection=bti -mfloat-abi=hard --save-temps" } */ + +#if !defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be defined." +#endif + +#if defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be undefined." +#endif +/* { dg-final { scan-assembler-not "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 1" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 74, 1" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 76" } } */ diff --git a/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c new file mode 100644 index 00000000000..1b25907635e --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/acle/pacbti-m-predef-7.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-additional-options "-march=armv8.1-m.main+pacbti+fp --save-temps -mfloat-abi=hard" } */ + +#if defined (__ARM_FEATURE_BTI_DEFAULT) +#error "Feature test macro __ARM_FEATURE_BTI_DEFAULT should be undefined." +#endif + +#if defined (__ARM_FEATURE_PAC_DEFAULT) +#error "Feature test macro __ARM_FEATURE_PAC_DEFAULT should be undefined." +#endif + +/* { dg-final { scan-assembler "\.arch_extension pacbti" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 50, 2" } } */ +/* { dg-final { scan-assembler "\.eabi_attribute 52, 2" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 74" } } */ +/* { dg-final { scan-assembler-not "\.eabi_attribute 76" } } */ From patchwork Fri Aug 12 15:33:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 505 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp947680pxh; Fri, 12 Aug 2022 08:34:10 -0700 (PDT) X-Google-Smtp-Source: AA6agR4gdh2jM1Zm5BzGPLufYahwTXHJNiEaS/Cydch2Pg+ZKnvFO7qqp97/7PXVh/N5zmLYB8j3 X-Received: by 2002:a17:907:7619:b0:730:d709:a2f0 with SMTP id jx25-20020a170907761900b00730d709a2f0mr3064418ejc.673.1660318450729; Fri, 12 Aug 2022 08:34:10 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id n13-20020a05640205cd00b0043cfd7f7afdsi2369387edx.508.2022.08.12.08.34.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:34:10 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="cd/Km21M"; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 949EE385841A for ; Fri, 12 Aug 2022 15:34:09 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 949EE385841A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318449; bh=pPraAZAyHcaLKTBwTZ7QQouQ3LeFC9NmTrgmUmWdDp0=; 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=cd/Km21Mu6b1SleHUSGrKl0JPCNiNlBkv/vB0XvHPPVDedyfvg9f6lAex9qz8ELO5 9GUx3yPviMBMjWhwJErRMWQ7iOh3MLue5XLkqXglanDD6YVhe1I/pNUIK6gEQOUqPQ Mf6K4QxYycrqYwxbMBeqeohSf7p5TVZMR/XrKLsg= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-AM6-obe.outbound.protection.outlook.com (mail-am6eur05on2067.outbound.protection.outlook.com [40.107.22.67]) by sourceware.org (Postfix) with ESMTPS id 229163858D28 for ; Fri, 12 Aug 2022 15:33:24 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 229163858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=SF4Frn2mxwUBLa98OFfvjMsE05vGHl+gxjzFstEJ9tq7YiUkUHuq2VDLnIEL0ssk108Y9i3PY24UPc4qtJCK91StcvCAI97G2e8wr5tSxxDElbVqv60DKewzsT9WJgNQEcHXhMCtWI4YHMn98CJdvjAOOiNDLUU5HYS1Y8ioSLjCx8EuSY402BKXKRsSa6x/3IADZ69eUCvUgyMXu1m8234VILhB02FpqYyILXpmjvSGoin7q2qFRV9mJKBA5UALRpAp4bwGNdQj2C7XaQLjli3MBYMwHvHSEo1Zkp1rxiT9+uyNwnC/INuIGPuaYxDOkEx3MLSynogibeJAfULgWQ== 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=pPraAZAyHcaLKTBwTZ7QQouQ3LeFC9NmTrgmUmWdDp0=; b=WhTx/pBrN7q4f2/Wq+61KEoYVa9xXfTZkxSXUNc8GUiSBrUp9Xoe4260MBPdfYhyO9FiyHaXtCsSNogy0OpWT04AFVHM6w92p0tEiEKY32cc5LCCaNES03StHaTrQVFYkKNX7tUUweFHZEDePbOQfdpORKcvLa9btWy0fCCVVolbzHvv+MdyGk40EoinDmCmzp8hH114svEJtFIa39mqxGBiz+kZYrQcHWkL+xr++IF8RjETA5D1kti4eNj77Qmt/IoY4mzG8/HF8HBFNPHtfaWVzB7zTZ4557Chv8eKfCKES0jmmnSi6COb0K1zjaBQEhzspkVzD/kxNNt6Gx1Vzg== 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 AS9PR01CA0013.eurprd01.prod.exchangelabs.com (2603:10a6:20b:540::24) by AM4PR08MB2931.eurprd08.prod.outlook.com (2603:10a6:205:9::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:33:21 +0000 Received: from AM7EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:540:cafe::2b) by AS9PR01CA0013.outlook.office365.com (2603:10a6:20b:540::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14 via Frontend Transport; Fri, 12 Aug 2022 15:33:21 +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 AM7EUR03FT038.mail.protection.outlook.com (100.127.140.120) 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:33:21 +0000 Received: ("Tessian outbound 63c09d5d38ac:v123"); Fri, 12 Aug 2022 15:33:21 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c9d98248537acd76 X-CR-MTA-TID: 64aa7808 Received: from 388b98bbb559.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id C59274B8-5D5B-41C7-854D-80D45B61F5F0.1; Fri, 12 Aug 2022 15:33:15 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 388b98bbb559.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:33:15 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CtSwwjhxqi2atid3eqUKT9jAswm0kYOplc2AWjCgDlRU1FjQbiKRTwA+akXWiXqN0ADU2wK2xWEffGlb7iIUUVMhSeVqG2jnribmRIqpgfQRyCUwJ++8Q1vtKmH47bxU4SO/OznqLBsDYM3HCujBI9SKoRIdR1EHiaVsSOedyedUtkMyMqO8x2aFPzRLttXEPCnaYGngtZkRcpCTnXNr0zeMTaEkR8hJ7uNcOm4Ngc2JvWTZXjzxaajud8AH6DNHf08iolQogvL79waaZIHzCRlgp8wgYgtcW6Ejw6JkGzA+YR9jvKBTT6QQKp6wMfkgmAuqL0lCjayGqNyb+dKggw== 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=pPraAZAyHcaLKTBwTZ7QQouQ3LeFC9NmTrgmUmWdDp0=; b=g3PjfAoDnTTDjcUxUOIrTjVFrCYYTGBpR231mnOXhR+Wnt7z6aU9fzp+l1JPAx1DRJhaHMWktsjyMBz4hHj1oNqXhmXjysmJ8rHNQg4/HmDJXpseqwmrP3nnhFZbgVqORaQNwdtDftqh495P30HogEYRiJU0YQCIttszlZSIFqrAElSIcWSgD9CNfDpZV6KDkNISfR2IMO+wztw9+w2y1FBzTRMnK+iRLTTzL8ZWseQEPaoQPVQgdpRy9rGPkrvd7n9VZcmWtntl+PNjlv91sdBaZzlqng4MufqeVOqrYSfqPBV71vKCKqojOc0gUSyETzCpIep9+RTY4q9tUsPD0A== 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 DU2PR04CA0223.eurprd04.prod.outlook.com (2603:10a6:10:2b1::18) by PAXPR08MB6751.eurprd08.prod.outlook.com (2603:10a6:102:136::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Fri, 12 Aug 2022 15:33:13 +0000 Received: from DBAEUR03FT052.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:2b1:cafe::1c) by DU2PR04CA0223.outlook.office365.com (2603:10a6:10:2b1::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:33:13 +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 DBAEUR03FT052.mail.protection.outlook.com (100.127.142.144) 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:33:13 +0000 Received: from AZ-NEU-EX01.Emea.Arm.com (10.251.26.4) by AZ-NEU-EX03.Arm.com (10.251.24.31) 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:33:13 +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:33:12 +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:33:12 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 8/15] arm: Introduce multilibs for PACBTI target feature References: Date: Fri, 12 Aug 2022 17:33:12 +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: 2d4f9b96-14b7-4d77-7e29-08da7c77fd31 X-MS-TrafficTypeDiagnostic: PAXPR08MB6751:EE_|AM7EUR03FT038:EE_|AM4PR08MB2931: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: fNlVbWKZkYmO2Bfg8D98ye5MRz0Or8D73t74pmeLPSufmW7tTsg3vbld9t1ZgqwtGZSNFCtjONtwttvTBorn9rEzHG1LoujJOXDEfw/WyLtODIlIV6l7BTjOnrXvqFmvBtljfwroe73xc4UGfdaLCZ1s8mzPxQZ1Ek6gI84acsy0GOhvJLvmGXFlparORHzB6vAPD/x58U6eiTIqTFv5mSvO9Yoc/4Iu5JSdsbM3WQ7nDlsLUMMXpZo6PSpbyW933hDnIe/2LCm86HV4CVBEYzSICRNgo2+vwOffsA4782AZlV9ZmITKCha+5Y3fn56o0GAog+4YEQ2YAUXJNGzjA2GwmiaRSuENRGyDgWQOcmbijDPIWWQWqJzbq+SGxPbaRvVhXE+lNGmgrTIH6vlG+pmrXOZ8QkdMaIXXA3Nn28k/oViJYsPFPLcDjyhdVWHnRV4KoJhaZdlplcxnrqozxafq2iLNiqUBviGRSRweL6v2wjga/nz3g+f0Fte8Cwyvo+2tEB3nADllQGNh6AITFs0MLi+tJzvV0QKCwkWqNyIgEzVXcz9t4HvksAm+gEpR5YmrEwbBijvTG4IxgrnjpW09TXPn5/9lSucbzt3P+6rjA94+qiDBc3DhtIzYaPomX9xra8vEq1+j6wrKzfmxl409vhvdCIZiMJ1KAg4h5myjDShGonoPuolJTGppBa/PKMs8okQvgeOWvwpxk38/0j6aW4p7oRQvEBAC/lanvBOOB7z/xYQkDCw6IbiOL9i+Q2kxecd2dvWO0ym/4P/O7MMu0ZTYGyWafj1h9HseNUPVa7ZfXXe4J9H7F9g7l/2DRbivWwCrvhWbyGcfFh4jKrNbbKnnYtvZ5VMc9Iu8mX0ilc29fEzcH7A7mDmdPkx7uduKv5gCh97WMI055KmkNg== 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)(136003)(396003)(346002)(40470700004)(36840700001)(46966006)(336012)(44832011)(478600001)(81166007)(6916009)(54906003)(47076005)(26005)(84970400001)(426003)(40460700003)(70206006)(316002)(86362001)(70586007)(82740400003)(8676002)(356005)(40480700001)(235185007)(4326008)(5660300002)(8936002)(33964004)(36756003)(41300700001)(36860700001)(186003)(2906002)(2616005)(82310400005)(4226005)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6751 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: b15868c9-e101-40b2-43d8-08da7c77f85b X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: l2ecNL7FxHzGukOqTL9CHNwdCgzTZ0kAnjITyQiS6IEYZ0MJfcdrcrLQXPGU+yhtaAfIckFjpHyNqyZA5PlgCBFsp7rasVHsGxyVOaRm5eNsiVu9v5fytjBpCLPw0yIZCwW1MJJY54RhcWEPxO5/ykVZ6jdRAeGKj8rCbuCSM1iphZIDDvxClsESKCCDwIH0ZjmJsjt/xLHBD91IfrffbQ57wGs90kjKqf7Eg6ylTkpktY8oV+/Yijp3XeTOb1WU31LOsbsmAIf9n+bC8VN+EZBfLA/mJ8RloSZEH8M51k2m9BjwAeWewJr62PpA39ICsCSzdGXk2/MPGC6di0GiRNwFBhG8MzFC96dS85bSIaSApZbPvhZedEXDUpy9jW/OIfZDRqXeqLAuH2H1/ynRX70pWXalHiECZEqD3pqlV2WjnfbsQEe1ksp3/8tf2p3RfgVuUVk66eKroIwMRv9xByxFvj2K5MwfbHlxXPtzM6IOvyE6oCJMnX5ZlQiEbKLXmgaZllR7vQwY6iIAb/vMKazDMqCzjuwLsSJpe1tZakpptsQRL0eZpB0Ckr49tTBJSKmAvTEJdpgmRNrocaz13HfAGv/4UrKwJcnp5XPyZy5cmeqiCzdZDFISojVfmZ5Slmnm4czy6aF106buEs9YfikgzYJ6pcMpV42DBjqHcfcS2mQjr+gb5Hy5hytImrrakymNXt8e8ZFBjqtd0yjmwdPZS599OYwDPF5sSXAGpZE0gC0NVQ9visoqFIcd4clYxclM9OGFwksYcFw9ut3e3yI1BLYVQZNs0mSIaywPUHksjkV/LofaAIr/z8ceG0cj4kr7Uq9t485Z3vz48Xwyi6txbBqykqa1esM7FjLnOZ4= 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)(39860400002)(396003)(136003)(376002)(346002)(46966006)(40470700004)(36840700001)(40460700003)(36860700001)(336012)(47076005)(82310400005)(426003)(2616005)(186003)(81166007)(40480700001)(478600001)(82740400003)(235185007)(70586007)(316002)(41300700001)(6916009)(70206006)(54906003)(5660300002)(44832011)(2906002)(8936002)(26005)(33964004)(8676002)(84970400001)(4326008)(86362001)(36756003)(4226005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:33:21.6553 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2d4f9b96-14b7-4d77-7e29-08da7c77fd31 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: AM7EUR03FT038.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR08MB2931 X-Spam-Status: No, score=-12.0 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970079817741560?= X-GMAIL-MSGID: =?utf-8?q?1740970079817741560?= This patch add the following new multilibs. thumb/v8.1-m.main+pacbti/mbranch-protection/nofp thumb/v8.1-m.main+pacbti+dp/mbranch-protection/soft thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard thumb/v8.1-m.main+pacbti+fp/mbranch-protection/soft thumb/v8.1-m.main+pacbti+fp/mbranch-protection/hard thumb/v8.1-m.main+pacbti+mve/mbranch-protection/hard Triggering the following compiler flags: -mthumb -march=armv8.1-m.main+pacbti -mbranch-protection=standard -mfloat-abi=soft -mthumb -march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=softfp -mthumb -march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=hard -mthumb -march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=softfp -mthumb -march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=hard -mthumb -march=armv8.1-m.main+pacbti+mve -mbranch-protection=standard -mfloat-abi=hard Approved here: gcc/ * config/arm/t-rmprofile: Add multilib rules for march +pacbti and mbranch-protection. gcc/testsuite/ * gcc.target/arm/multilib.exp: Add pacbti related entries. diff --git a/gcc/config/arm/t-rmprofile b/gcc/config/arm/t-rmprofile index eb321e832f1..fe46a1efa1a 100644 --- a/gcc/config/arm/t-rmprofile +++ b/gcc/config/arm/t-rmprofile @@ -27,8 +27,11 @@ # Arch and FPU variants to build libraries with -MULTI_ARCH_OPTS_RM = march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp/march=armv8.1-m.main+mve -MULTI_ARCH_DIRS_RM = v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve +MULTI_ARCH_OPTS_RM = march=armv6s-m/march=armv7-m/march=armv7e-m/march=armv7e-m+fp/march=armv7e-m+fp.dp/march=armv8-m.base/march=armv8-m.main/march=armv8-m.main+fp/march=armv8-m.main+fp.dp/march=armv8.1-m.main+mve/march=armv8.1-m.main+pacbti/march=armv8.1-m.main+pacbti+fp/march=armv8.1-m.main+pacbti+fp.dp/march=armv8.1-m.main+pacbti+mve +MULTI_ARCH_DIRS_RM = v6-m v7-m v7e-m v7e-m+fp v7e-m+dp v8-m.base v8-m.main v8-m.main+fp v8-m.main+dp v8.1-m.main+mve v8.1-m.main+pacbti v8.1-m.main+pacbti+fp v8.1-m.main+pacbti+dp v8.1-m.main+pacbti+mve + +MULTI_ARCH_OPTS_RM += mbranch-protection=standard +MULTI_ARCH_DIRS_RM += mbranch-protection # Base M-profile (no fp) MULTILIB_REQUIRED += mthumb/march=armv6s-m/mfloat-abi=soft @@ -50,6 +53,13 @@ MULTILIB_REQUIRED += mthumb/march=armv8-m.main+fp.dp/mfloat-abi=hard MULTILIB_REQUIRED += mthumb/march=armv8-m.main+fp.dp/mfloat-abi=softfp MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+mve/mfloat-abi=hard +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti/mbranch-protection=standard/mfloat-abi=soft +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti+fp/mbranch-protection=standard/mfloat-abi=softfp +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti+fp/mbranch-protection=standard/mfloat-abi=hard +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti+fp.dp/mbranch-protection=standard/mfloat-abi=softfp +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti+fp.dp/mbranch-protection=standard/mfloat-abi=hard +MULTILIB_REQUIRED += mthumb/march=armv8.1-m.main+pacbti+mve/mbranch-protection=standard/mfloat-abi=hard + # Arch Matches MULTILIB_MATCHES += march?armv6s-m=march?armv6-m @@ -87,9 +97,23 @@ MULTILIB_MATCHES += $(foreach FP, $(v8_1m_sp_variants), \ MULTILIB_MATCHES += $(foreach FP, $(v8_1m_dp_variants), \ march?armv8-m.main+fp.dp=mlibarch?armv8.1-m.main$(FP)) +# Map all mbranch-protection values other than 'none' to 'standard'. +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?bti +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?pac-ret +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?pac-ret+leaf +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?pac-ret+bti +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?pac-ret+leaf+bti +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?bti+pac-ret +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?bti+pac-ret+leaf +MULTILIB_MATCHES += mbranch-protection?standard=mbranch-protection?standard+leaf + # For all the MULTILIB_REQUIRED for v8-m and above, add MULTILIB_MATCHES which # maps mlibarch with march for multilib linking. MULTILIB_MATCHES += march?armv8-m.main=mlibarch?armv8-m.main MULTILIB_MATCHES += march?armv8-m.main+fp=mlibarch?armv8-m.main+fp MULTILIB_MATCHES += march?armv8-m.main+fp.dp=mlibarch?armv8-m.main+fp.dp MULTILIB_MATCHES += march?armv8.1-m.main+mve=mlibarch?armv8.1-m.main+mve +MULTILIB_MATCHES += march?armv8.1-m.main+pacbti=mlibarch?armv8.1-m.main+pacbti +MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+fp=mlibarch?armv8.1-m.main+pacbti+fp +MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+fp.dp=mlibarch?armv8.1-m.main+pacbti+fp.dp +MULTILIB_MATCHES += march?armv8.1-m.main+pacbti+mve=mlibarch?armv8.1-m.main+pacbti+mve diff --git a/gcc/testsuite/gcc.target/arm/multilib.exp b/gcc/testsuite/gcc.target/arm/multilib.exp index ddbb4439314..52e67446453 100644 --- a/gcc/testsuite/gcc.target/arm/multilib.exp +++ b/gcc/testsuite/gcc.target/arm/multilib.exp @@ -832,6 +832,12 @@ if {[multilib_config "rmprofile"] } { {-march=armv8.1-m.main+mve.fp+fp.dp -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp" {-march=armv8.1-m.main+mve+fp.dp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard" {-march=armv8.1-m.main+mve.fp+fp.dp -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard" + {-march=armv8.1-m.main+pacbti -mbranch-protection=standard -mfloat-abi=soft} "thumb/v8.1-m.main+pacbti/mbranch-protection/nofp" + {-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+fp/mbranch-protection/soft" + {-march=armv8.1-m.main+pacbti+fp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+fp/mbranch-protection/hard" + {-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=softfp} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/soft" + {-march=armv8.1-m.main+pacbti+fp.dp -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+dp/mbranch-protection/hard" + {-march=armv8.1-m.main+pacbti+mve -mbranch-protection=standard -mfloat-abi=hard} "thumb/v8.1-m.main+pacbti+mve/mbranch-protection/hard" {-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=soft} "thumb/v8-m.main/nofp" {-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=softfp} "thumb/v8-m.main+dp/softfp" {-mcpu=cortex-m55+nomve -mfpu=auto -mfloat-abi=hard} "thumb/v8-m.main+dp/hard" From patchwork Fri Aug 12 15:34:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 506 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp948576pxh; Fri, 12 Aug 2022 08:35:57 -0700 (PDT) X-Google-Smtp-Source: AA6agR5IcdhHjzh0BxHDfSVP63laKAgDAtiovFdMqTFnGSA0ELErVnuMDXI7MhGf0KeCRTJzHxSQ X-Received: by 2002:a17:907:2722:b0:731:201a:df9c with SMTP id d2-20020a170907272200b00731201adf9cmr3115527ejl.149.1660318556843; Fri, 12 Aug 2022 08:35:56 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id e20-20020a50ec94000000b0043acc275debsi2255706edr.296.2022.08.12.08.35.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:35:56 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=qTiCenJp; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 6738A3858427 for ; Fri, 12 Aug 2022 15:35:55 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 6738A3858427 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318555; bh=9t269f46Y+plvlMcbyL4ejBZPynUGRn4gchqewmnbyw=; 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=qTiCenJpXqz9hvXjxN8sH27RzKc8HZmosfnSI3KCiB7aIi2yMy59gDd5QjKWU/bt4 dxoc+1UmBDsKPCIB2qKh3J9djIipkTzIds3DaRrbyULxvzd44n38gTmDE7lUe575mV 9oIsfYhqJs9Kasm53X5Bfujxk5LUmPVJ8XJE1rEU= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2088.outbound.protection.outlook.com [40.107.20.88]) by sourceware.org (Postfix) with ESMTPS id D952C3858D28 for ; Fri, 12 Aug 2022 15:35:10 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D952C3858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=EfdvHxXCq07FhLatCKEpQi+ditRJ1tOxMTkdXsfN0zY371cGQg5BZKI8IauxRzzKoXEiVeN21fwRHs+P+TF8FxFoUb7aw4bNk0lERDmi5j4V/uG1khYXJMQ9tcuH/rMORnE7dzfdpFes7ynEfuntIeLiRxLWD+7AF8zt7w/wRAvGCnFXkSb+jCKsFk8LxsUy8EoidUiQujuhQoc+ZSOnhN0E5tjCKPZs17dzTalqCMHnphUmR9urLBjpSyB44jTiMK6gcLS8yjyCGkrqfWk4gyTIB+j16fDe9XZ40UVPOz1Bzur7pWP7Uf6c7rRBEUyT6UyPZ+bL3TU0LCm33z7gkQ== 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=9t269f46Y+plvlMcbyL4ejBZPynUGRn4gchqewmnbyw=; b=TpGcI7SlJ/s/eR1IJgApuxCXTlD2klogx3Xg8BlahsV9B9oUXzmmdfeaTJioFdkQBeUeNECRhuld+32BauCHOi/wHqFrjPB5LzHAW2qw1LhQrHKxPSbe/l9BdvHsNd3eEcm5mQ9vwjh1RvEsDgbwhLDsSN/HKsIwmvYcQtKpwje46NZIdlLCnw4YJ7meuyeMp0aO2PT9ubQfkO8fieAvHB0kNi4rZXCjcNoPTjIMd9cNvZ4rVoOpcrn72cptB/lf48UZpCpdCtJ9YaHLFdGrc1nwszQqB5nzqMtWjsFXAdMqJRHVxW2op8urOodNqCQwqLfTj6XhcYDlYMPxcRFmMA== 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 DB8P191CA0005.EURP191.PROD.OUTLOOK.COM (2603:10a6:10:130::15) by AM4PR08MB2675.eurprd08.prod.outlook.com (2603:10a6:205:10::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Fri, 12 Aug 2022 15:35:08 +0000 Received: from DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:130:cafe::36) by DB8P191CA0005.outlook.office365.com (2603:10a6:10:130::15) 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:35:08 +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.5525.11 via Frontend Transport; Fri, 12 Aug 2022 15:35:08 +0000 Received: ("Tessian outbound fccf984e7173:v123"); Fri, 12 Aug 2022 15:35:08 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 053edd65d1845295 X-CR-MTA-TID: 64aa7808 Received: from beb77bbb28a7.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A3537574-5119-4DCC-A571-CB99541AAE31.1; Fri, 12 Aug 2022 15:34:25 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id beb77bbb28a7.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:34:25 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=G/VpK8SkklZAaiFrY95bkuyUVK2rKUXDVz7v79M2AaQmiKmq7YQ4ZKKUa2qtYcqtjPqeW421B6Rt52f+dgWPINRlI+Gd5NXiblzj1kU5dfHNm3D7BrdRtdmOI3kWpL2poMKh3yGZtTLOPoom8RuLyqrebNj0kX32vAiN6W1DC1TToMIfhFBZsbBrSGzQk+HqkBaKqwch8ojZoKnR5MmM+5ftHGcAqvhpSRc9zUF0897ilJFa36wJH8wkBKETk17xYuuF6MqPnlG6srpdgoEwy7T1rddV+Btbz9uCYl/dHLfKh/2NxaHAoUrGfrd5rBoKbJyNtv9Ku3oRwhMezgQBcw== 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=9t269f46Y+plvlMcbyL4ejBZPynUGRn4gchqewmnbyw=; b=eloiikabncNR46/D/oxqtHtNvRAntwHvtozegVIzAbRBYTbcNGQgwIjzW2KBguMrDDBbZ+QnC/MAZ89eW3qHIOHUZeRGmnip2mlD/hLszXUy4U+OB4m9pNLhFML/T4bmeMD5NB3c/1em7hxqJaCJh4fCA8FJN+g788C7lTEQVJCEDVdrNgANo86pSmu0Ft0v4GD1goCSpPhU37rgEbGy9HaiSU3ny2GA5XFIm8zxN17xZi0kPwKqN9GLoOf8Dte97GGTMa3uUueLrxyMLePYbGmy65izV7STT+QtawsSAYVSQrccjI/LZxnsNY1ud1jCh6hxlvaREFyTDzY1HiQjqw== 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 DU2PR04CA0030.eurprd04.prod.outlook.com (2603:10a6:10:3b::35) by AM6PR08MB2952.eurprd08.prod.outlook.com (2603:10a6:209:43::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:34:24 +0000 Received: from DBAEUR03FT049.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:3b:cafe::e4) by DU2PR04CA0030.outlook.office365.com (2603:10a6:10:3b::35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.14 via Frontend Transport; Fri, 12 Aug 2022 15:34:24 +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 DBAEUR03FT049.mail.protection.outlook.com (100.127.142.192) 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:34:23 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.9; Fri, 12 Aug 2022 15:34:23 +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:34:22 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 9/15] arm: Set again stack pointer as CFA reg when popping if necessary References: Date: Fri, 12 Aug 2022 17:34:22 +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: fb67ae31-aef7-46e2-999f-08da7c783cdc X-MS-TrafficTypeDiagnostic: AM6PR08MB2952:EE_|DBAEUR03FT018:EE_|AM4PR08MB2675: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: V5dbK297QTCOeDNFtw8hiDaV54IamYfu5O3xzuaSl04w3ri9xaNIHatjs+h0PzWo3GaU0zucoZPSnBd6qQjLOogRfqD0ZOsArrCQO3hVZMNgpD9DcTJ0RK+S2SET4un6zZWsIXPzaed5/lkAai/ezQOj7AC5gCPgd3CzSHypddk0jR7qzLLogI8sFMkGWS1fjR1Q/VfsM+1pXABfxtZ0PVfKfo9kp7mjypK9syuiz2N7+XAOUvFUa2GLDxxj3H+WuCAYuZEhclfWtlcQ9VnEFMA8tYcHcMMuFSsdlXrThlR10LDhBtoRMHVQpuyIJ8UopGKSyINOua/fZbrkNggWDJcfb2M80llkX/o498we03/72YF+gk5h+uPcZWxGyxu915GxXdOvXr3XY6k7Q3+cRWZP9O7l2YYw2Q8U5PZobTqRt5L1OHxShVDSl8XGOxm6WV2iZgYztBc+l3T5p6nJJgOoNVcLWAvP6ImOTYDMP+/eB/Vc16cUKQeV0b7ksKKPQWxeWi6lwk/wDJNGDhgXeweoD3lQaeQ0bvTgvZnosBdKm5Vu1cm3/f4GtYNur7KknpEQGvASZVPbDI1u+051wAgU5LPtTbJGndvus8BXnEaE+Q5jjBTO5V9yA/xbobY9lNIPmKoA6t1XGkJT5RYkelH5BSs8ZzChs8kKcXQ4IMVH27MYbHwtA26uJazll8ouokfBZ2BGLQenzH9WIHWH6nf+Z4Y1ycw6Qg+7Ln74cCMZticAySv88zpwys1JcB/bDRfuvyPHLpZuhucvCn6Lw/61baHut5k9xoe4QVWO/qar43EYQTS8Bo02tUKt5+IVXte7pXW6D0BnVBl/AqiqiA== 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)(136003)(376002)(346002)(39860400002)(396003)(40470700004)(36840700001)(46966006)(6916009)(41300700001)(478600001)(54906003)(316002)(40480700001)(4326008)(82310400005)(2906002)(26005)(8676002)(40460700003)(44832011)(70206006)(70586007)(5660300002)(8936002)(235185007)(82740400003)(36756003)(36860700001)(564344004)(86362001)(426003)(81166007)(356005)(2616005)(336012)(47076005)(186003)(33964004)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 8vMOJYdS55I59Ud8uEP7uic+TlnV6/lvkIArbcErpOUSXLYbgDWLr4aJyxomKQw+NCJAntUAAS0ckARl3678TFQVum9Yb9PW6f+PBI0z/OkXZmbQqwMJZETVXxVOENBzt1Va1KgIsJU432IyUGHbhQdurazRgzdQNt82izcqA8fJDuaShJWGJUz7SH7W+XRDNHm4VsDOktzw0up73z8L0m6kP+QeMI3Xo/bJdkOCWE3lKmN29hph/+OYp+BBHpkVTNdTSAtq+vjnOuYziX+VjRMJjPPFWRw4dXFr0OcXr4D1v9e57s2G/BhNMwfnxO41Us1bYitzV2VpQLhF/rpgHhHeOz8BBoDVvx8Y/6FKClyXKbhstvEAxOoWQb/JK7TfpyV2srPpkTOH6t26X5eT/FHKmLiLVyiZRJcEtIqmcmgPCEMGoZSTHCoNI2ehBB0dirx609nzhTQLQ9hpPOJkuc4GVy9F6ZNQb2Y7w7okLR6SQRBIpaMZnyKGtxLFb4liNsckR1x9ID+0wwIS2HI6DZxtgS5MST4054V0i/5KweIYBmmlt3dX6JTUD7cpYfYRk9YFNJMp9UKQxBccbPP57F2bThBu/RIeHKGUEn0UKkBlNtq7fCdEUJwC38JX8AwHzJFcwCjM92utPjO2EA5m2siRw86ZAExna5ad6fI5GAV9uiWq7C/+UmkV89kBs8NVz8+d3zKPGiNjGOHeysGhHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB2952 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT018.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 18f83e60-6c70-4b41-67a0-08da7c78224f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bUb35PLf9wTUYmUQbr02W+/cuGGdi/HflHz9XlatL+CTjfQwqAuX+fM9HWQ/ZjoeXHw0EDwmQTRuocnEt6S1l7nqUX9ZoBJcSeIzVrAotLkM9Hz8vCWJZOiFp4sGQi9LrjSDXeDY3ou7mBgkVCl3U1qTObYp9DWK1V2y1/4yla33J9RLjpQHwNp+0qb/DaUnlM75DPPuzi4eAuMP9gp8LjuEJPQSeiysjrttA7z4dvlBgOPb3AI1ziYJadt9dupA+djwcCW80cpGUQIkIH5WIXZafHx93yEu+wfmLKg+gtjx58F09o1lSHnmWAOikehNKtV3h1osockflHe+RS+omdvX2oh9/qpNwY5WlYx4IGUNDFisAZX567+MiHbrzXgA5lZ5l5xd516PAs/SVFHoJkBcn8Cc9+C2hmTdvPdoPO/B/l8L+EjillbkUOq6hIdvdfNZ8kkmrl4tIhxisp925Xlx6Qj+br/yGIJfZVDubVkk/bVWvQghxUlbEPb1Pzau2yBjAf8B02uJ4hsKOJfTPFf0BwUmlLSCSDxMO3UHYD3N18bpLfflwmLiJ5KrKauT8M1JgqwwUpSY9ifM9slRE5W6gjH4VC8Oc8sDhpqwJNfT3ol8wUzQaWtmZ7R5iwqyiGr1WDYSQ5945XCzpQ3z+mrloTtjRUMsWtebD3EvlzRsmvTpg0tSXWtfuNn+tuGvcwHhDUpIZgznBuYfI2strhA8tYTPwVHzibVBcRnmT5MAHbjRXGJCo5VOzbGnOCXc3b8Mq7l2u8cIWPm1el89O0h5qeA1XUVVO5NpZEFzOrc0r11mMbPj8FF9urez6Lvj 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)(346002)(39860400002)(376002)(396003)(136003)(36840700001)(46966006)(40470700004)(336012)(2906002)(478600001)(8676002)(4326008)(70206006)(70586007)(564344004)(82740400003)(81166007)(235185007)(8936002)(44832011)(5660300002)(36860700001)(426003)(33964004)(2616005)(47076005)(86362001)(41300700001)(40460700003)(186003)(26005)(54906003)(40480700001)(6916009)(36756003)(316002)(82310400005); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:35:08.5200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: fb67ae31-aef7-46e2-999f-08da7c783cdc 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: AM4PR08MB2675 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, 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970191085413922?= X-GMAIL-MSGID: =?utf-8?q?1740970191085413922?= Hi all, this patch enables 'arm_emit_multi_reg_pop' to set again the stack pointer as CFA reg when popping if this is necessary. /gcc/ * config/arm/arm.cc (arm_emit_multi_reg_pop): If the frame pointer was set define again the stack pointer as CFA reg when popping. diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index ceec14f84b6..a5cf4225aa2 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -22303,8 +22303,18 @@ arm_emit_multi_reg_pop (unsigned long saved_regs_mask) REG_NOTES (par) = dwarf; if (!return_in_pc) - arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD * num_regs, - stack_pointer_rtx, stack_pointer_rtx); + { + /* If the frame pointer was set define again the stack pointer + as CFA reg. */ + if (frame_pointer_needed) + { + RTX_FRAME_RELATED_P (par) = 1; + add_reg_note (par, REG_CFA_DEF_CFA, stack_pointer_rtx); + } + else + arm_add_cfa_adjust_cfa_note (par, UNITS_PER_WORD * num_regs, + stack_pointer_rtx, stack_pointer_rtx); + } } /* Generate and emit an insn pattern that we will recognize as a pop_multi From patchwork Fri Aug 12 15:36:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 507 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp949353pxh; Fri, 12 Aug 2022 08:37:22 -0700 (PDT) X-Google-Smtp-Source: AA6agR7spuidezsnvNEB4zT7y63M9n2IDu15fYlZzVvCurgBRbz+9qT23yT5UxS1dYbdclCfAL22 X-Received: by 2002:a17:906:29d:b0:6f0:18d8:7be0 with SMTP id 29-20020a170906029d00b006f018d87be0mr2967842ejf.561.1660318642230; Fri, 12 Aug 2022 08:37:22 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id y7-20020a056402270700b0043beaa7f1b3si2563220edd.247.2022.08.12.08.37.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:37:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=QAQgpRGX; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C80433858412 for ; Fri, 12 Aug 2022 15:37:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C80433858412 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318640; bh=ByIhNx2XW07YcCGZi4Ou7c4ysIVqhh9xAZ2zffGjxU0=; 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=QAQgpRGXUJlQQn2US6qmgaBzeQakPteWobTem6XV03jwrGKZKu4QBwtNIx+77cVP4 X8Z8u3ioIwOpebxD2uWw+4rwLwvqzbv2Qon56EPNpLsIfjraZ96Zx13y5lmTy7KgrV qEnFlUEWmanbrRahiON9rv21P1/aEF0H9TClZo5g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2056.outbound.protection.outlook.com [40.107.21.56]) by sourceware.org (Postfix) with ESMTPS id E0E703858D28 for ; Fri, 12 Aug 2022 15:36:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org E0E703858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=ONuNB9Lbpu6Ohc03sG34N/l/l2TgGq8u/vv1D1cYJPovcqX/ktmYODTRCQfdkaYHtMDoKdDPykQpEajxq7yZ2ATgNlMJ5389CshLAUtSPhdSi3RplyWAYIKVKy5OfNSR33kEJEpiHDw21FKgEZXUwhFkDT1RZOS6Q60XTR2Oj6o6D83Gvwj/tUCm4OavKIRDw+P8GC/kL+qFMKJvc6WZHJgkboW2SXwPhrk/cXATrOygixr+IYdH/ZrePytwnhKcR5L5XSBdkj735KqM4+ETWRY5gnduMYFIC3SzyyogCOSLLHdkdtAdC+1fW9m3TthSbjcbz43k2zUw8Uv+4R8IRA== 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=ByIhNx2XW07YcCGZi4Ou7c4ysIVqhh9xAZ2zffGjxU0=; b=jE65XharB13c1yTUY2R3vkOvtwCgZhLBXVmaIhLW3kNsrtdez3XV81sLFSnQMb8d7zsNH7if3H1E7tM5LDvrTdNC1IK1gMz+FPpOx9hqqDaVRlmq50tc3GRfK5Y/5WFgbF3CxyI2OUW+nzEig/ACCuN79+eaAFomXPhWrVCW1g3eKOCSyWkiAGdg9qFU4BunBb/xcyOxhPfsZD3KVhG+e6HoYAqBnvuiHxSOrTu+ZtTdKTpO1CpFsR5W2iv+RTk2kZAKsc/5kfCsEKtyVxewxuaQJ3z3z3wqH0JKS4q/IaEYA9o6L8CAI5Zb9zoAXqYUWVcmBAFhN6M0sylk6Ifhow== 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 AS9PR06CA0572.eurprd06.prod.outlook.com (2603:10a6:20b:486::7) by DB8PR08MB4172.eurprd08.prod.outlook.com (2603:10a6:10:af::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10; Fri, 12 Aug 2022 15:36:28 +0000 Received: from AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:486:cafe::1c) by AS9PR06CA0572.outlook.office365.com (2603:10a6:20b:486::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16 via Frontend Transport; Fri, 12 Aug 2022 15:36:28 +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 AM7EUR03FT039.mail.protection.outlook.com (100.127.140.224) 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:36:28 +0000 Received: ("Tessian outbound 73dd6a25223d:v123"); Fri, 12 Aug 2022 15:36:28 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 16ff1c51d6cd9c9f X-CR-MTA-TID: 64aa7808 Received: from 2fc35455bf54.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 168B50B3-0269-4F11-B915-0FF10F091EB8.1; Fri, 12 Aug 2022 15:36:21 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 2fc35455bf54.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:36:21 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UW/rW00rOVOujeXEbn5jzac54LSNC5KKSFi4OP4gKyvQ088xbnqlrN0Ri85lGXd4UU4Yd/X2O/7QxRal7Vohh5Ev8atOLaaWokXRRJD3DZ3VAWvrqC9HWUVSts1wkNLD1hFI24ifRDCrYd36IKxbfupPTjcCRh4cYA6R42rbBaFaV9DShId6F0xi/fb0fYI3XzKqBT1+xr7G3493MiKnB5DK6QdSgMtJ0E3z5PjDS8LqApFdNoNBHh/EwO5NOztQmuMZptg2AbANYFgjEOHWOPBEu7EiqpnKHvH/DQ5o2+aNuWeuoBykoi0RQLs2Qqln7Z5jrD88iwxotL+5GVdbSg== 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=ByIhNx2XW07YcCGZi4Ou7c4ysIVqhh9xAZ2zffGjxU0=; b=KiEt17oar5bz0LCKBwW8nkP1B/xgK4F2in9uLiWr/b+Fa8+3IlpyY7HH6vAAzRWx5TxCI+vHiSVW0zC+cHj1ErGUUD9ZvFM8BRhWftTnzYc0zU06mQf4xRreBInPHLVH5GIpoAoy3yhRUDiezz9fKaZ/unS0vXIMRK20wBZI2YDEwxcLZPes0y9M31VooEoDskGznM9JgY7sl2/8MFoOdsYM/BRN75a3ZJt0FvxAdxBUh+QCLG9Azq/1AH186axVvf17cB6owF7EMqKFuQi5GKzGHWsPw6dConcMNnFt5dZZQgAemRzobItB+5Bfh2yHVqo4Xjle+whgXAyPlgw3bQ== 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 DBBPR09CA0027.eurprd09.prod.outlook.com (2603:10a6:10:d4::15) by VI1PR08MB4416.eurprd08.prod.outlook.com (2603:10a6:803:ff::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.15; Fri, 12 Aug 2022 15:36:19 +0000 Received: from DBAEUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:10:d4:cafe::c5) by DBBPR09CA0027.outlook.office365.com (2603:10a6:10:d4::15) 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:36:19 +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 DBAEUR03FT009.mail.protection.outlook.com (100.127.143.21) 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:36:18 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) 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.9; Fri, 12 Aug 2022 15:36:18 +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:36:18 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 10/15] arm: Implement cortex-M return signing address codegen References: Date: Fri, 12 Aug 2022 17:36:17 +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: e454e7e0-f0c1-4896-c50f-08da7c786c81 X-MS-TrafficTypeDiagnostic: VI1PR08MB4416:EE_|AM7EUR03FT039:EE_|DB8PR08MB4172: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: +cYxrsIo4LrVgMlBJS1ZqoPzC1eogR1Lgm18Q71vMufbB/zxX8ONXfHOefk+X3d0l8PFfODFqPF7rUiCOU3zL/Y7txA8kIdGqii3mQ2ZRLPmmkeBujBfR8/rBIKY8beg/i+3TKvcs7oZZo86azJbD3Vm9OzAfZaIfy9qjzG261r3WpwfNvS8iR+NWpTQrJzDBNAxbuF5reasimPVm5oQq3iOplwi8p5xhZzs1cnKeXMrZ7gcnhY2BxRDLHliNNmoCNf1hHB7TFQAjWYZtUPuiej4Qa/j3xlKe638zMb5Mf56aldPdGF1ZKVd/CrCBDPeDFbZ94WmXkhk7CQUV/HMPpCvdkdkHftiIL98y1AAoQAwlkkCsOsM54bT8V9xKiLiYCNM5YLhRBKHSHgtxXY15v9AOHNyZeo7bRePxXafF6TBON3gbe/DQ3uoaD5E7ql5tNjI74jkizbb2Tz/QuY8o3k0zG9NpbWs7gdaQ82J9yztZgg8MRgfOCpm0N+kMY4uc0HmXcMTj2MC04VOY7+z1vmEhTMk3X7cuKLQ77/cj3kBp1zxi4mFf/L4iQ9KUA0RYdKAFu3n28qim/yrGhwVzDlGKnenMECGesu9+VhUj0Mjbtx/gDKbKSDvfYAx6o80EpN493Q1298I06nj+tkQtzWsSkZai3plj6FVmO0/zAvsQOMhsumQ5uG8AcIspy4rzeJUntNRxeDlUNz4TJcOG+9yWC2OyIAObnpDRWJXRf2Zn6Cw3+gRK7F+YJpLi+oc6xGh6udO6a6/nwJrNIn0wsbE/q1XucOehX1k/+0LFT3YPtD0ubdMIpDEfficIeIV0kVVe3ou7eOxE/ZEa1OxD5HKVCFwQIMegWjNONfLt6UQ3Ob9Dp9rEL1tUIJT2yA9PsBYrW9s7zTH8r9JrG3xInNvWn1So6uXXxvumKmqwfc= 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)(136003)(396003)(39860400002)(376002)(346002)(46966006)(40470700004)(36840700001)(82740400003)(8936002)(356005)(5660300002)(81166007)(47076005)(186003)(336012)(426003)(83380400001)(36860700001)(2616005)(41300700001)(70586007)(478600001)(26005)(33964004)(54906003)(316002)(6916009)(40480700001)(82310400005)(4326008)(40460700003)(36756003)(44832011)(8676002)(235185007)(86362001)(84970400001)(70206006)(2906002)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB4416 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: daaebcdb-fde2-457e-bed9-08da7c7866dd X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZcR+9Ck9kmeWwRhbuvfIQzBZ7voLt34tG+no3aNKBqPO2WjpdZLkD+dWqw+5CXdHTFs8TZGLs2dpARwECCZf2srJir80prQY4M9gx3yVhrxcY+zq0rUFKnX/cJZDDtwbodCm3NT2Ts6cXxKC/vN2ydwJyp88nXHEoToUL+KzEcw1YZFAXUtZ0Zf9lWThNii1/QITp1HXvlGkYo/Zt/H27Esxs6g+POBM7ix9PRFsJDpLOtVoUJQhPZqsq2/L9ERtSLUGrQAYb8pHpP09E2NSt3R5vzYCiUulXsKEJ6o4hE+lGL/jdKzOpT1yd4vsCbf8/lzVhiDkav8rkd4sNhc2kIpvM4O3E8BMjig0G7g3/v+NA/JoLEDm12usnxiu7xJEyPD1pK+Kzfc1oRYOHkYvPv2JtCew/NqzfvLPZKLf2YDNdlfH3LiyLm3J005+IHLmCftm7WzMIxk3uFD1fKAITkNPV6EHTmXmcP/duSj5PJy86LqU2ghhMEmSf+rV8lqUgS8ymHDMQq40hTeDZFdPNYpLgqgVPFP1sWRy1wJV3yzAqP2lP320AhL3SQe5C3oLG4BBvJ3mK3G51jN9ksowr3lmxyMCXw1pPeYohWv8tYjJOYeg2l0EVmnHP0g23tX4OMld28Oixd6+q0O/GsnyzZmB939HW6YVZwF8kZ8d6MBcq29DFwlzqBsyZfac8SKpqf47YtwWRQDXUAqG35MRUZno7XXl93EcWJ8vm4Lbmc4h5WFtQNV3ufEzK77Vm4hk 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)(136003)(376002)(346002)(39860400002)(396003)(40470700004)(36840700001)(46966006)(6916009)(41300700001)(84970400001)(478600001)(54906003)(316002)(40480700001)(4326008)(82310400005)(2906002)(26005)(8676002)(40460700003)(44832011)(70206006)(70586007)(5660300002)(8936002)(235185007)(82740400003)(36756003)(36860700001)(86362001)(426003)(81166007)(2616005)(336012)(47076005)(186003)(33964004)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:36:28.3928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e454e7e0-f0c1-4896-c50f-08da7c786c81 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: AM7EUR03FT039.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4172 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970280852940504?= X-GMAIL-MSGID: =?utf-8?q?1740970280852940504?= Hi all, this patch enables address return signature and verification based on Armv8.1-M Pointer Authentication [1]. To sign the return address, we use the PAC R12, LR, SP instruction upon function entry. This is signing LR using SP and storing the result in R12. R12 will be pushed into the stack. During function epilogue R12 will be popped and AUT R12, LR, SP will be used to verify that the content of LR is still valid before return. Here an example of PAC instrumented function prologue and epilogue: void foo (void); int main() { foo (); return 0; } Compiled with '-march=armv8.1-m.main -mbranch-protection=pac-ret -mthumb' translates into: main: pac ip, lr, sp push {r3, r7, ip, lr} add r7, sp, #0 bl foo movs r3, #0 mov r0, r3 pop {r3, r7, ip, lr} aut ip, lr, sp bx lr The patch also takes care of generating a PACBTI instruction in place of the sequence BTI+PAC when Branch Target Identification is enabled contextually. Ex. the previous example compiled with '-march=armv8.1-m.main -mbranch-protection=pac-ret+bti -mthumb' translates into: main: pacbti ip, lr, sp push {r3, r7, ip, lr} add r7, sp, #0 bl foo movs r3, #0 mov r0, r3 pop {r3, r7, ip, lr} aut ip, lr, sp bx lr As part of previous upstream suggestions a test for varargs has been added and '-mtpcs-frame' is deemed being incompatible with this return signing address feature being introduced. [1] gcc/Changelog 2021-11-03 Andrea Corallo * config/arm/arm.c: (arm_compute_frame_layout) (arm_expand_prologue, thumb2_expand_return, arm_expand_epilogue) (arm_conditional_register_usage): Update for pac codegen. (arm_current_function_pac_enabled_p): New function. * config/arm/arm.md (pac_ip_lr_sp, pacbti_ip_lr_sp, aut_ip_lr_sp): Add new patterns. * config/arm/unspecs.md (UNSPEC_PAC_IP_LR_SP) (UNSPEC_PACBTI_IP_LR_SP, UNSPEC_AUT_IP_LR_SP): Add unspecs. gcc/testsuite/Changelog 2021-11-03 Andrea Corallo * gcc.target/arm/pac.h : New file. * gcc.target/arm/pac-1.c : New test case. * gcc.target/arm/pac-2.c : Likewise. * gcc.target/arm/pac-3.c : Likewise. * gcc.target/arm/pac-4.c : Likewise. * gcc.target/arm/pac-5.c : Likewise. * gcc.target/arm/pac-6.c : Likewise. * gcc.target/arm/pac-7.c : Likewise. * gcc.target/arm/pac-8.c : Likewise. diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index cff7ff1da2a..84764bf27ce 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -379,6 +379,7 @@ extern int vfp3_const_double_for_bits (rtx); extern void arm_emit_coreregs_64bit_shift (enum rtx_code, rtx, rtx, rtx, rtx, rtx); extern bool arm_fusion_enabled_p (tune_params::fuse_ops); +extern bool arm_current_function_pac_enabled_p (void); extern bool arm_valid_symbolic_address_p (rtx); extern bool arm_validize_comparison (rtx *, rtx *, rtx *); extern bool arm_expand_vector_compare (rtx, rtx_code, rtx, rtx, bool); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index a5cf4225aa2..31c6bcdea55 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -3209,6 +3209,9 @@ arm_option_override_internal (struct gcc_options *opts, arm_stack_protector_guard_offset = offs; } + if (arm_current_function_pac_enabled_p () && !(arm_arch7 && arm_arch_cmse)) + error ("This architecture does not support branch protection instructions"); + #ifdef SUBTARGET_OVERRIDE_INTERNAL_OPTIONS SUBTARGET_OVERRIDE_INTERNAL_OPTIONS; #endif @@ -21139,6 +21142,9 @@ arm_compute_save_core_reg_mask (void) save_reg_mask |= arm_compute_save_reg0_reg12_mask (); + if (arm_current_function_pac_enabled_p ()) + save_reg_mask |= 1 << IP_REGNUM; + /* Decide if we need to save the link register. Interrupt routines have their own banked link register, so they never need to save it. @@ -23362,6 +23368,12 @@ output_probe_stack_range (rtx reg1, rtx reg2) return ""; } +static bool +aarch_bti_enabled () +{ + return false; +} + /* Generate the prologue instructions for entry into an ARM or Thumb-2 function. */ void @@ -23440,12 +23452,13 @@ arm_expand_prologue (void) /* The static chain register is the same as the IP register. If it is clobbered when creating the frame, we need to save and restore it. */ - clobber_ip = IS_NESTED (func_type) - && ((TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM) - || ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK - || flag_stack_clash_protection) - && !df_regs_ever_live_p (LR_REGNUM) - && arm_r3_live_at_start_p ())); + clobber_ip = (IS_NESTED (func_type) + && (((TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM) + || ((flag_stack_check == STATIC_BUILTIN_STACK_CHECK + || flag_stack_clash_protection) + && !df_regs_ever_live_p (LR_REGNUM) + && arm_r3_live_at_start_p ())) + || (arm_current_function_pac_enabled_p ()))); /* Find somewhere to store IP whilst the frame is being created. We try the following places in order: @@ -23521,6 +23534,14 @@ arm_expand_prologue (void) } } + if (arm_current_function_pac_enabled_p ()) + { + if (aarch_bti_enabled ()) + emit_insn (gen_pacbti_nop ()); + else + emit_insn (gen_pac_nop ()); + } + if (TARGET_APCS_FRAME && frame_pointer_needed && TARGET_ARM) { if (IS_INTERRUPT (func_type)) @@ -27309,7 +27330,7 @@ thumb2_expand_return (bool simple_return) to assert it for now to ensure that future code changes do not silently change this behavior. */ gcc_assert (!IS_CMSE_ENTRY (arm_current_func_type ())); - if (num_regs == 1) + if (num_regs == 1 && !arm_current_function_pac_enabled_p ()) { rtx par = gen_rtx_PARALLEL (VOIDmode, rtvec_alloc (2)); rtx reg = gen_rtx_REG (SImode, PC_REGNUM); @@ -27324,10 +27345,20 @@ thumb2_expand_return (bool simple_return) } else { - saved_regs_mask &= ~ (1 << LR_REGNUM); - saved_regs_mask |= (1 << PC_REGNUM); - arm_emit_multi_reg_pop (saved_regs_mask); - } + if (arm_current_function_pac_enabled_p ()) + { + gcc_assert (!(saved_regs_mask & (1 << PC_REGNUM))); + arm_emit_multi_reg_pop (saved_regs_mask); + emit_insn (gen_aut_nop ()); + emit_jump_insn (simple_return_rtx); + } + else + { + saved_regs_mask &= ~ (1 << LR_REGNUM); + saved_regs_mask |= (1 << PC_REGNUM); + arm_emit_multi_reg_pop (saved_regs_mask); + } + } } else { @@ -27733,7 +27764,8 @@ arm_expand_epilogue (bool really_return) && really_return && crtl->args.pretend_args_size == 0 && saved_regs_mask & (1 << LR_REGNUM) - && !crtl->calls_eh_return) + && !crtl->calls_eh_return + && !arm_current_function_pac_enabled_p ()) { saved_regs_mask &= ~(1 << LR_REGNUM); saved_regs_mask |= (1 << PC_REGNUM); @@ -27847,6 +27879,9 @@ arm_expand_epilogue (bool really_return) } } + if (arm_current_function_pac_enabled_p ()) + emit_insn (gen_aut_nop ()); + if (!really_return) return; @@ -32941,6 +32976,15 @@ arm_fusion_enabled_p (tune_params::fuse_ops op) return current_tune->fusible_ops & op; } +/* Return TRUE if return address signing mechanism is enabled. */ +bool +arm_current_function_pac_enabled_p (void) +{ + return aarch_ra_sign_scope == AARCH_FUNCTION_ALL + || (aarch_ra_sign_scope == AARCH_FUNCTION_NON_LEAF + && !crtl->is_leaf); +} + /* Implement TARGET_SCHED_CAN_SPECULATE_INSN. Return true if INSN can be scheduled for speculative execution. Reject the long-running division and square-root instructions. */ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 60468f6182c..92269a7819a 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -11518,7 +11518,7 @@ arm_expand_prologue (); else thumb1_expand_prologue (); - DONE; + DONE; " ) @@ -12890,6 +12890,29 @@ (set_attr "length" "8")] ) +(define_insn "pac_nop" + [(set (reg:SI IP_REGNUM) + (unspec:SI [(reg:SI SP_REGNUM) (reg:SI LR_REGNUM)] + UNSPEC_PAC_NOP))] + "arm_arch7 && arm_arch_cmse" + "pac\t%|ip, %|lr, %|sp" + [(set_attr "length" "4")]) + +(define_insn "pacbti_nop" + [(set (reg:SI IP_REGNUM) + (unspec:SI [(reg:SI SP_REGNUM) (reg:SI LR_REGNUM)] + UNSPEC_PACBTI_NOP))] + "arm_arch7 && arm_arch_cmse" + "pacbti\t%|ip, %|lr, %|sp" + [(set_attr "length" "4")]) + +(define_insn "aut_nop" + [(unspec:SI [(reg:SI IP_REGNUM) (reg:SI SP_REGNUM) (reg:SI LR_REGNUM)] + UNSPEC_AUT_NOP)] + "arm_arch7 && arm_arch_cmse" + "aut\t%|ip, %|lr, %|sp" + [(set_attr "length" "4")]) + ;; Vector bits common to IWMMXT, Neon and MVE (include "vec-common.md") ;; Load the Intel Wireless Multimedia Extension patterns diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md index 7748e784379..dbe243a03f6 100644 --- a/gcc/config/arm/unspecs.md +++ b/gcc/config/arm/unspecs.md @@ -159,6 +159,9 @@ UNSPEC_VCDE ; Custom Datapath Extension instruction. UNSPEC_VCDEA ; Custom Datapath Extension instruction. UNSPEC_DLS ; Used for DLS (Do Loop Start), Armv8.1-M Mainline instruction + UNSPEC_PAC_NOP ; Represents PAC signing LR + UNSPEC_PACBTI_NOP ; Represents PAC signing LR + valid landing pad + UNSPEC_AUT_NOP ; Represents PAC verifying LR ]) diff --git a/gcc/testsuite/gcc.target/arm/pac-1.c b/gcc/testsuite/gcc.target/arm/pac-1.c new file mode 100644 index 00000000000..6cd64dbd014 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-1.c @@ -0,0 +1,12 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret+leaf -mthumb -mfloat-abi=hard --save-temps -O0" } */ + +#include "pac.h" + +/* { dg-final { scan-assembler-times "pac\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-times "aut\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ + diff --git a/gcc/testsuite/gcc.target/arm/pac-2.c b/gcc/testsuite/gcc.target/arm/pac-2.c new file mode 100644 index 00000000000..945ce938592 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-2.c @@ -0,0 +1,11 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret -mthumb -mfloat-abi=hard --save-temps -O0" } */ + +#include "pac.h" + +/* { dg-final { scan-assembler "pac\tip, lr, sp" } } */ +/* { dg-final { scan-assembler "aut\tip, lr, sp" } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-3.c b/gcc/testsuite/gcc.target/arm/pac-3.c new file mode 100644 index 00000000000..47e290a5840 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-3.c @@ -0,0 +1,11 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=bti+pac-ret+leaf -mthumb -mfloat-abi=hard --save-temps -O2" } */ + +#include "pac.h" + +/* { dg-final { scan-assembler-times "pacbti\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-times "aut\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-4.c b/gcc/testsuite/gcc.target/arm/pac-4.c new file mode 100644 index 00000000000..cf915cdba50 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-4.c @@ -0,0 +1,10 @@ +/* Testing return address signing. */ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mthumb -mfloat-abi=hard --save-temps -O2" } */ + +#include "pac.h" + +/* { dg-final { scan-assembler-not "\tbti\t" } } */ +/* { dg-final { scan-assembler-not "\tpac\t" } } */ +/* { dg-final { scan-assembler-not "\tpacbti\t" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-5.c b/gcc/testsuite/gcc.target/arm/pac-5.c new file mode 100644 index 00000000000..c70087eb6b6 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-5.c @@ -0,0 +1,28 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret+leaf -mthumb -mfloat-abi=hard --save-temps -O0" } */ + +#include + +int +__attribute__((noinline)) +foo1 (int a, int b) +{ + int square (int z) { return z * z; } + return square (a) + square (b); +} + +int +main (void) +{ + if (foo1 (1, 2) != 5) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-times "pac\tip, lr, sp" 3 } } */ +/* { dg-final { scan-assembler-times "aut\tip, lr, sp" 3 } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-6.c b/gcc/testsuite/gcc.target/arm/pac-6.c new file mode 100644 index 00000000000..c5329f0ef48 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-6.c @@ -0,0 +1,18 @@ +/* Check that GCC does .save and .cfi_offset directives with RA_AUTH_CODE pseudo hard-register. */ +/* { dg-do compile } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-options "-march=armv8.1-m.main+fp -mbranch-protection=pac-ret+leaf -mthumb --save-temps -O0 -g" } */ + +int i; + +void foo (int); + +int bar() +{ + foo (i); + return 0; +} + +/* { dg-final { scan-assembler "pac\tip, lr, sp" } } */ +/* { dg-final { scan-assembler "aut\tip, lr, sp" } } */ +/* { dg-final { scan-assembler-not "bti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-7.c b/gcc/testsuite/gcc.target/arm/pac-7.c new file mode 100644 index 00000000000..cdaebca5cfa --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-7.c @@ -0,0 +1,32 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret+leaf -mthumb -mfloat-abi=hard --save-temps -O0" } */ + +#include + +int +__attribute__((noinline)) +foo1 (int a, int b) +{ + int x = 4; + int foo2 (int a, int b) + { + return a + b + x; + } + return foo2 (a, b); +} + +int +main (void) +{ + if (foo1 (1, 2) != 7) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-times "pac\tip, lr, sp" 3 } } */ +/* { dg-final { scan-assembler-times "aut\tip, lr, sp" 3 } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac-8.c b/gcc/testsuite/gcc.target/arm/pac-8.c new file mode 100644 index 00000000000..3f37dcfa5c8 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac-8.c @@ -0,0 +1,34 @@ +/* Testing return address signing. */ +/* { dg-do run } */ +/* { dg-require-effective-target mbranch_protection_ok } */ +/* { dg-require-effective-target arm_pacbti_hw } */ +/* { dg-options "-march=armv8.1-m.main+pacbti+fp -mbranch-protection=pac-ret+leaf -mthumb -mfloat-abi=hard --save-temps -O0" } */ + +#include +#include + +int acc (int n, ...) +{ + int sum = 0; + va_list ptr; + + va_start (ptr, n); + + for (int i = 0; i < n; i++) + sum += va_arg (ptr, int); + va_end (ptr); + + return sum; +} + +int main() +{ + if (acc (3, 1, 2, 3) != 6) + abort (); + + return 0; +} + +/* { dg-final { scan-assembler-times "pac\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-times "aut\tip, lr, sp" 2 } } */ +/* { dg-final { scan-assembler-not "\tbti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/pac.h b/gcc/testsuite/gcc.target/arm/pac.h new file mode 100644 index 00000000000..7355e6b2954 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/pac.h @@ -0,0 +1,17 @@ +#include + +int +__attribute__((noinline)) +foo1 (int a, int b) +{ + return a + b; +} + +int +main (void) +{ + if (foo1 (1, 2) != 3) + abort (); + + return 0; +} 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: 508 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp951391pxh; Fri, 12 Aug 2022 08:41:35 -0700 (PDT) X-Google-Smtp-Source: AA6agR6zPdAGvvAyIkmvoqSCYcNUBp4F0XtQfBLBsRlDcX29GFliIdsaqa+WbMZgNcCR7qChlTv3 X-Received: by 2002:a17:907:2c42:b0:730:aacf:1b69 with SMTP id hf2-20020a1709072c4200b00730aacf1b69mr3032763ejc.381.1660318895347; Fri, 12 Aug 2022 08:41:35 -0700 (PDT) Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id s19-20020a50d493000000b0043dfb97250dsi2615870edi.599.2022.08.12.08.41.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:41:35 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="h4y4E/C2"; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2E1983858280 for ; Fri, 12 Aug 2022 15:41:34 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2E1983858280 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318894; 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=h4y4E/C2zIaCU05++aX/6lLneoSbX0A80yDJnl5cVYP9s1f9JhNukAPBSSOBZRQCi IPDTHpblMDtat2P41LVwYSp1YAPlTx4OtyBS7og8IsWmv+F8TZhIwxKBgsXjLGS+I6 aSmsLa58i8Elft8HgRXV0jG+yWPi3IFNdhJd2/jg= 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970545761141859?= X-GMAIL-MSGID: =?utf-8?q?1740970545761141859?= 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 From patchwork Fri Aug 12 15:41:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrea Corallo X-Patchwork-Id: 509 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6a10:38f:b0:2d5:3c95:9e21 with SMTP id 15csp952022pxh; Fri, 12 Aug 2022 08:42:49 -0700 (PDT) X-Google-Smtp-Source: AA6agR5vTQTnsyc8nmXmRuGBXNkHeECtG/HnPSWKlU7Z5i6gnx8rhPLSFqpBfHtwR/m03NKShQOs X-Received: by 2002:a17:907:c0d:b0:730:a85d:8300 with SMTP id ga13-20020a1709070c0d00b00730a85d8300mr3115250ejc.558.1660318968877; Fri, 12 Aug 2022 08:42:48 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id lw28-20020a170906bcdc00b00730a4246dd0si1881729ejb.593.2022.08.12.08.42.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 Aug 2022 08:42:48 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GbYWMLc1; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id A636C385842E for ; Fri, 12 Aug 2022 15:42:47 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A636C385842E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1660318967; bh=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; 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=GbYWMLc1GEneDZOnS/NrNIlLS8Dk+4qnjG6hF7Y95B20gopJgOm1jfxJgLettQ18f PnS3/KVdDeNe5PoCLAZh8+3J7FQCWEIBxfJTgWk6JDvKA01S7RU0BUdn+IE6kY40s0 yBQIUs3kEA85Z3UITYKDp5ZeL1eARe0PYA/qBshI= 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-eopbgr80082.outbound.protection.outlook.com [40.107.8.82]) by sourceware.org (Postfix) with ESMTPS id 58CCB3858D28 for ; Fri, 12 Aug 2022 15:42:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 58CCB3858D28 ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=Lo9h2iwLeCIv26iD6sUMOqZGhn9zQepqglXgl00vzpjYR6ROGANy4+RJQbBtkZjShnhOtfklaUPT5ehubS0Qi6BoknrHWObhfVXzZ35i12T5nmuu7UeGuovqrDItCmWCO6PP+JWhF0u1c6ePHK2Sv07PIUgcN7mqbEK33POp+YfWDN0nJPcQgd3/TLOI3jtLIIdV+5ejQSatsFgtydQoyDyRV/fipUU6vGo5v0KEwNjJ5eXECxkOkaCyLL9GHcceZGi5Wt+IfbHLtHC16UAMylGgGEEj1dFkj9OsFJ9w0XILTV1y5nI793xZvA8i582tOhhGdUebdmTfe7tuMinSpw== 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=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; b=eVJMNN94JFZSJQb3W7KpHEaiRikvf88W9IdaoDIqpXXDugoo5ho3GnvJ/B0nn/HyRP7KwRbnZ+BSBUbr98pmm1bhyk6uBumeHFe2hmFY4SyT8uRuRM/elYKmJ+qcyunp77Jxv3+EatT1A784bDXRWJ8YkgCfCWnjSqsdcwUYLxWv0kqUp9aQ0kF+LNsxNA7jycobJKqynKF2KYN4clcFjCgm9nK8PKNX/aIlgdPr7YppapCGGQIeTo4jMvtoip3L88kHGQbN6mqRMaQFA1ArIBhxm0eJHIq22TfFEdJil6yPBZFhmp8dm66DEHA2li5D8cWbi8G0om2iasbDohK5mA== 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 FR0P281CA0089.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:1e::11) by VI1PR08MB3199.eurprd08.prod.outlook.com (2603:10a6:803:46::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.16; Fri, 12 Aug 2022 15:41:57 +0000 Received: from VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:1e:cafe::ad) by FR0P281CA0089.outlook.office365.com (2603:10a6:d10:1e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.10 via Frontend Transport; Fri, 12 Aug 2022 15:41:57 +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 VE1EUR03FT043.mail.protection.outlook.com (10.152.19.122) 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:41:56 +0000 Received: ("Tessian outbound 73dd6a25223d:v123"); Fri, 12 Aug 2022 15:41:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: e65a04a6027dfbf3 X-CR-MTA-TID: 64aa7808 Received: from 39d03384b156.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id EAB0FE64-B1F7-4713-884B-E53C8ADD919A.1; Fri, 12 Aug 2022 15:41:48 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 39d03384b156.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Aug 2022 15:41:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lkUxq4ZeAgJ2HEE7KbmUlgxjZraq7ORgwW6mFIqs/v2YhAafh+Y96xJWkKWXvePaGkVBHTNqL+sZeT/EbbZVV3HlCIDWqHlgX+Ys2rOoXWMF4YATcsN44Y84xyo14MrE7+4GlRoSdI3VmIl/sZNgD0Ep9nE8NtcpbQefIYsD82Ujr5j5HWaN+ihclsl5o2N34rHZ/9tqM4maDDvGWjD4SBm5JKjYeWK8Lq1OhlC0frVIL+rwozK9oJrzYWHLaL9YzuBzZGxCjOnTjHNWY+wl3H/X8hCEruyL6Hjcz8ukPyNTEBT4C7Y66RIRG2vAQw8E0dP3+Aa1KsAVSu3y2BBzrA== 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=HAfcdaI5Xkx4Equxzg3jJdQmaNIRDdl2EnobdkTETNU=; b=T6APPmO+Sc3ji+vFzL0oSknuzwl4fjlMnOrk1CSA105f7qMKNLWr+EAbzgK+6VHi0/P+AtjjmHTU9FTUGYDUQfbRBXJ1rYS7h0ZVoGSv+fJBiiM04tQguEkpS/4+l974lxDw6tdl9+cwRaHLLPafoO1RSBINqyx8WrH0iwqathBOE2/9n3vkraAEtrztgouhrX9TFsOB1HZXwgdqJT5FklkMQzt56T+7lPb0xmJWix7JwrcnoHXI0olUPBzcDyjIBnQvbPko60MerZJkPMlUs9MJJ2hREGKljzhyRdEcI/W6LNcro5eZAi59sgmRuO/XXAdjj6xKJA4DGKbSI6DmeQ== 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 FR0P281CA0119.DEUP281.PROD.OUTLOOK.COM (2603:10a6:d10:a8::17) by AS8PR08MB7694.eurprd08.prod.outlook.com (2603:10a6:20b:509::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.25; Fri, 12 Aug 2022 15:41:45 +0000 Received: from VE1EUR03FT008.eop-EUR03.prod.protection.outlook.com (2603:10a6:d10:a8:cafe::68) by FR0P281CA0119.outlook.office365.com (2603:10a6:d10:a8::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.6 via Frontend Transport; Fri, 12 Aug 2022 15:41:44 +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 VE1EUR03FT008.mail.protection.outlook.com (10.152.18.75) 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:41:44 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX04.Arm.com (10.251.24.32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.9; Fri, 12 Aug 2022 15:41:43 +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:41:43 +0000 To: Andrea Corallo via Gcc-patches Subject: [PATCH 12/15] arm: implement bti injection References: Date: Fri, 12 Aug 2022 17:41:42 +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: 103e4a80-cf46-4099-4ddb-08da7c793061 X-MS-TrafficTypeDiagnostic: AS8PR08MB7694:EE_|VE1EUR03FT043:EE_|VI1PR08MB3199: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: Dij4ME4RCNIyX8YETfduu6/dcuABvZqdvQQ5uWB5gNddVv6Jn5ehEG3cqu8tiiuyETdwOTmCy1odF1z+Za0+ntSqG2momhRygaTF16Z++j3SYEipymhkBb4if4rp/Bc9fuvNcDQVQOwxKHr1aVjgSRyxXGMgJPmgQHBPZrd74fH7n0S0OW3vPhZTC0FcSYFebIuhJBQKk5SJlYf7rcZ0TO4Po1LL4cKbKlmAKelX0nWLF9cCgeMlMceo/lNtmwhVu8B05tnIJHCCupu6V8OBhLVcrgJ2h1s0ULO7MvwBdGo5zL0XmP2NaAlS3/POunTl4tQPLs8+CAg9Cw9XmnQ/MatexS/e3T/16MCawuUW+Lw7x2EMZ9/p7lZRGi98KiAkrzgWE1DRyRP7Yl6cVaAtf6/L6C+NkmXkdoTmI5CygCTtbh+pm9h1bd8TzQCOdSloHZAf0ZJRSYomgteuvqSF7WnB2Ihx7EhiQh+RG1BQpXVH3f+K6Xa6uoJ43Zqxgcj81zu9Po4vIMoE2bTO+souPKDTkF8JZi3zun1pWTuWD5HSOn7awPx+nU6uotxjQ4mfHPuNMGAbXfRNfmitu4mQyHLxzj7eKbbWNyV/Fo9SiplkZLXOaq8mA3MYBV6O1Rbtq5id4amHTfaKNGctACYLS8NZ7LCIK6y5sX6Hh9aKBDtSwOF8D68BH2SB0Ywu4j8XbFDGDB1SXsloI3IokUD82gKIl0bkvw0hWJ1mOKHKbfPwmvb+6kvqfSBwB+ig91qVQl/Q5dr77M2fk7wT3pUKtcXPWtuzruDBjjgOhEzs5QQ= 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)(346002)(376002)(136003)(396003)(36840700001)(46966006)(40470700004)(316002)(82740400003)(4326008)(8676002)(478600001)(83380400001)(6916009)(36756003)(70586007)(84970400001)(70206006)(54906003)(40480700001)(44832011)(86362001)(82310400005)(2906002)(5660300002)(40460700003)(356005)(8936002)(81166007)(235185007)(26005)(41300700001)(36860700001)(47076005)(186003)(2616005)(336012)(33964004)(426003)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-ExternalHop-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-ExternalHop-MessageData-0: 7RNh1xP3GtsWjca8pp8JTLaEE5tqWlcdjl3L7iVTJ9ynykVLJkXybFiiojziM84qLP6Vz+xJzb/+naABnwaSHEptcbUB2fh/fXjiZ/wHqBFtc+1rNMauW34w8sEqMxXc4NxnK1YsNBRQxvcEnw7d4y/sZeZewqGTKuJY0MpjAF+OtmphGGYLpCWZHAit0cFX/TVpKMimJ+j5yn8FDj5vJeUyc5ieZt7/IYHe3QTPwiuAW+768UDqIwKXjMhkFQ+npLkxQOSrnLAZbiI4MjZ1hBmfx2zu1G4bA6u8cZ/B3vFW5WrjjLX15PpgEzbPol6r4C2WgvF3h8gv6eo5av2KXsSnoLvFOPsDtw4jnSg929ewrb8Gw4CPS0csU+0SiAlEssRSsFXL0zrDhNdkPulHyTIgMJApgy6QrOvsvThfVUnxWCBLdLEGWF1Y7abTHMbOsqIpuwEh8CedSp9HzoiytL/BHuEyTtn114Rbsn9SGfQzTEHgCXLXeJ4YCmct7No4xvaY12PwWQANNj8pteaY1Zft8kNCW6sbQSE5X4SvLBybT6CCRaY1XK6P9Iw1TzBjNJRdGgkSVrMdjwbVx3PkfRnlwO7wN61JtAArF1AnbPxn9lY0q3HwkFlYobCoYlawFB7D8qhBRcRwZYcbeQUx1eyM+0ljdW/jBshA4YOq2Brn1M0jC5ZU1nqwkgfGDrxVGLiBK7+6bKTc7uVQs5WMxA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB7694 X-MS-Exchange-Transport-CrossTenantHeadersStripped: VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 38c559b8-cb49-4b2c-cc5d-08da7c792913 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /kMo1txpat9lhNddBez40shB6ZAGSZBG4/fCi5u8BWqWDMopA2OjkXGw5mhKbwCKemYQUZA9E6U+66muI4jb9ArXdkfWK5SFUBxL6R5mWb3KtxYSRRucC7GYeLwsC6r0lJw/QwYjj6txjC1cf8LfwcR2ikJxIMBtzyC7xaWskTF75b5k60QEcZnT9d3Jh0eHNuHsZ4cwW7b+zhdb91mzNC/rPO9Pct80+QV8hwSB8vR/+l1OhoZdml7iy1bfVUmjpyFe0mJdiQUQUVT1CifQA5xBMn+pdo/t+Nvlmbjd0uJ5yghH1DxbmfLAj3GFP8fm6dkWHk1qt9bmzr79nhBGWtmhGKh9QD1qv45et6kQr83gz+iS8absSmUWNnhm22MgffrhEKrfYKe8dmOoUzgQ5ptFgTlHA1vJsbXjMu2l3winhKjjHwB6qINKBSrp91qd3cUNw+DaeAC8A8eTiEDktfSTMe7JGf1zQBLZ1hgBkO7C24EycLBBoIJSwdMZW3ziLbK7OSzObaEHhPRJ/0ONZUUt4Mx0AmeOsIbuqQ6PhIpb9B9EE3MrfOcV+iv7xoObbM/gqpNTAtIi9yHLgEFDukrtYV5oW0J5kviahTpJ6qTAS+ky5uS7DS6tD3HTg5oAGxGSVn+C2xSDN8OTIthTp5QHPpwk8cXJtYi/9bpyjCNdh2MT5cISS2xIS1svaGKgwBseWBZShp+XRFZ+NgkS9/BpWbsX702C6kyR7xFCJtacDh96njZx0Xff9OWKDXI5z4tXrlDyYWdzMVmlEFXqfRAVggaSac10VBZft8/lcyHu7TwTEkAsoTVazwHa0w4+kiFmiYt/XQ8xAkwKYqG8gWqQ62hesaHipvf/d/JKz9RRy45ed8d7rcdpIbSRg09K 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)(376002)(346002)(396003)(136003)(39860400002)(46966006)(36840700001)(40470700004)(2906002)(5660300002)(26005)(82740400003)(4326008)(478600001)(54906003)(33964004)(40460700003)(70586007)(6916009)(86362001)(8676002)(36860700001)(36756003)(41300700001)(81166007)(40480700001)(70206006)(186003)(316002)(336012)(82310400005)(84970400001)(83380400001)(426003)(47076005)(2616005)(8936002)(235185007)(44832011); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Aug 2022 15:41:56.9198 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 103e4a80-cf46-4099-4ddb-08da7c793061 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: VE1EUR03FT043.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR08MB3199 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+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1740970623415455837?= X-GMAIL-MSGID: =?utf-8?q?1740970623415455837?= Hi all, this patch enables Branch Target Identification Armv8.1-M Mechanism [1]. This is achieved by using the bti pass made common with Aarch64. The pass iterates through the instructions and adds the necessary BTI instructions at the beginning of every function and at every landing pads targeted by indirect jumps. Best Regards Andrea [1] gcc/ChangeLog 2022-04-07 Andrea Corallo * config.gcc (arm*-*-*): Add 'aarch-bti-insert.o' object. * config/arm/arm-protos.h: Update. * config/arm/arm.cc (aarch_bti_enabled, aarch_bti_j_insn_p) (aarch_pac_insn_p, aarch_gen_bti_c, aarch_gen_bti_j): New functions. * config/arm/arm.md (bti_nop): New insn. * config/arm/t-arm (PASSES_EXTRA): Add 'arm-passes.def'. (aarch-bti-insert.o): New target. * config/arm/unspecs.md (UNSPEC_BTI_NOP): New unspec. * config/arm/aarch-bti-insert.cc (rest_of_insert_bti): Update to verify arch compatibility. * config/arm/arm-passes.def: New file. gcc/testsuite/ChangeLog 2022-04-07 Andrea Corallo * gcc.target/arm/bti-1.c: New testcase. * gcc.target/arm/bti-2.c: Likewise. diff --git a/gcc/config.gcc b/gcc/config.gcc index 2021bdf9d2f..004e1dfa8d8 100644 --- a/gcc/config.gcc +++ b/gcc/config.gcc @@ -353,7 +353,7 @@ arc*-*-*) ;; arm*-*-*) cpu_type=arm - extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o" + extra_objs="arm-builtins.o arm-mve-builtins.o aarch-common.o aarch-bti-insert.o" extra_headers="mmintrin.h arm_neon.h arm_acle.h arm_fp16.h arm_cmse.h arm_bf16.h arm_mve_types.h arm_mve.h arm_cde.h" target_type_format_char='%' c_target_objs="arm-c.o" diff --git a/gcc/config/arm/aarch-bti-insert.cc b/gcc/config/arm/aarch-bti-insert.cc index 2d1d2e334a9..8f045c247bf 100644 --- a/gcc/config/arm/aarch-bti-insert.cc +++ b/gcc/config/arm/aarch-bti-insert.cc @@ -41,6 +41,7 @@ #include "cfgrtl.h" #include "tree-pass.h" #include "cgraph.h" +#include "diagnostic-core.h" /* This pass enables the support for Branch Target Identification Mechanism for Arm/AArch64. This is a security feature introduced in ARMv8.5-A diff --git a/gcc/config/arm/arm-passes.def b/gcc/config/arm/arm-passes.def new file mode 100644 index 00000000000..71d6b563640 --- /dev/null +++ b/gcc/config/arm/arm-passes.def @@ -0,0 +1,21 @@ +/* Arm-specific passes declarations. + Copyright (C) 2022 Free Software Foundation, Inc. + Contributed by Arm Ltd. + + This file is part of GCC. + + GCC is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3, or (at your option) + any later version. + + GCC is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with GCC; see the file COPYING3. If not see + . */ + +INSERT_PASS_BEFORE (pass_shorten_branches, 1, pass_insert_bti); diff --git a/gcc/config/arm/arm-protos.h b/gcc/config/arm/arm-protos.h index 84764bf27ce..6befb6c4445 100644 --- a/gcc/config/arm/arm-protos.h +++ b/gcc/config/arm/arm-protos.h @@ -24,6 +24,8 @@ #include "sbitmap.h" +rtl_opt_pass *make_pass_insert_bti (gcc::context *ctxt); + extern enum unwind_info_type arm_except_unwind_info (struct gcc_options *); extern int use_return_insn (int, rtx); extern bool use_simple_return_p (void); diff --git a/gcc/config/arm/arm.cc b/gcc/config/arm/arm.cc index 31c6bcdea55..de5a679c92a 100644 --- a/gcc/config/arm/arm.cc +++ b/gcc/config/arm/arm.cc @@ -23368,12 +23368,6 @@ output_probe_stack_range (rtx reg1, rtx reg2) return ""; } -static bool -aarch_bti_enabled () -{ - return false; -} - /* Generate the prologue instructions for entry into an ARM or Thumb-2 function. */ void @@ -32985,6 +32979,58 @@ arm_current_function_pac_enabled_p (void) && !crtl->is_leaf); } +/* Return TRUE if Branch Target Identification Mechanism is enabled. */ +bool +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) == UNSPEC_BTI_NOP; +} + +/* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ +bool +aarch_pac_insn_p (rtx x) +{ + if (!x || !INSN_P (x)) + return false; + + rtx pat = PATTERN (x); + + if (GET_CODE (pat) == SET) + { + rtx tmp = XEXP (pat, 1); + if (tmp + && GET_CODE (tmp) == UNSPEC + && (XINT (tmp, 1) == UNSPEC_PAC_NOP + || XINT (tmp, 1) == UNSPEC_PACBTI_NOP)) + return true; + } + + return false; +} + +rtx +aarch_gen_bti_c (void) +{ + return gen_bti_nop (); +} + +rtx +aarch_gen_bti_j (void) +{ + return gen_bti_nop (); +} + /* Implement TARGET_SCHED_CAN_SPECULATE_INSN. Return true if INSN can be scheduled for speculative execution. Reject the long-running division and square-root instructions. */ diff --git a/gcc/config/arm/arm.md b/gcc/config/arm/arm.md index 92269a7819a..90c8c1d66f5 100644 --- a/gcc/config/arm/arm.md +++ b/gcc/config/arm/arm.md @@ -12913,6 +12913,13 @@ "aut\t%|ip, %|lr, %|sp" [(set_attr "length" "4")]) +(define_insn "bti_nop" + [(unspec_volatile [(const_int 0)] UNSPEC_BTI_NOP)] + "arm_arch7 && arm_arch_cmse" + "bti" + [(set_attr "length" "4") + (set_attr "type" "mov_reg")]) + ;; Vector bits common to IWMMXT, Neon and MVE (include "vec-common.md") ;; Load the Intel Wireless Multimedia Extension patterns diff --git a/gcc/config/arm/t-arm b/gcc/config/arm/t-arm index 041cc6ec045..683342cb528 100644 --- a/gcc/config/arm/t-arm +++ b/gcc/config/arm/t-arm @@ -175,3 +175,13 @@ arm-d.o: $(srcdir)/config/arm/arm-d.cc arm-common.o: arm-cpu-cdata.h driver-arm.o: arm-native.h + +PASSES_EXTRA += $(srcdir)/config/arm/arm-passes.def + +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 + $(COMPILER) -c $(ALL_COMPILERFLAGS) $(ALL_CPPFLAGS) $(INCLUDES) \ + $(srcdir)/config/arm/aarch-bti-insert.cc diff --git a/gcc/config/arm/unspecs.md b/gcc/config/arm/unspecs.md index dbe243a03f6..78e723a4b3c 100644 --- a/gcc/config/arm/unspecs.md +++ b/gcc/config/arm/unspecs.md @@ -162,6 +162,7 @@ UNSPEC_PAC_NOP ; Represents PAC signing LR UNSPEC_PACBTI_NOP ; Represents PAC signing LR + valid landing pad UNSPEC_AUT_NOP ; Represents PAC verifying LR + UNSPEC_BTI_NOP ; Represent BTI ]) diff --git a/gcc/testsuite/gcc.target/arm/bti-1.c b/gcc/testsuite/gcc.target/arm/bti-1.c new file mode 100644 index 00000000000..230ebb5a1da --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/bti-1.c @@ -0,0 +1,12 @@ +/* Check that GCC does bti instruction. */ +/* { dg-do compile } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main -mthumb -mbranch-protection=bti --save-temps" } */ + +int +main (void) +{ + return 0; +} + +/* { dg-final { scan-assembler "bti" } } */ diff --git a/gcc/testsuite/gcc.target/arm/bti-2.c b/gcc/testsuite/gcc.target/arm/bti-2.c new file mode 100644 index 00000000000..35aef6992e2 --- /dev/null +++ b/gcc/testsuite/gcc.target/arm/bti-2.c @@ -0,0 +1,58 @@ +/* { dg-do compile } */ +/* -Os to create jump table. */ +/* { dg-options "-Os" } */ +/* { dg-skip-if "avoid conflicting multilib options" { *-*-* } { "-marm" "-mcpu=*" } } */ +/* { dg-options "-march=armv8.1-m.main -mthumb -mbranch-protection=bti --save-temps" } */ + +extern int f1 (void); +extern int f2 (void); +extern int f3 (void); +extern int f4 (void); +extern int f5 (void); +extern int f6 (void); +extern int f7 (void); +extern int f8 (void); +extern int f9 (void); +extern int f10 (void); + +int (*ptr) (void); + +int +f_jump_table (int y, int n) +{ + int i; + for (i = 0; i < n ;i ++) + { + switch (y) + { + case 0 : ptr = f1; break; + case 1 : ptr = f2; break; + case 2 : ptr = f3; break; + case 3 : ptr = f4; break; + case 4 : ptr = f5; break; + case 5 : ptr = f6; break; + case 6 : ptr = f7; break; + case 7 : ptr = f8; break; + case 8 : ptr = f9; break; + case 9 : ptr = f10; break; + default: break; + } + y += ptr (); + } + return (y == 0)? y+1:4; +} + +int +f_label_address () +{ + static void * addr = &&lab1; + goto *addr; +lab1: + addr = &&lab2; + return 1; +lab2: + addr = &&lab1; + return 2; +} + +/* { dg-final { scan-assembler-times "bti" 15 } } */