From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR04-HE1-obe.outbound.protection.outlook.com (mail-eopbgr70057.outbound.protection.outlook.com [40.107.7.57]) by sourceware.org (Postfix) with ESMTPS id 95C163858C2D for ; Tue, 16 Aug 2022 16:11:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 95C163858C2D 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=WasIuDZhU+9O3TZuXDGeA8jdB1/rvkiTkwUhRB8YtgKUN9irc02RAAZofn3768QIz7Lgc/rqau5UaKroImR/BNkK2TuZR6PcpbvWQYWrvlLCr9Tczcnj56AJ2CIex23L5kN69wo0STF7AJ7BcQ1K/sVX2RrIbXm/uCGzD8XHsVgrJVlkL7DTYLUKxA6+wjBN/GvUXCWjyVlMa5Q+XWcykJMLpAG4qE7Q0kvz0Kgs0T2soYfijocMq9TFpHyqbm5eaOHC4g2ypJBPY6OuyCEtfgA8SNNrnU+ge4LvR1tTry4B9ksavNLx43V3GAZfPGucBav/GAMxzYyYeiCtW2vrnQ== 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=oHBZRsa3XYTalQHlMV9j3o3wBDpjhwVTGsAJsgF9Bak=; b=CdTLjoRmTgoAe8la9c0Ka1RHediQNHCa26MB2ZlscoULdqovZpTZ3ndFf3EUtKIVg69oufJthDBpTrwtq2AgSiTZDXDGOwcsJdsCHx1GJEe0YajqcqMpHi+ix1QX8Y5vQM6aw9JOo7SuyzQzUpK2vFzXTQFlaA8Jp+8G+AzYq3MiHWYNx3JM+Dkt0wageF/VSf54B2pPFr/6t/ElLB4bHmk/NBDTeJ4OygDcWBwHWpxp5tMWFJRYRSMnWT9TL0U7gyCOFheEBWenrVyG3loI13LJnug7hW/6xOZRKErpNJ9vMFiU+VEk11jxepOz4t79kS3hZHUfaZRzgbrlr2b6kA== ARC-Authentication-Results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 63.35.35.123) smtp.rcpttodomain=sourceware.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]) 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=oHBZRsa3XYTalQHlMV9j3o3wBDpjhwVTGsAJsgF9Bak=; b=Ni3R0A79zGKSe0rRg/kpKK1zS6QFT8Ud8k5FHZFQIeWRJgApWAo2L3X7G5hDt6AKez6ceZcQt7cmjCBAR6rljodpg/5oz+fHwLL0kXREM/dU1gb5ejC4XputJnkoz5KvuGM8XEVFW/gkGzdL1LA6nGX4coiHSZ7eZCKjqvAANBc= Received: from DB6PR1001CA0045.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:55::31) by AS8PR08MB8013.eurprd08.prod.outlook.com (2603:10a6:20b:572::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.27; Tue, 16 Aug 2022 16:11:35 +0000 Received: from DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:55:cafe::8f) by DB6PR1001CA0045.outlook.office365.com (2603:10a6:4:55::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5525.10 via Frontend Transport; Tue, 16 Aug 2022 16:11: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 DBAEUR03FT036.mail.protection.outlook.com (100.127.142.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5546.15 via Frontend Transport; Tue, 16 Aug 2022 16:11:35 +0000 Received: ("Tessian outbound 6a3290ff1310:v123"); Tue, 16 Aug 2022 16:11:35 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: c0a5a02c1d657cf0 X-CR-MTA-TID: 64aa7808 Received: from 03b4a03b759a.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F63FAC1C-902F-4D87-89E8-231F05955347.1; Tue, 16 Aug 2022 16:11:29 +0000 Received: from EUR02-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 03b4a03b759a.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 16 Aug 2022 16:11:29 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OpEPzN+YA2aRKO6ZxPjQHERZyDqjOFrAtIE+FTVVJT8fagaZ6iv4f4sYx0XiST6IxIrD8WIbtipi/LFRrlqRisbreZS+fZJf/UB8cG+ybiUwZDzKQVkgnrSUsGj1sSlTbbpn5vAD0PUkiPoJsOn+2aXQl/3uXY8jX0C5DujQpnD64oR86em1ZLdUO9ztIFutVbdapp1KpC/JrCFErcpg0h+WBIxiaZUC/Ic0YYTW0xl3tK05iDErNH+/F0L4BC7EbtGSzTF+sMkr3MO5dHkzTLTMVyXFa93dshXCr2ftEvJyVNf4zEmt7hNT1UB1SK4TmAW2NfAocAJlDGU8OIltmg== 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=oHBZRsa3XYTalQHlMV9j3o3wBDpjhwVTGsAJsgF9Bak=; b=jGLl1VTWcvoghXD70G23NR6Zuo6V9Y1WfVR2R8XRrUAV9bf+16tgLo63OdF5z1JjUx0Wk/RA6+PAeo3X/VtwdKyc/mFLC9LwLH1rGydgffLhyf6QNIJwM3rWg/OT3ttEufvOlBYPWS5DJMD7wztSFiCXrb0heh37Zq2a0Qe7J13CwwKQwnFv9sxMHNmzSPFqwWzXJ2hsu/zn88pVVfm/aVka9SYQ/57qixxq05OUHXFLvY+/mhSL7TfEuFl/erbIGCD+ZbPDsCHBOFhcX1UeiRJqR8DZYgJzOtfaFw2ldY9FQ5c9Zpv3Hv3vcfgFXHnVzQzdyyaSdlvV3Veht/MV/Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.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=oHBZRsa3XYTalQHlMV9j3o3wBDpjhwVTGsAJsgF9Bak=; b=Ni3R0A79zGKSe0rRg/kpKK1zS6QFT8Ud8k5FHZFQIeWRJgApWAo2L3X7G5hDt6AKez6ceZcQt7cmjCBAR6rljodpg/5oz+fHwLL0kXREM/dU1gb5ejC4XputJnkoz5KvuGM8XEVFW/gkGzdL1LA6nGX4coiHSZ7eZCKjqvAANBc= Received: from AM5PR1001CA0037.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:15::14) by PAXPR08MB6750.eurprd08.prod.outlook.com (2603:10a6:102:13f::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5504.14; Tue, 16 Aug 2022 16:11:27 +0000 Received: from AM7EUR03FT011.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:15:cafe::25) by AM5PR1001CA0037.outlook.office365.com (2603:10a6:206:15::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; Tue, 16 Aug 2022 16:11:27 +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 AM7EUR03FT011.mail.protection.outlook.com (100.127.140.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5546.15 via Frontend Transport; Tue, 16 Aug 2022 16:11:27 +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; Tue, 16 Aug 2022 16:11:26 +0000 Received: from e125768 (10.2.78.50) 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; Tue, 16 Aug 2022 16:11:26 +0000 From: "Victor L. Do Nascimento" To: Richard Earnshaw CC: , Subject: Re: [PATCH v2 1/8] newlib: libc: define M-profile PACBTI-enablement macros In-Reply-To: <72ab6827-13eb-a2ed-668c-d6b53a83e9ca@foss.arm.com> (Richard Earnshaw's message of "Thu, 4 Aug 2022 16:19:21 +0100") References: <20220803153524.20631-1-victor.donascimento@arm.com> <20220803153524.20631-2-victor.donascimento@arm.com> <72ab6827-13eb-a2ed-668c-d6b53a83e9ca@foss.arm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.1 (gnu/linux) Date: Tue, 16 Aug 2022 17:11:12 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-Office365-Filtering-Correlation-Id: f1ef4c69-6458-439b-7a6e-08da7fa1fdfb X-MS-TrafficTypeDiagnostic: PAXPR08MB6750:EE_|DBAEUR03FT036:EE_|AS8PR08MB8013: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: BuB1EFweYjSEwIOw2FArYYwlKBnt851yQgkyhxUoPoXKARQ6StapBYSjUfp4HZEkRZWvHp9Ewww4/wGMTxy81nOkXsiLnLEtf6SOzJa7S3gNWUGMQMFt94QDhM8i/V2D0YMsXNAktVSBmvzF5MGldGV3/Pu3MVXWUwxyHLFfSf7JtE6kqzy4hrTikAfvou/0RmULKc1mvVsi8B+PSrFjt+1y3b9L8raEatSjxRPxjRvnkIq8WJ2gRfYF/4ywAZUF+PcoBQw+WXcA65LB6omoUZFekLmxTlTCPFLi0ylNVtm+Y8LgTCVBin4sepPDtjytZpjsWlvJ4OdEv0tbWCudHDRmLwaf5Exw6c6ZpQriR7ElCZdTQQIvPb6sdqslTRlOmxTd/TxlJ83z0Oq0IJ7t720QyWjDigBwkSS5bOfrzS3BK/udldjOdClIAUuEL7G4puSUmZw3LvvvU4W/XBKOth/VlbwNzKrSkzTGqf9f1NRS7XanNd9/Fau6aXh43Qvx4w4n+FK3d4Sp5nLa+3KqqGi5zp/b/KM1v5yChoeJEsJHIzCUp0uxrbQ9cOTkacvLodT2aXGENHKsi/ZkWuMVdM1GtUt3cUCyQmRBluglAHSnc4j0Ht+s1cdVoq2n9NUTeizdaZW/cqYCIRRRpZFAwEfaLrRlPKopwFkQIRgNcp7P5VVtgK3YkiON+hz+MLT8XUTHqZCurEzRkod/IlPOaY3rhnxrJKflllrkNI3ubb+fbRAzvUbZxRDhEQMZGxgjwXlA63ZANeRMgjjIBRSGReJoyAauwE/aXAH7w6nTjwh/QRBU3EGPyq1P/pIcDIsu4h3r7w+eMq84skmdL7jEqw== 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)(346002)(376002)(136003)(396003)(39860400002)(36840700001)(46966006)(40470700004)(336012)(426003)(70586007)(186003)(70206006)(40480700001)(478600001)(40460700003)(4326008)(5660300002)(81166007)(53546011)(6666004)(6862004)(47076005)(8936002)(8676002)(82310400005)(26005)(36756003)(2906002)(82740400003)(316002)(2616005)(83380400001)(41300700001)(54906003)(356005)(36860700001)(86362001)(36900700001); DIR:OUT; SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: PAXPR08MB6750 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: 35a6245b-4264-489f-f475-08da7fa1f938 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QKNDqcIvGgvag/F4Bh5dl/MT1489BtfjsQJBhG/oYGrHDY18VR1Rzg1CagsECqW9SNSOjb2BqNkN3YiTIsLcwDLXqgrVByuivC+R/tdUKvpnJFQ97oNxYzwiWdZDTn1SN8djhNyH8V9Ol1WJiMTrHLNDYGH7sf8qSfxAjq33M4eq3VEqDGZ3otqAjre4bLXjBfepHnKI3zFVFPaDugPeJTTZYsuVx5v1AoLBoF4ZuFiiJrdhXArrpeOxFsWEk+f5JBOJhLchL7ek9GhI1QxC44Pt9vFicm2NL1cfOukoamvjbCyKfVfblYXZRCNdcXMCzE+fZlWGTKifaS2cjlTq+UpdzNAQL+SpUysyHRTdFIvkYpmpP/NCUxu/IzXDBsJ+n9f2i24yi+xOX7Tn6+cg8YfnJ7XE2MQre8I8zEo6ABaMrV/cvNfIstjt/i7XOvRajtxgyF5fzskOBlGUKS3dutRXS87sojgVMypyoMPwsLLruYo9VFzvgnOiSdmjCLm9VYfIKEiVwK/o0Db4QFFspabL/bFgp9pOiWldFAZGkFaCufsJiEG0RT7hTVMYZxVZutvJbom5BeNW4QfdndtTqg6TCliu+h6hnMRO3Ox+6lCFGqF0zZ35SMINEmzShgG/mxyJKVIP+1ceGQpwSaISJSwy+vERF2cf+EDaH/1z+m1dFua7ZabBDBQT9rxqSTzx6efI5WQmPXfB2NyUAsiXDI2S7e4DzwaEtqYz8rODLQBW1v3xw8++CCe7CPhwQHG4pC/TUecdOFVheCAK/5muHVnN/LCwBpfNafxbxDrzyqwG8j8W8OF777PJtJcpTQfg 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)(39860400002)(396003)(346002)(40470700004)(36840700001)(46966006)(4326008)(70206006)(5660300002)(6862004)(36756003)(8936002)(8676002)(70586007)(40480700001)(54906003)(316002)(2906002)(82310400005)(41300700001)(186003)(26005)(40460700003)(336012)(2616005)(82740400003)(36860700001)(478600001)(53546011)(426003)(6666004)(83380400001)(86362001)(47076005)(81166007); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 16 Aug 2022 16:11:35.3925 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f1ef4c69-6458-439b-7a6e-08da7fa1fdfb 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: DBAEUR03FT036.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB8013 X-Spam-Status: No, score=-13.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: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 16 Aug 2022 16:11:41 -0000 Richard Earnshaw writes: > On 03/08/2022 16:35, Victor Do Nascimento wrote: >> Create an assembly header file that conditionally defines fuction >> prologues/epilogues depending on the compile-time mbranch-protection >> argument values. >> * newlib/libc/machine/arm/pacbti.h: New. >> --- >> newlib/libc/machine/arm/pacbti.h | 64 ++++++++++++++++++++++++++++++++ >> 1 file changed, 64 insertions(+) >> create mode 100644 newlib/libc/machine/arm/pacbti.h >> diff --git a/newlib/libc/machine/arm/pacbti.h >> b/newlib/libc/machine/arm/pacbti.h >> new file mode 100644 >> index 000000000..4c31d00bc >> --- /dev/null >> +++ b/newlib/libc/machine/arm/pacbti.h >> @@ -0,0 +1,64 @@ >> +/* >> + * Copyright (c) 2022 Arm Ltd >> + * All rights reserved. >> + * >> + * Redistribution and use in source and binary forms, with or without >> + * modification, are permitted provided that the following conditions >> + * are met: >> + * 1. Redistributions of source code must retain the above copyright >> + * notice, this list of conditions and the following disclaimer. >> + * 2. Redistributions in binary form must reproduce the above copyright >> + * notice, this list of conditions and the following disclaimer in the >> + * documentation and/or other materials provided with the distribution. >> + * 3. The name of the company may not be used to endorse or promote >> + * products derived from this software without specific prior written >> + * permission. >> + * >> + * THIS SOFTWARE IS PROVIDED BY ARM LTD ``AS IS'' AND ANY EXPRESS OR IMPLIED >> + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF >> + * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. >> + * IN NO EVENT SHALL ARM LTD BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >> + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED >> + * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR >> + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF >> + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING >> + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS >> + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >> + */ >> + >> +/* Checki whether leaf function PAC signing has been requested >> + in the -mbranch-protect compile-time option. */ >> +#define LEAF_PROTECT_BIT 2 >> +#define __HAVE_PAC_LEAF \ >> + __ARM_FEATURE_PAC_DEFAULT & (1 << LEAF_PROTECT_BIT) > > Either this header needs to avoid polluting the user namespace, or it > doesn't. If it does, then LEAF_PROTECT_BIT fails to do that. If it > doesn't then __HAVE_PAC_LEAF should really be HAVE_PAC_LEAF (to avoid > polluting the reserved namespace. I suspect this header is private to > newlib (won't be exported to users), so should not be prefixing names > with __. > >> + >> +/* Macro to handle function entry depending on branch-protection >> + schemes. */ >> + .macro pacbti_prologue >> +#if __HAVE_PAC_LEAF >> +#if __ARM_FEATURE_BTI_DEFAULT >> + pacbti ip, lr, sp >> +#else >> + pac ip, lr, sp >> +#endif /* __ARM_FEATURE_BTI_DEFAULT */ >> + .cfi_register 143, 12 >> + str ip, [sp, #-4]! > > This causes the stack to lose 8-byte alignment. Whilst for leaf > functions that's probably not a problem, the macro should have an > option where the user can ask for alignment to be preserved. But > there should also be an option to not save IP on the stack at all (for > when the user does not modify IP in the function body). Work is ongoing on implementing the macro with all necessary features. A better macro implementation for the prologue is given as follows (but still lacks any alignment preservation logic): /* Emit .cfi_offset directives for a consecutive sequence of registers. PAC_CFI_ADJ will be 4 bytes if IP reg is pushed. */ .macro cfisavelist first, last, index=1 .cfi_offset \last, -4*(\index) - PAC_CFI_ADJ .if \last-\first cfisavelist \first, \last-1, \index+1 .endif .endm /* Create a prologue entry sequence handling PAC/BTI, if required and emitting CFI directives for generated PAC code and any pushed registers. */ #define NREG ((\last-\first)+1) .macro prologue first=-1, last=-1, savepac=PAC_LEAF_PUSH_IP #if HAVE_PAC_LEAF #if __ARM_FEATURE_BTI_DEFAULT pacbti ip, lr, sp #else pac ip, lr, sp #endif /* __ARM_FEATURE_BTI_DEFAULT */ .cfi_register 143, 12 #else #if __ARM_FEATURE_BTI_DEFAULT bti #endif /* __ARM_FEATURE_BTI_DEFAULT */ #endif /* HAVE_PAC_LEAF */ .if \first != -1 .if \last != -1 .if \savepac push {r\first-r\last, ip} .cfi_adjust_cfa_offset NREG*4 + PAC_CFI_ADJ .cfi_offset 143, -PAC_CFI_ADJ cfisavelist \first, \last .else push {r\first-r\last} .cfi_adjust_cfa_offset NREG*4 cfisavelist \first, \last .endif .else .if \savepac push {r\first, ip} .cfi_adjust_cfa_offset 4 + PAC_CFI_ADJ .cfi_offset 143, -PAC_CFI_ADJ cfisavelist \first, \first .else // !\savepac push {r\first} cfisavelist \first, \first .endif .endif .else // \first == -1 .if \savepac push {ip} .cfi_adjust_cfa_offset PAC_CFI_ADJ .cfi_offset 143, -PAC_CFI_ADJ .endif .endif .endm The question remains of how I can ammend the register list in the push directive when we wish to push an extra dummy register to the stack for alignment purposes. A hypothetical solution (albeit a broken one, as we can't redefine macro arguments in the body of the macro) for when pushing an even no. of registers + the pac code is: .if \first != -1 .if \last != -1 .if \savepac + .if \align_requested && ( ( (NREG+1) % 2 ) != 0 && (\first != 0) ) + \first = \first - 1 + .endif push {r\first-r\last, ip} .cfi_adjust_cfa_offset NREG*4 + PAC_CFI_ADJ + .if \align_requested && ( ((NREG+1) % 2 ) != 0 && (\first != 0) ) + /* Having pushed the dummy, restore original register range. */ + \first = \first + 1 + .endif .cfi_offset 143, -PAC_CFI_ADJ cfisavelist \first, \last .else ... The logic above seems correct to me, but I need to figure out a way of adjusting the value of \first in the least invasive way. If we emit the push instruction via a separate macro, we could then pass the \first argument as \first-1 (e.g. pushmacro \first=\first-1, last=last, savepac=1). Even so, creating a macro just to emit the push instruction seems overkill. We may end up having way too many macros. Do you have any insights on how I may be able to fix the above code to allow for alignment preservation elegantly within the limitations of what assembler macros can do? Cheers, V. >> + .save {ra_auth_code} >> + .cfi_def_cfa_offset 4 >> + .cfi_offset 143, -4 >> +#elif __ARM_FEATURE_BTI_DEFAULT >> + bti >> +#endif /* __HAVE_PAC_LEAF */ >> + .endm >> + >> +/* Macro to handle different branch exchange cases depending on >> + branch-protection schemes. */ >> + .macro pacbti_epilogue >> +#if __HAVE_PAC_LEAF >> + ldr ip, [sp], #4 >> + .cfi_restore 143 >> + .cfi_def_cfa_offset 0 >> + aut ip, lr, sp >> +#endif /* __HAVE_PAC_LEAF */ >> + bx lr >> + .endm > > I think these macros are really misnamed, firstly, they're only for > leaf functions and secondly, they (particularly the epilogue) does > something even if PAC is not needed. So I think they should be > renamed as 'leaf_prologue' and 'leaf_epilogue' respectively. > > In consequence, I think this file should really be merged into the > existing arm_asm.h, then we don't need yet another header file. > > Finally, the header needs to define a (C) macro that defines how much > to adjust the CFI offset by for various scenarios: > - When PAC is not used > - When PAC is used with no alignment > - When PAC is used and asked for 8-byte alignment to be preserved. > > R.