From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60063.outbound.protection.outlook.com [40.107.6.63]) by sourceware.org (Postfix) with ESMTPS id EAA603858D39 for ; Tue, 27 Sep 2022 09:19:13 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EAA603858D39 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com ARC-Seal: i=2; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=pass; b=U4P1c1ufEuH0Ht7tdAV1SVWlsWzL8Uv0wzZcRqhPGNOLWya0zevJslbAN6oQgDb4vhqkCCUI1OwR4fAzv54q0s8Fk+33EKFVHaSMi0dJJ+phLjUxEJMaWejW0Z3Jhqq9xaXKaYoqm15Z0ccaL7eqpVaHtnGZYzITrdcc94EocpiMtiUBfWSdZtIpifmEivVTGec5ZeoWwd71Mdc+QQOMhjFPHwHEFx0RY1N1UlKYM0v8idyM8Dr7V2UoFT9+hp/+eEha6d8ihUZu7f9zenqH4Hg4580cpxO+1x9lPFUs5lb8BbMZkhya4GHnBBmccQoEghgNkhnM964aVnONfvrTeg== 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=Ya1CrVO8QXqq0mGS7T3DdBXL6iYCQQaqEu5fE3TS9To=; b=k2cDwzTN9CJ3ijh7OAVPkihuCFBGVd4mhROgBVzF924DzTVWzxTbmpoXufR16T7BoGtCG6OxrNWZWqhbdR+WIo6yUOWrXG6ttVC6s+j+IyMtSkzWQ4RVHCG3rlTOWoKQfXvb/TPPZWUUQ8JkNGmVXdZX1vFTM9Pud8iudXoKBSor9negFZkMieZYVCPif85lvdWHcJ3E5AxbhbepY3PzogRjN5DaAhqdGvft1tUBeD1K7Uux5P2eQ4JBaxjtEM+fEGsY1OT5Q2gztE3VF4OukwfZAOWxnqkJbUs7FdHzNaxLam82T0yW/9wDYDcEO5xtsB5ffmW+rFYgTSqZjzubyA== 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] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com]) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ya1CrVO8QXqq0mGS7T3DdBXL6iYCQQaqEu5fE3TS9To=; b=QBiN5ccvlRV892jZxjJQ3FWhO5OFFduO5PKkCBhoz5NL83LeU/rHNSbttoipP+ArXG2crf8iY/qF6TXH5SnXKJAJyhO158vwJeYXDnpje/SRD2X1mVEjvH6RhhSryAFL4uY+kiDbh3ybwcfsOz0oputSz4858FUKC3jJh34Scvc= Received: from AS9PR04CA0174.eurprd04.prod.outlook.com (2603:10a6:20b:530::15) by GV1PR08MB8215.eurprd08.prod.outlook.com (2603:10a6:150:5e::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.15; Tue, 27 Sep 2022 09:19:10 +0000 Received: from AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:530:cafe::6a) by AS9PR04CA0174.outlook.office365.com (2603:10a6:20b:530::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.15 via Frontend Transport; Tue, 27 Sep 2022 09:19:10 +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 AM7EUR03FT009.mail.protection.outlook.com (100.127.140.130) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Tue, 27 Sep 2022 09:19:10 +0000 Received: ("Tessian outbound 88978e6d60db:v124"); Tue, 27 Sep 2022 09:19:09 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 349f42be0ceecbf9 X-CR-MTA-TID: 64aa7808 Received: from aee5efdeb4bf.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 692DAB7B-A3A0-4F51-BC39-4BADED16A652.1; Tue, 27 Sep 2022 09:19:00 +0000 Received: from EUR01-DB5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id aee5efdeb4bf.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 27 Sep 2022 09:19:00 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dTyPUp7HmebRHxlYoBfgaFmYYciRfqzd4ycC6HDjx55OC5DL4BY2EQ/rnQyQPAEnrj6x4cOnUPU4VSzFwu6bLp6g1YjJYmBDeEQh3fu9XG0j9hUE/AqWjNUurMYp6l1SBRRxqGzNFCECGS8yadzMmFbKt8a+fdhalBOV2nWQaT8P33nV8EIZ/Jn9aq+Pr/cUUN8QSXFurJGNqV6bibsRaT5c7Fr+G2OfK2ZFDvSx+EZfXJ+/MdOExSV3rxKjE7xss65AsqT7o2yJXR4AZ0mLYQMJn9urAZ57fh2OSt6N3djbzq2KMkz3mzmPmJTL1sxIuOolw2oe6cQmCgEa8seUyg== 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=Ya1CrVO8QXqq0mGS7T3DdBXL6iYCQQaqEu5fE3TS9To=; b=drgTOVonkt1Fr7FB63EdFyp4srQ3FCibbjjTNHIA+j5/HDc7ktp0rFGJxco2gjkaQJLschEfLWM2KuN+9FVf3vCHo6HPUa7Hvwujg+5jX8UN3UUOsR6TfstHp1nRT+coa6CHLze1STgZXSrKAE/GNJfFvEUHczKCr7baHLtV1e3H1URJ/D3WgpP4HBsWXTsZEwPHY+1yACCj2CL6jx5m6Dc2slJK3hS1KJachAwkzOPFlCri0MSmjFVMsyALpR4TanQjz1DhTCviRSQQuSrCY77SJE7t9CKX1I3lxnO90kyNFqX9sUNU29D8lMM0UAuXIIMAkzPbebxcUDGuq2w85w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Ya1CrVO8QXqq0mGS7T3DdBXL6iYCQQaqEu5fE3TS9To=; b=QBiN5ccvlRV892jZxjJQ3FWhO5OFFduO5PKkCBhoz5NL83LeU/rHNSbttoipP+ArXG2crf8iY/qF6TXH5SnXKJAJyhO158vwJeYXDnpje/SRD2X1mVEjvH6RhhSryAFL4uY+kiDbh3ybwcfsOz0oputSz4858FUKC3jJh34Scvc= Received: from PAXPR08MB6926.eurprd08.prod.outlook.com (2603:10a6:102:138::24) by DU0PR08MB9727.eurprd08.prod.outlook.com (2603:10a6:10:445::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Tue, 27 Sep 2022 09:18:54 +0000 Received: from PAXPR08MB6926.eurprd08.prod.outlook.com ([fe80::f0a0:ab7d:81bb:aff8]) by PAXPR08MB6926.eurprd08.prod.outlook.com ([fe80::f0a0:ab7d:81bb:aff8%9]) with mapi id 15.20.5654.026; Tue, 27 Sep 2022 09:18:54 +0000 From: Kyrylo Tkachov To: Andrea Corallo , Andrea Corallo via Gcc-patches CC: Richard Earnshaw , nd Subject: RE: [PATCH 12/15] arm: implement bti injection Thread-Topic: [PATCH 12/15] arm: implement bti injection Thread-Index: AQHYrmI8UeNz+gxbH0uv5QVAvyVG8K3zRVyA Date: Tue, 27 Sep 2022 09:18:54 +0000 Message-ID: References: In-Reply-To: Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: Authentication-Results-Original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; x-ms-traffictypediagnostic: PAXPR08MB6926:EE_|DU0PR08MB9727:EE_|AM7EUR03FT009:EE_|GV1PR08MB8215:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d31b3a8-c04e-4de1-7299-08daa0695600 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: vIri2gpmL1gN6QIAXqa4i0HaM1lCG7LevHJQcoKuUx64uzU+SfmxVih3OHNH+IXjK5cAH/hj8jYlZmq+HVpW8h2NRFQ+4m/qL6NrI3a2rpAaQJoksa/6F3P+SOPzLzkVq6KFvGovz8snwTTkqz5Nr6CZGRUpCGyJmPkgGrLrjRL5y3bJ0M2x/W0oQSjSzMVDyXh5WZkD8AxUx69itGER/qRNOVtPMZf7F8nGSbGA3tixPJQFsKbFJ6+4npbnldsn4+sJfVCQRiVw81BAmqogsYtff8nESpN5iyvk7vMCOCEFg0mKaF3QBCYAK/LX7qxULjwwsPKrfsNIOhy9W7qBMIjQcMtKTloB15CPEkS7kd+Qydp66Q6w/zTy7lQrqOUplx+dVwy3jju0rcxJfQWGH1Z+Lh3Tagfr8du3weiRlk2mQGwmNyBY6b8Qfb84NtlhcvKB8UFRjpbkbDanl196q1lE9et5UUtCL43S+EtaLOnZlDB5Ih2fbB8Y9dG4YnItnbJZ/XTWKr7ES1sS4Ut63uHo3xDXJSOLbUFl9ysJfV4pBT+Swyyc6mCm1RiIlpAnxLpkObhP4+DeUShfR5l6pP6+wvGgaFnnWjYSEHnvXg+luM9gYD7cFtPt7kQehKvnUlseaGEpeWgB/WiCt/vVvjBnLFspLscyaxye1golOH4+5WmcabFgns9lEnFx3vcCda7qPf8pXB+G7wQefF79NPDPx2y9hT/YbIWhIqhU5RI9WauRXFKpOxMXbwxSaBfasUF52yi6j+jruo5QfZ9OPG/pLZ3eG/eHGeYYERPipK5BMPQES3l+MfjFtBcbcvNvQC8/Ykvjc6Z/CTORWnjy4w== X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR08MB6926.eurprd08.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230022)(4636009)(346002)(376002)(136003)(39860400002)(366004)(396003)(451199015)(66946007)(52536014)(8936002)(5660300002)(66556008)(33656002)(66476007)(122000001)(86362001)(2906002)(38070700005)(38100700002)(84970400001)(66446008)(8676002)(55016003)(53546011)(186003)(6506007)(478600001)(41300700001)(26005)(71200400001)(64756008)(9686003)(83380400001)(54906003)(76116006)(4326008)(7696005)(316002)(110136005);DIR:OUT;SFP:1101; Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB9727 Original-Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bdc423ac-f132-4744-2b8d-08daa0694cae X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8dg2jZpk7g3ne15cf8UuT+7RhfnYL3yN7en8Z6qZl6U9ymYNZSepeiph80lfT1PbDvbxyes1ejgmjbnv0BrIkeeMa47vEzlcyWyGxIwiiu34F+DerMrjIO2FApq2dVuKPS6SgMzWUQbb0hp/roHJtO4nTGL+E7tGQTX5zdGqsQVGmVcvd43DbEO2fscUiFsHRl4WL62rTrHfLgUtmojBUnvB8Gi9KEjgNvP+jCTgdmSqlKkepmHpP//qmO5URN0XefM5d/sL1p/trS19/cH56vqgKq660kW6ovamOEtYx9LZzM7Krf+F5s4vnrzsmiHLLctCdURFjuP8QfBONcD+9FnyWIm8Wij0Pk019shkb5I+nvueUQP994j0rRxCU2HRrW6x+WqTxRyf39AxZaJ7mMXGfxjW52rVaxI3FQrODwiOlCIRBQ2Wa0UP+lRp9Z4+HzPddzOMa2a48vHF+WCHkT8GuTwbqsX1qVO6wb3RVOly+q1t1qqWQI18bGpVECf5xoow+6u/L/aGabX8YRlzXfmByr+Bdew91oGkQkd7Mai25SliyZ7yXFzDUmT8yHZ0njHL3mMzL0l8bw//9fBNLkyTKmWcSr9Mk/1VUQMm2x0CagXby9g6QZby5KQcLX/Z3HBllCPy391WAQSsg/UN2U/MD5vH8IuFkvnXISUHfJVlA43Z77InS6dFHOHAJVtmvb7yZ8g12gevzG+Ubcpe7AAlZ9hjik2M8VTWWKDJFSR8G/9Ud2Yhi+RSbk/lWoiaWmGRc46tWprHKBCyRQ+WbmOyrfs3LiIyZ9T5J3tuLjcRH1SHM3gBOZbn2wuP/TFpSh55yrasOhLQB8tQmjIqwg== 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:(13230022)(4636009)(396003)(346002)(136003)(376002)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(186003)(336012)(26005)(9686003)(47076005)(356005)(83380400001)(6506007)(7696005)(53546011)(54906003)(81166007)(70206006)(40460700003)(70586007)(4326008)(8676002)(33656002)(478600001)(41300700001)(84970400001)(316002)(36860700001)(2906002)(86362001)(82310400005)(8936002)(5660300002)(82740400003)(40480700001)(110136005)(55016003)(52536014);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Sep 2022 09:19:10.0601 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d31b3a8-c04e-4de1-7299-08daa0695600 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: AM7EUR03FT009.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: GV1PR08MB8215 X-Spam-Status: No, score=-11.6 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,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 List-Id: Hi Andrea, > -----Original Message----- > From: Gcc-patches bounces+kyrylo.tkachov=3Darm.com@gcc.gnu.org> On Behalf Of Andrea > Corallo via Gcc-patches > Sent: Friday, August 12, 2022 4:42 PM > To: Andrea Corallo via Gcc-patches > Cc: Richard Earnshaw ; nd > Subject: [PATCH 12/15] arm: implement bti injection >=20 > Hi all, >=20 > this patch enables Branch Target Identification Armv8.1-M Mechanism > [1]. >=20 > This is achieved by using the bti pass made common with Aarch64. >=20 > 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. >=20 > Best Regards >=20 > Andrea >=20 > [1] > products/processors/b/processors-ip-blog/posts/armv8-1-m-pointer- > authentication-and-branch-target-identification-extension> >=20 > gcc/ChangeLog >=20 > 2022-04-07 Andrea Corallo >=20 > * 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. >=20 > gcc/testsuite/ChangeLog >=20 > 2022-04-07 Andrea Corallo >=20 > * gcc.target/arm/bti-1.c: New testcase. > * gcc.target/arm/bti-2.c: Likewise. 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" =20 This change doesn't seem to match what's in the ChangeLog and doesn't make = sense to me. @@ -32985,6 +32979,58 @@ arm_current_function_pac_enabled_p (void) && !crtl->is_leaf); } =20 +/* Return TRUE if Branch Target Identification Mechanism is enabled. */ +bool +aarch_bti_enabled (void) +{ + return aarch_enable_bti =3D=3D 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 =3D PATTERN (insn); + return GET_CODE (pat) =3D=3D UNSPEC_VOLATILE && XINT (pat, 1) =3D=3D UNS= PEC_BTI_NOP; +} + +/* Check if X (or any sub-rtx of X) is a PACIASP/PACIBSP instruction. */ The arm instructions are not PACIASP/PACIBSP. This comment should be rewritten. +bool +aarch_pac_insn_p (rtx x) +{ .......... +rtx +aarch_gen_bti_c (void) +{ + return gen_bti_nop (); +} + +rtx +aarch_gen_bti_j (void) +{ + return gen_bti_nop (); +} + A reader may be confused for why we have a bti_c and bti_j function that ha= ve identical functionality. Please add function comments explaining the situation. 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")]) =20 +(define_insn "bti_nop" + [(unspec_volatile [(const_int 0)] UNSPEC_BTI_NOP)] + "arm_arch7 && arm_arch_cmse" That seems like a copy-paste mistake. CMSE has nothing to do with this func= tionality? + "bti" + [(set_attr "length" "4") The length of instructions in the arm backend is 4 by default, this set_att= r can be omitted + (set_attr "type" "mov_reg")]) + Probably better to use the "nop" attribute here? Thanks, Kyrill