From patchwork Thu Jul 23 16:23:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1334971 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=nPbHdqL5; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=nPbHdqL5; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCHhh669Bz9sRK for ; Fri, 24 Jul 2020 02:24:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 0A64B388A80D; Thu, 23 Jul 2020 16:23:59 +0000 (GMT) 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-am6eur05on2072.outbound.protection.outlook.com [40.107.22.72]) by sourceware.org (Postfix) with ESMTPS id 374103857002 for ; Thu, 23 Jul 2020 16:23:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 374103857002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@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=vfwCehBJhTUg9lZ63C1Peln37s0lOeA8RzHMegI+6hc=; b=nPbHdqL5nsszP1CJXtoH873yqCuSPLv98aUOxv7jsm2xwMnnKNes41ZMF6v2GZ2et9RwE/R5+y2u2XxCEAHb7MqnHBOVPNfXUuBu9MO0l1URzdk04N+sbOt7093YmSOgu5lH7NdlBO2bpbHz3Y9S6Fh8tqSMjzvz6QUJNVBjK4A= Received: from AM5PR1001CA0026.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:206:2::39) by AM5PR0801MB1633.eurprd08.prod.outlook.com (2603:10a6:203:3c::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22; Thu, 23 Jul 2020 16:23:54 +0000 Received: from AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:2:cafe::54) by AM5PR1001CA0026.outlook.office365.com (2603:10a6:206:2::39) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22 via Frontend Transport; Thu, 23 Jul 2020 16:23:54 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM5EUR03FT015.mail.protection.outlook.com (10.152.16.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Thu, 23 Jul 2020 16:23:54 +0000 Received: ("Tessian outbound 7de93d801f24:v62"); Thu, 23 Jul 2020 16:23:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: fd735194a38bcf64 X-CR-MTA-TID: 64aa7808 Received: from 65c907b3a7c6.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 5352D66D-C405-484A-8B14-3BFDDAAB9A0F.1; Thu, 23 Jul 2020 16:23:45 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 65c907b3a7c6.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 23 Jul 2020 16:23:45 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=P6qdZjhYam+lWsbxCTEs6rJWpNSuWzziKcDdl8kzJbPnmHgtgD/S57aJIL0vR4u7IfpKCge7vLp7rBsVBZJhteom/B1Gol5EEhniCWS3RWDuxucH7JTOwF+wb0dYyMTMjb71W28qFECmSd40Bh7yJAwIuW42Dh/IwTXzZc5c7p8iLHw9Rsiil4InVK5XY46nbfJM0ZT8jp+TfvrutfLn8exA0oR4FSE7hMvcbQTvcMfNNofuVHGEu6N2UIaSAtePYKns24tkaBV/5ctLLHlPxVExByanf5XGNCkM+i5LoQToGJrg3d9ngHo5LE7eqmh4w34Ye6QLvE9E/KRNnUeJKw== 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-SenderADCheck; bh=vfwCehBJhTUg9lZ63C1Peln37s0lOeA8RzHMegI+6hc=; b=Moa3xOQ2j6f5hkCK7Yg0fA+PXvP2Eum2fQQC/lJqgiYmqQgJ5OmRp/pv+oOSCigfwnyYIKWWXMb2XtuokNO1SZUzUIp8CWonIVvYVwpXpYU6yLj0cV2H9JLiXMDyoqZgdM+wY7Yo3396l6zZrj9rZh+h4TYnVv6HNWp12N3hrYW2Qh6kG4Uj/WKDtI1tPUsCyAkb1vfcih854ivJVhy7RAvX1kqQRiEm5+3asumf0+RhT1Wo298Dqm2H64hKUQ960zx5bu552gQiTQRnmMuo/3wAn7AmGTUu+TOnJ4Z1qAiZ3qzegEv5RtrHsPgFGeIiXu5DMpUFa54hTKtF9I1EDw== 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=vfwCehBJhTUg9lZ63C1Peln37s0lOeA8RzHMegI+6hc=; b=nPbHdqL5nsszP1CJXtoH873yqCuSPLv98aUOxv7jsm2xwMnnKNes41ZMF6v2GZ2et9RwE/R5+y2u2XxCEAHb7MqnHBOVPNfXUuBu9MO0l1URzdk04N+sbOt7093YmSOgu5lH7NdlBO2bpbHz3Y9S6Fh8tqSMjzvz6QUJNVBjK4A= Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4867.eurprd08.prod.outlook.com (2603:10a6:20b:cd::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23; Thu, 23 Jul 2020 16:23:43 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3216.022; Thu, 23 Jul 2020 16:23:43 +0000 From: Szabolcs Nagy To: gcc-patches@gcc.gnu.org Subject: [PATCH 1/2] aarch64: add PAC GNU property note to libgcc lse.S Date: Thu, 23 Jul 2020 17:23:37 +0100 Message-Id: <20200723162337.10248-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: LO2P123CA0068.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::32) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by LO2P123CA0068.GBRP123.PROD.OUTLOOK.COM (2603:10a6:600:1::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.22 via Frontend Transport; Thu, 23 Jul 2020 16:23:43 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f81d07d7-baef-40c1-a5c5-08d82f24cb03 X-MS-TrafficTypeDiagnostic: AM6PR08MB4867:|AM5PR0801MB1633: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:8882;OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: U/tO+eYLOzNbQ6EKcC1E+2sIHR3kfak+Dr+y2xDN/twjK5iVkZ+5BCfLPyWTSLPnpKX8fgdazypt4SAE82j2ZEGUXlbyY/YOFKhqk5nNr1GEmi7BWGbt8QybtwROLt9onoOLZ/G5itynA6DCgHSEAgceY8gWVRu1XvMF6AgOgtdqsQTHjKZlBSJ/TwDhWgOfmQLaRD8hAWopWgbcfhzkA4c0J6BsVpJrCA7MK9R1lwhfbSelP9v7hmrQjg1gF1dbMndUECFfFNSGvaDPIepl4YD/MCIdYxJyf5Noo7BEESi4Z16fRJjr3nYI4TL5vhnq6JhZwNCT2MoTT+w+x0UZE2Xs8dbeVSWXJEQDEfE2ZM3fr/oWAszR+fshJed0qDi7 X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(366004)(396003)(346002)(376002)(39860400002)(956004)(44832011)(6666004)(69590400007)(2616005)(5660300002)(2906002)(478600001)(66476007)(66556008)(316002)(16526019)(83380400001)(26005)(36756003)(186003)(86362001)(6916009)(6506007)(6512007)(1076003)(52116002)(6486002)(8676002)(4326008)(66946007)(8936002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: lih6T6EOSDFGz957WZ35IFzd3BUcKaVYif1FD8gouChUJyJOMNUQ0Wk5ex35QAF5KxM8oeVeVndmomnuB0YP4fmXLS6qztcno7wdkIGHQZtwfusvJW+T6I/cN0EqbX+lr4z8Z8FeDvnYKjzwCZFB3SY6MCxBn2OVNRFOJaq/RlQWcILFEb54IrtehfSjtGb2i0Ygv44cospeT7Q0yzfHQWoPf3d4gS0oEpp/V1/KQdfVQ0FhMdzmpjN2cfTYuXczto9T8N7FuMeCjpgrS/m+Aj2zt9U7WyWlbFlc4zI3FC9vQNES9pO9i0ycsgLU3/tT2SafkDwydGKKh/ra9brU4Pub981hrSegoqvEFsuxqPFW4XF/QeLYGmhyKKrEfFBaWr4/CYYaG9/pSruezgdWEnwOUNmVb7tyver84lfwcRkOgtDVBK9Zcf3gn3mUbNMgt83gFIkjc97DYFUjn6Mya04cW4xZYwjlMhQRt2HsTtU= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4867 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: 9bbda43d-81c4-486c-3704-08d82f24c47d X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NM8n6LP2bEEji9BOf8gyrMRIpzh1g5nTKhAGF7KoiqpDnCHDBDuJtZeb+mYhPFKxaVSdrZUG3Dyp2OZ4Tzp8enZ3aPf4wm81RxvdjyX9qLzNOz1CrgvUiNOuxy4Kqzh5C4G4i6UHGfe6iQOBQyk5oGEuNQx45/NxCpsFYPdGIF8ATVIYFIupCioDzBgaq5t/WLQkmkv3o4o4q+H6DLVwQODmWL03XY85H8S+q4Tsj+MgmmLqCWKZilS3+4O4JxLgQrW/MAzFbqvANjNkGMbZhrbBbNb7pjCE0PmAE7+F5DBY4bmIezpg816zdnlCDio2avOeOVZw2JXNeu6fiIc06dj97FxOuB4Sf3AsdvILnnkLz9juM3svcCGJDilA64aKUcvKc3YT3+ykIViySoh8T4/OSgJDJTnc9UKxHp+Iy8ktDcltxSAepnWvbyx2lKLr 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; SFTY:; SFS:(4636009)(136003)(376002)(346002)(396003)(39860400002)(46966005)(81166007)(336012)(956004)(2616005)(82740400003)(47076004)(69590400007)(70206006)(6512007)(70586007)(186003)(44832011)(16526019)(26005)(1076003)(6486002)(5660300002)(86362001)(6666004)(36906005)(2906002)(356005)(478600001)(8676002)(83380400001)(8936002)(6916009)(82310400002)(36756003)(4326008)(6506007)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2020 16:23:54.3647 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f81d07d7-baef-40c1-a5c5-08d82f24cb03 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: AM5EUR03FT015.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM5PR0801MB1633 X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" This note is not used anywhere currently but it is supposed to mark objects if the return address is protected with PAC on the stack. Since lse.S only has leaf functions the return address is never saved on the stack so we can add the note. The note is only added if pac-ret is enabled because it can cause problems with old linkers and we don't have checks for that. This can be changed later to be unconditional, for now it is consistent with how gcc generates the notes. libgcc/ChangeLog: * config/aarch64/lse.S: Add PAC property note. --- libgcc/config/aarch64/lse.S | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/libgcc/config/aarch64/lse.S b/libgcc/config/aarch64/lse.S index 64691c601c1..aa3e3dc4f2d 100644 --- a/libgcc/config/aarch64/lse.S +++ b/libgcc/config/aarch64/lse.S @@ -283,6 +283,19 @@ ENDFN NAME(LDNM) #define FEATURE_1_BTI 1 #define FEATURE_1_PAC 2 +/* Supported features based on the code generation options. */ +#if defined(__ARM_FEATURE_BTI_DEFAULT) +# define BTI_FLAG FEATURE_1_BTI +#else +# define BTI_FLAG 0 +#endif + +#if __ARM_FEATURE_PAC_DEFAULT & 3 +# define PAC_FLAG FEATURE_1_PAC +#else +# define PAC_FLAG 0 +#endif + /* Add a NT_GNU_PROPERTY_TYPE_0 note. */ #define GNU_PROPERTY(type, value) \ .section .note.gnu.property, "a"; \ @@ -300,7 +313,7 @@ ENDFN NAME(LDNM) .section .note.GNU-stack, "", %progbits /* Add GNU property note if built with branch protection. */ -# ifdef __ARM_FEATURE_BTI_DEFAULT -GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI) +# if (BTI_FLAG|PAC_FLAG) != 0 +GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG) # endif #endif From patchwork Thu Jul 23 16:23:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 1334972 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=RJq0JSm7; dkim=pass (1024-bit key) header.d=armh.onmicrosoft.com header.i=@armh.onmicrosoft.com header.a=rsa-sha256 header.s=selector2-armh-onmicrosoft-com header.b=RJq0JSm7; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4BCHhz1Ddpz9sRK for ; Fri, 24 Jul 2020 02:24:19 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ED5C1388C002; Thu, 23 Jul 2020 16:24:16 +0000 (GMT) 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 6A3613857002 for ; Thu, 23 Jul 2020 16:24:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 6A3613857002 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Szabolcs.Nagy@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=qW8pTGX3TEB9/41d6CYISaOME51nmTs6TqvdjE5WCp8=; b=RJq0JSm74DeTSGZuX46IbJBKlEgh758q6n0WrEnCnPmhwYZL5ib6SrB2doEt5RPy2rDMzX99MtasJ0VuyXSvd2L+UujG+xz5nXgpRomCVMksepwducmdsbV+91w0YMjDpHXxiPZ6Vgp5BJobwSh3SOMA4jfb6uS52h1C4BJq+yg= Received: from DB6PR0301CA0057.eurprd03.prod.outlook.com (2603:10a6:4:54::25) by HE1PR0802MB2332.eurprd08.prod.outlook.com (2603:10a6:3:c6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3195.24; Thu, 23 Jul 2020 16:24:12 +0000 Received: from DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:54:cafe::84) by DB6PR0301CA0057.outlook.office365.com (2603:10a6:4:54::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.21 via Frontend Transport; Thu, 23 Jul 2020 16:24:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; gcc.gnu.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;gcc.gnu.org; dmarc=bestguesspass 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; Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by DB5EUR03FT041.mail.protection.outlook.com (10.152.21.4) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.10 via Frontend Transport; Thu, 23 Jul 2020 16:24:12 +0000 Received: ("Tessian outbound 73b502bf693a:v62"); Thu, 23 Jul 2020 16:24:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 4499995bc548e59f X-CR-MTA-TID: 64aa7808 Received: from 04df23c35cbc.2 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A598664B-6035-4FFC-8C9D-CC6D6436D0E7.1; Thu, 23 Jul 2020 16:24:07 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 04df23c35cbc.2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Thu, 23 Jul 2020 16:24:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aSR90UGUHlHaE9iI0ooSK9G3m7/Z10YqrbyVsLuBh6aj6GCfvndlNitUrwejcMJ43/Alw97qj/LGrr2zD1MoEb06KdthlsPh7MqKXXC62GYsQMXrHL1QMRmp0oLS3IV1Vk0dNlLMyLqLXcUIRHg7iMH5/1PHUnoFTu5bhIRy4anyjOc0kURC5CE6b/cSHu2NBm+asYKLknIGry9Ru/3KlOLN56jUOeJmjWBuLBsxz28s74eT+jxoyFtLNRE9O7pk3RbiXXgiODBFlCmayo9EjQ1NjdDda6fQigZXAH7ykUUPaB4vxK1NyaAfRbjLX4hF49CBwLiMFjhy3LL/brT0Yw== 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-SenderADCheck; bh=qW8pTGX3TEB9/41d6CYISaOME51nmTs6TqvdjE5WCp8=; b=l88NYU7SaelLVj6NZ+OooYozN3n08moMMy/8m8g9jFoijAkLqnarS6wlgTiGs0GY4QZckzFR8zBEijwmKzDK5u1zmCWUiEsOp0MJm9bu+ilDNt2ga8/Hpmmnmxf0RI+GtFA1qDF2sskDUepfRqVO9FvyVcBHZAR8PUZ9rMJ8c0cmnzG9PmUe1qWeRdcXqiKrrpXM2wGoogoJKL80nGKrtl9H6iEIh56kifEI4hAO0qhHyhW3lc86vKDhble/hDV/NYHhhSczUeCCmZjB+qHPfHpsKmfvegMd5CJnUFB5i6dDVGkQdvWfmmT91Oqgztg7z0EDz4/kgrv3O7J21ambPQ== 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=qW8pTGX3TEB9/41d6CYISaOME51nmTs6TqvdjE5WCp8=; b=RJq0JSm74DeTSGZuX46IbJBKlEgh758q6n0WrEnCnPmhwYZL5ib6SrB2doEt5RPy2rDMzX99MtasJ0VuyXSvd2L+UujG+xz5nXgpRomCVMksepwducmdsbV+91w0YMjDpHXxiPZ6Vgp5BJobwSh3SOMA4jfb6uS52h1C4BJq+yg= Authentication-Results-Original: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB3301.eurprd08.prod.outlook.com (2603:10a6:209:47::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.24; Thu, 23 Jul 2020 16:24:05 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::2404:de9f:78c0:313c%6]) with mapi id 15.20.3216.022; Thu, 23 Jul 2020 16:24:05 +0000 From: Szabolcs Nagy To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] aarch64: add PAC-RET protection to libitm sjlj.S Date: Thu, 23 Jul 2020 17:23:54 +0100 Message-Id: <20200723162354.10301-1-szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 X-ClientProxiedBy: DM6PR17CA0016.namprd17.prod.outlook.com (2603:10b6:5:1b3::29) To AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (217.140.106.53) by DM6PR17CA0016.namprd17.prod.outlook.com (2603:10b6:5:1b3::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3216.23 via Frontend Transport; Thu, 23 Jul 2020 16:24:04 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.53] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f2f750b0-cdbd-451a-9dd8-08d82f24d5c9 X-MS-TrafficTypeDiagnostic: AM6PR08MB3301:|HE1PR0802MB2332: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:10000;OLM:10000; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: IgB1ogzIp18ehZQ7gHKsXDpFhz9fKhyIFUssjNeWnGmfEj2QUs7CHcK7bpDXNvxtsSiYQ2O19Dyl8FkRooszYlIzKytHAj4jPaGBPSvhyIBHZV4NjNXf407BjVnFm8yvrCGVLl4biYdjW2n13MpG5K1hkAan3/KIkowsbyt+BvkHlpyHT6jMqui27XNWk3rQi36t0cpv0FAJbGhSgVbCd8eeDQCykuNQVODNK+Kf5dlPZ+6vNYb0hOddLTd15KoXxTuPB14pLGu537jCBUw8inwicYJoSjER7sGQQVnNfg3uFJ3XL40QCwxiMlkpQ1aLYeDM8SvNPb8fgjMjnYqs3olCjqV7m/i0anl5+y1YGNUEVGkAATmEHIK+ye41NpBr X-Forefront-Antispam-Report-Untrusted: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM6PR08MB3047.eurprd08.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(136003)(346002)(39860400002)(376002)(366004)(396003)(2906002)(5660300002)(52116002)(44832011)(69590400007)(6506007)(86362001)(26005)(36756003)(6666004)(6512007)(6486002)(8676002)(186003)(478600001)(83380400001)(316002)(956004)(8936002)(6916009)(2616005)(66556008)(66476007)(4326008)(1076003)(66946007)(16526019); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: DSLIDSqL1mLG0VtKJ2hPc1GyMrbQzUUtIuVc3YAs+/uwedpQRSlaQHKFnbbUJs0k8n3WrUEuCKOMzVO4gVsD9wA/CmcSocL6oksSBWGkdJeNLjoFrxLq5SP8jtoj5DahaRLLHoXSwZDWEpMwx8NPOgWLuHSVsUp97cEl17w8dr6/ixJGVKR0x6SvP52/bhSmN0cvPpPBgB3/dZEjr1CkN+mRomjSEQk3hVfGBus6CMmRkURYkBaExccs+i55NkvZeuqjX5OGeVzY+3P29gMUZTHXJj9+uerbl8F9YHQsEUDvCT7RG0XNNbyTakywiwa+83gUf3FHJH3n6NCVPiiJFqQ0dbqy7LfJnvXKdVPzWQWY26HYZRD1AvYqMK34GZg1aScTWlXn8qinY0Tuygf37FxMwkf98d+OWQGeJvE9WyuP8V5IBpMNsR1hg5wiW9XDuWlpSTwvzRFIvHuzAQZ2RcTASDVFsLjxjm5hDGwc2D8= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3301 Original-Authentication-Results: gcc.gnu.org; dkim=none (message not signed) header.d=none;gcc.gnu.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Office365-Filtering-Correlation-Id-Prvs: bb514bc1-41ab-4ed9-60a9-08d82f24d157 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CfQW3J2JhR0RqDWDwKpblV6NzxpjmL7sACirQQ/br1+HMeDDPZmbZg/rVEuppEG/EDOUqusD0qy6/bCOXDO9NXajNacbFmDbaqqRcMF6WJ3TX/MelN+kOLdEWgIEfrnaiWI/ipmMk9DIDm+zjOqCNzcWEnAgL4E/Mq60sbuiePzvNDwK5cB9TaObJa7wgaD1dlebiLmqpTkQTlyrU8D7AbMIRh8qSGVaFthWJG5JvJ4yeSLKVjHxmGsBHZWPjZ44hytfh488gxZD4NOl7klfHdidtSdkPmEY+LPZOfvbAVeRnTRY+kf1s6wkq9AsNR4tIl3yzX+GyWQSJDPjckpMmIgHs30cPdfwzwv5mrR/N8QcHaoDrLSqbSgW+YKZnmsOfhstD8Qh2oYGAgQD4/vezOClxPVKT3dtZ7c3hx+kbJwckA316gsc92eWwGoQfQQZ 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; SFTY:; SFS:(4636009)(39860400002)(136003)(396003)(346002)(376002)(46966005)(356005)(26005)(186003)(69590400007)(36756003)(81166007)(316002)(16526019)(47076004)(82740400003)(82310400002)(6512007)(6506007)(6666004)(70206006)(70586007)(4326008)(956004)(2616005)(6486002)(5660300002)(336012)(6916009)(478600001)(1076003)(2906002)(8936002)(8676002)(44832011)(83380400001)(86362001); DIR:OUT; SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 23 Jul 2020 16:24:12.4953 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f2f750b0-cdbd-451a-9dd8-08d82f24d5c9 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: DB5EUR03FT041.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0802MB2332 X-Spam-Status: No, score=-15.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, MSGID_FROM_MTA_HEADER, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: , Errors-To: gcc-patches-bounces@gcc.gnu.org Sender: "Gcc-patches" _ITM_beginTransaction is a 'returns_twice' function that saves x30 on the stack as part of gtm_jmpbuf (that is passed down to GTM_begin_transaction), but the saved x30 is also used for return. The return path should be protected so we don't leave an ldp x29, x30, [sp] ret gadget in the code, so x30 is signed on function entry. This exposes the signed address in the gtm_jmpbuf too. The jmpbuf does not need a signed address since GTM_longjmp uses ldp x29, x30, [x1] br x30 and with BTI there is a BTI j at the _ITM_beginTransaction call site where this jump returns. Using PAC does not hurt: the gtm_jmpbuf is internal to libitm and its layout is only used by sjlj.S so the signed address does not escape. Saving signed x30 into gtm_jmpbuf provides a bit of extra protection, but more importantly it allows adding the PAC-RET support without changing the existing code much. In theory bti and pac-ret protection can be added unconditionally since the instructions are in the nop space, in practice they can cause trouble if some tooling does not understand the gnu property note (e.g. old binutils) or some unwinder or debugger does not understand the new dwarf op code used for pac-ret (e.g old gdb). So the code is written to only support branch-protection according to the code generation options. libitm/ChangeLog: * config/aarch64/sjlj.S: Add conditional pac-ret protection. --- libitm/config/aarch64/sjlj.S | 56 ++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/libitm/config/aarch64/sjlj.S b/libitm/config/aarch64/sjlj.S index e2093ca1a97..c84e98aecad 100644 --- a/libitm/config/aarch64/sjlj.S +++ b/libitm/config/aarch64/sjlj.S @@ -25,6 +25,35 @@ #include "asmcfi.h" #define BTI_C hint 34 +#define PACIASP hint 25 +#define AUTIASP hint 29 +#define PACIBSP hint 27 +#define AUTIBSP hint 31 + +#if defined(HAVE_AS_CFI_PSEUDO_OP) && defined(__GCC_HAVE_DWARF2_CFI_ASM) +# define cfi_window_save .cfi_window_save +# define cfi_b_key_frame .cfi_b_key_frame +#else +# define cfi_window_save +# define cfi_b_key_frame +#endif + +#if __ARM_FEATURE_PAC_DEFAULT & 1 +# define CFI_PAC_TOGGLE cfi_window_save +# define CFI_PAC_KEY +# define PAC_AND_BTI PACIASP +# define AUT AUTIASP +#elif __ARM_FEATURE_PAC_DEFAULT & 2 +# define CFI_PAC_TOGGLE cfi_window_save +# define CFI_PAC_KEY cfi_b_key_frame +# define PAC_AND_BTI PACIBSP +# define AUT AUTIBSP +#else +# define CFI_PAC_TOGGLE +# define CFI_PAC_KEY +# define PAC_AND_BTI BTI_C +# define AUT +#endif .text .align 2 @@ -33,7 +62,9 @@ _ITM_beginTransaction: cfi_startproc - BTI_C + CFI_PAC_KEY + PAC_AND_BTI + CFI_PAC_TOGGLE mov x1, sp stp x29, x30, [sp, -11*16]! cfi_adjust_cfa_offset(11*16) @@ -60,6 +91,8 @@ _ITM_beginTransaction: cfi_adjust_cfa_offset(-11*16) cfi_restore(x29) cfi_restore(x30) + AUT + CFI_PAC_TOGGLE ret cfi_endproc .size _ITM_beginTransaction, . - _ITM_beginTransaction @@ -73,6 +106,7 @@ GTM_longjmp: /* The first parameter becomes the return value (x0). The third parameter is ignored for now. */ cfi_startproc + CFI_PAC_KEY BTI_C ldp x19, x20, [x1, 1*16] ldp x21, x22, [x1, 2*16] @@ -86,7 +120,10 @@ GTM_longjmp: ldr x3, [x1, 10*16] ldp x29, x30, [x1] cfi_def_cfa(x1, 0) + CFI_PAC_TOGGLE mov sp, x3 + AUT + CFI_PAC_TOGGLE br x30 cfi_endproc .size GTM_longjmp, . - GTM_longjmp @@ -96,6 +133,19 @@ GTM_longjmp: #define FEATURE_1_BTI 1 #define FEATURE_1_PAC 2 +/* Supported features based on the code generation options. */ +#if defined(__ARM_FEATURE_BTI_DEFAULT) +# define BTI_FLAG FEATURE_1_BTI +#else +# define BTI_FLAG 0 +#endif + +#if __ARM_FEATURE_PAC_DEFAULT & 3 +# define PAC_FLAG FEATURE_1_PAC +#else +# define PAC_FLAG 0 +#endif + /* Add a NT_GNU_PROPERTY_TYPE_0 note. */ #define GNU_PROPERTY(type, value) \ .section .note.gnu.property, "a"; \ @@ -113,7 +163,7 @@ GTM_longjmp: .section .note.GNU-stack, "", %progbits /* Add GNU property note if built with branch protection. */ -# ifdef __ARM_FEATURE_BTI_DEFAULT -GNU_PROPERTY (FEATURE_1_AND, FEATURE_1_BTI) +# if (BTI_FLAG|PAC_FLAG) != 0 +GNU_PROPERTY (FEATURE_1_AND, BTI_FLAG|PAC_FLAG) # endif #endif