From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on2065.outbound.protection.outlook.com [40.107.6.65]) by sourceware.org (Postfix) with ESMTPS id F1425384FE94 for ; Mon, 12 Dec 2022 14:55:20 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org F1425384FE94 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=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=O18/X63uOMlDO1WfJxM1epTxqrlnAiFWK9oqxAamIaY=; b=EijKpGk8+cYFOxxbaxcTsGk3UwlIQRMNMVBBtBS2mIhf7bvgyM5qxqTJrq3ldevMN/uVdrXq3T94qQ0NO1M+wDVGR2isRrHIiN0W9iZJa7UMgPG6n8gmhzPd7Z6xx7x0m/SvLSmUpRAkorh3tL97hy21Uec7vrCsyMblRy0gNHo= Received: from DB6PR0301CA0075.eurprd03.prod.outlook.com (2603:10a6:6:30::22) by DU0PR08MB7836.eurprd08.prod.outlook.com (2603:10a6:10:3b3::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.9; Mon, 12 Dec 2022 14:55:15 +0000 Received: from DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com (2603:10a6:6:30:cafe::5d) by DB6PR0301CA0075.outlook.office365.com (2603:10a6:6:30::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.8 via Frontend Transport; Mon, 12 Dec 2022 14:55:15 +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 DBAEUR03FT013.mail.protection.outlook.com (100.127.142.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5901.21 via Frontend Transport; Mon, 12 Dec 2022 14:55:15 +0000 Received: ("Tessian outbound 2ff13c8f2c05:v130"); Mon, 12 Dec 2022 14:55:15 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 5e9ac31e5dcd9fdc X-CR-MTA-TID: 64aa7808 Received: from af8be75478ec.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 94083BD4-C067-4D51-A806-E77B3904A899.1; Mon, 12 Dec 2022 14:54:37 +0000 Received: from EUR03-DBA-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id af8be75478ec.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 12 Dec 2022 14:54:37 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TeJYwLJVc3c7syayB6C7vN/HrZr4RqFQsf9nyOa8mvLTH3FsGnZnNRpOojJk3erYjdEI95RviN2JFSY8GVZ7VqR9SEdilJTfbljpid5e6xvduZgpStbA33yewCkJTufxjG3KwI9DrCbk9Z/YVjWUkp5uJl46Z88Hi1HNBOROT3MN2gDCzCmBfltkNiGqgqVaMOHshD9C/j8nfTqy1LmffIbeSIDjOquYQPA2VzTcDCpm+M8zxA5m+9zBdiwAIZSLwDmsHdid/6wU+BYU/c8RWsXS74YPS5ZPIhqYs1gry6z9HU8Mkj2ytNKGambBFOX1zyy+zPEJ2PtTWuOZTpEJig== 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=O18/X63uOMlDO1WfJxM1epTxqrlnAiFWK9oqxAamIaY=; b=loSMr9hPie8rUJoHARTaEOT9tKpcnjiCGHK9bdpofm9QxN1DMD8d2gUCyMb/XmKuts7ncT2OCiay3VLxOherMB5Fmt0/FsJdnCkMBnEnafo26EvcnWRUzEOcwrpWiDyDpNZDsFPq01Zv+G2Trqkzio57Js3ty0lENej2UxSyy3FU2ANdJBs+S/JOR277SelBoQ7usA4v3vChoRL0kybA+rOddt9ijOE4bB7O+kD1Oue+hQqXlAIaphagi/okzM6HLl9rQ+HBZx5ged4lr99TVx/ufhMfsJT/9TVxIz2n90xfDEfNBXvoq/KsEFADYgQjt4g75659CytMFfbhyCbv5Q== 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 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=O18/X63uOMlDO1WfJxM1epTxqrlnAiFWK9oqxAamIaY=; b=EijKpGk8+cYFOxxbaxcTsGk3UwlIQRMNMVBBtBS2mIhf7bvgyM5qxqTJrq3ldevMN/uVdrXq3T94qQ0NO1M+wDVGR2isRrHIiN0W9iZJa7UMgPG6n8gmhzPd7Z6xx7x0m/SvLSmUpRAkorh3tL97hy21Uec7vrCsyMblRy0gNHo= Received: from AM5PR0502CA0005.eurprd05.prod.outlook.com (2603:10a6:203:91::15) by AS8PR08MB8946.eurprd08.prod.outlook.com (2603:10a6:20b:5b4::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5924.8; Mon, 12 Dec 2022 14:54:35 +0000 Received: from VI1EUR03FT016.eop-EUR03.prod.protection.outlook.com (2603:10a6:203:91:cafe::34) by AM5PR0502CA0005.outlook.office365.com (2603:10a6:203:91::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5880.10 via Frontend Transport; Mon, 12 Dec 2022 14:54:35 +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 VI1EUR03FT016.mail.protection.outlook.com (100.127.144.158) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5901.21 via Frontend Transport; Mon, 12 Dec 2022 14:54:35 +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.16; Mon, 12 Dec 2022 14:54:34 +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.16 via Frontend Transport; Mon, 12 Dec 2022 14:54:33 +0000 From: Andrea Corallo To: Richard Earnshaw CC: Richard Earnshaw , nd , "Andrea Corallo via Gcc-patches" Subject: Re: [PATCH 9/12 V2] arm: Make libgcc bti compatible References: <6c251f00-6b73-110c-d2b3-5e115ed6912b@foss.arm.com> <86a735ce-f41c-967c-45cd-8e3965d283bf@foss.arm.com> Date: Mon, 12 Dec 2022 15:54:33 +0100 In-Reply-To: <86a735ce-f41c-967c-45cd-8e3965d283bf@foss.arm.com> (Richard Earnshaw's message of "Mon, 25 Jul 2022 11:41:34 +0100") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: VI1EUR03FT016:EE_|AS8PR08MB8946:EE_|DBAEUR03FT013:EE_|DU0PR08MB7836:EE_ X-MS-Office365-Filtering-Correlation-Id: cbf627e7-b1d5-4664-8ebb-08dadc50e102 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: IAygQsdA3t+mD2PTifef49V999aDskzYYQaUPDd9ByvwzKt93aqRp6rj8cpWhAi0mUuJjCFAnTQiMVOq7aZD+Em8t8TnT005nXs0YZpBdiFGoyLBWh2J8nBLour5i8v0yRPn177uTvI/hIx4OZXuP6bcbyF9G8+y+NwXXgDb6dexo+7NwUrugtO+8eB0bPtGkpONIpG/WqTbsQjPh8hCZXZddJjRXD0/+Wwiu1JUf96pxmbBb8OFKWnJnmAdwqzdh7bq7jq41glAHyp0gdRNZ8wZQDxnMEpx57/+GYVeusvDd7HkE7UItaxIiKyNGdO3brnWyraKBQj1vCH4SrzL3aqfx6cN4xqCzPxyirf/USHMJeUSOtflP4c+NaY/OX7OP7vWBArV+3c2kwyD6EW+mQITExWHAQbQaH+gWzbd7xqLXvZGokal51pjpq67rCyQ5HEQypml4ZfLsnaI8osNESbOUPYAN6Z2hVxrgpgRnvcDVUgxlDxcvfer3Qfv1X11IpDRW6ckuIsGFka4o5mt/JnvOhHRQDe+bkzN5qyRRt53hzkUSiMsZ5ZgRxKfLt19vQ1LAP1WTg7qJ8dt/i07dAUo4bTJCRKbyFHoheFXhdKKQJNch7dlFbixNDloL3af4siBH1VwIpJ/QCMJeOD7Esn5NxucgFErUV/HFVqTxgZ6PpzdWFaVKrIAbm42/BPpXY20Q64ni/WMJ+PTvLxqVQ== 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:(13230022)(4636009)(39860400002)(396003)(346002)(136003)(376002)(451199015)(46966006)(36840700001)(316002)(8936002)(54906003)(6862004)(70586007)(5660300002)(8676002)(4326008)(36860700001)(41300700001)(26005)(36756003)(53546011)(70206006)(82310400005)(86362001)(426003)(336012)(83380400001)(2616005)(186003)(47076005)(478600001)(2906002)(356005)(81166007)(82740400003)(44832011)(40480700001)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8946 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 822a043b-fe90-4031-9df9-08dadc50c924 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZoGUCdZqo6KrS+df92RyLPyaRmsNnIPRiT5zU5Hg/yqHvdNYl0dhmwSfWejzEcsEDIjDqckALsRlMgkYECECb3A6MZC6Nm6fMy92m+ImgUWxwc5Ll75mvN9UjGK1+3KkS3PyhF2DRLiQj9g8O4cMErBggLsN1rfwl/QYpQ0p2fmEFx0XTXULD7BEyW4TDFUp9Fyn+22IxpE79LOSNfkroPtLxMpZL9px1M5cyzuZrIcYxf2MRIGJLBfNREJ9/7n4STAGn2x+9JClZbpgDJ03+HVyRtToAqY8HgDVIUzwlpN59gkwzqwv37u+en9S+S/w+Q1wck866Mynn1ery5E2Xtu5EokaapCjHWZJAmWZ6TpsmGuMn8j/adwgOC0b1AABccP8nDFB6P5nlWqwmoZ1BMYgUpXE5UeiLmRnO1039ghmDN22m8Ng/EvkOb1dv36NZw+l90vBD54rQT4INObZJmQgBxYnSbIoCD9JCUVdB7//f/pySCgOpqj41OL5HKvpTv05SR43o7+6zKP31anjLXIPeXRq/8PYQ4R1E7y2DgILkui8PrnpAVEB5e6U/aWk7gTKgN/NI9H7LBbhF9LCKqoBaMao8LGbIL9nov0I0b8zLM6IxTMkVgsIskXMXYFLzMPMk+K2sQoux/18C8EG0E91XnBq6wKDy8/Buy/D54Aj3oqoS1x7tqQu/jTd9C5XbySMIsYQp7WhjhtQq7T87w== 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)(376002)(346002)(136003)(39860400002)(396003)(451199015)(46966006)(40470700004)(36840700001)(40480700001)(82310400005)(36756003)(53546011)(83380400001)(2616005)(336012)(47076005)(36860700001)(426003)(478600001)(86362001)(2906002)(81166007)(54906003)(26005)(44832011)(70586007)(186003)(8676002)(4326008)(70206006)(82740400003)(316002)(6862004)(5660300002)(8936002)(41300700001)(40460700003);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Dec 2022 14:55:15.6725 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cbf627e7-b1d5-4664-8ebb-08dadc50e102 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: DBAEUR03FT013.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU0PR08MB7836 X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Richard Earnshaw writes: > On 22/07/2022 16:09, Andrea Corallo via Gcc-patches wrote: >> Richard Earnshaw writes: >> >>> On 21/07/2022 10:17, Andrea Corallo via Gcc-patches wrote: >>>> Richard Earnshaw writes: >>>> >>>>> On 28/04/2022 10:48, Andrea Corallo via Gcc-patches wrote: >>>>>> This change add bti instructions at the beginning of arm specific >>>>>> libgcc hand written assembly routines. >>>>>> 2022-03-31 Andrea Corallo >>>>>> * libgcc/config/arm/crti.S (FUNC_START): Add bti instruction >>>>>> if >>>>>> necessary. >>>>>> * libgcc/config/arm/lib1funcs.S (THUMB_FUNC_START, FUNC_START): >>>>>> Likewise. >>>>>> >>>>> >>>>> +#if defined(__ARM_FEATURE_BTI) >>>>> >>>>> Wouldn't it be better to use __ARM_FEATURE_BTI_DEFAULT? That way we >>>>> only get BTI instructions in multilib variants that have asked for >>>>> BTI. >>>>> >>>>> R. >>>> Hi Richard, >>>> good point, yes I think so. >>>> Please find attached the updated patch. >>>> BR >>>> Andrea >>>> >>> >>> I've been pondering this patch. The way it is implemented would put a >>> BTI instruction at the start of every assembler routine in libgcc. >>> But the vast majority of functions in libgcc cannot have their address >>> taken, so a BTI isn't needed (BTI is only needed when an indirect jump >>> could be used). So I wonder if we really need to do this so >>> aggressively? >>> >>> Perhaps a better approach would be to define a macro (eg MAYBEBTI) >>> which expands a BTI if the compilation requires it and nothing >>> otherwise), and then manually insert that in any functions that really >>> need this (if any). >> I guess the main downside of this approach would be the maintanace >> burden, we'll have to remember forever that every time an asm function >> is called by function pointer we have to add the bti landing pad >> manually, otherwise this will be broken when pacbti enabled. WDYT? >> If we want to go this way I'll start reworking the patch in this >> direction (tho this might not be trivial). >> > > Yes, it's a trade-off. The lazy way, however, costs all users even if > a function is never addressed (which I think is the case for > practically all functions in libgcc). > > So I think in this case it's worth taking that extra development pain. > > R. As a late follow-up to this. I believe there are no hand written asm functions in libgcc that are addressed, so this patch was dropped from the series in the following iteration. It is true that we could pac instrument them but ATM we don't. Andrea