From patchwork Mon Jun 22 14:01:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39728 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 169B8388B001; Mon, 22 Jun 2020 14:01:29 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-DB8-obe.outbound.protection.outlook.com (mail-db8eur05on2062.outbound.protection.outlook.com [40.107.20.62]) by sourceware.org (Postfix) with ESMTPS id 102B1388A83C for ; Mon, 22 Jun 2020 14:01:25 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 102B1388A83C 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=urKY5fjabJOFfEmegkfuhhmIHt1cAfqj8lRKgixm0JSLNrcgC9BLVFCpzlQLrqYaAuTox6C74araWizX+mi9d4Ncm3gQYWGSltEuyPGbhn3US/aH7ZsGJa2sWzooIQgDzeg5h57SSsDJpoOsvlY7nvr/3XhbkuA/UdiAQOidlEY= Received: from DB6PR1001CA0003.EURPRD10.PROD.OUTLOOK.COM (2603:10a6:4:b7::13) by AM0PR08MB3874.eurprd08.prod.outlook.com (2603:10a6:208:108::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22; Mon, 22 Jun 2020 14:01:23 +0000 Received: from DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com (2603:10a6:4:b7:cafe::ec) by DB6PR1001CA0003.outlook.office365.com (2603:10a6:4:b7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:23 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; sourceware.org; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com; sourceware.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 DB5EUR03FT020.mail.protection.outlook.com (10.152.20.134) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:23 +0000 Received: ("Tessian outbound 2ba684f51d22:v59"); Mon, 22 Jun 2020 14:01:23 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 914e5a0eaffcf64f X-CR-MTA-TID: 64aa7808 Received: from fa0dbc8eb788.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 140397E6-7D28-4850-A398-84047264318E.1; Mon, 22 Jun 2020 14:01:18 +0000 Received: from EUR03-AM5-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fa0dbc8eb788.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:01:18 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jj/WQPClJjSkavbHYXS0hTs5Ib7ZJ91Byq8LdQyqbVNdhagorjIiOAsqEp82NPts7nAtnbIHHTlDCO4V+0rQEHfP+pBc5z4XMmjA/65Faehnin+xRO0a3FZFayGF2i6XZhkExd9PV6eWY0rzFbPgeh/SWFj45fhxow1aEALTK/FnRnf+hjOA+mtiawQAxYnSyoLeXAKgt6wGkdMDjHpUOxqcpChEifnYexpQOVmoHsniWnuLWh26HQo5YVuSLuui8Zksz8z0KpnLob+sxsNq5YslcY3QXEKQPrqTe7gexRh05A5Ws05umbqyntEp/Kn3GUFfrhV+H2O5yRrFzen6qw== 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=S2U8mJVT2gTf/eZw/OXRdOJY4uFSdrwQreXmtovgpZQwbfLs+9r7VAT3FmcYvA65OasDZSaZxBja9/j8IMW3tFew8M5GuVwDWjxUZ+1Yjup80OtlqeyWdypz2eqc+ZAXmQUTm9cQU+aUx7mRpKDdzQjL1/tEjR/s68TCuxjJo4EqyQq+OjlJpbm2hQUVS0f4rUAO72qhxpbZuVAWVpXnP6k72GjEF7scVVFP34mSaj+gpq0yolFRHjeweaScuGUmXr6KGUYgMf6Yf6usJxrx4XWRVlhv0afwiUuwy8sj1zYUs7+z0rAlPYAmrk8RGhelmLhorGnvTLGnejV32Zp2XA== 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=M64pUNzJjcK8D+TvA5MCOPT0fEr/+F/yH2pckFj+PRw=; b=urKY5fjabJOFfEmegkfuhhmIHt1cAfqj8lRKgixm0JSLNrcgC9BLVFCpzlQLrqYaAuTox6C74araWizX+mi9d4Ncm3gQYWGSltEuyPGbhn3US/aH7ZsGJa2sWzooIQgDzeg5h57SSsDJpoOsvlY7nvr/3XhbkuA/UdiAQOidlEY= Authentication-Results-Original: sourceware.org; dkim=none (message not signed) header.d=none;sourceware.org; dmarc=none action=none header.from=arm.com; Received: from AM6PR08MB3047.eurprd08.prod.outlook.com (2603:10a6:209:4c::23) by AM6PR08MB4341.eurprd08.prod.outlook.com (2603:10a6:20b:b9::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.21; Mon, 22 Jun 2020 14:01:17 +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.3109.027; Mon, 22 Jun 2020 14:01:17 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 12/14] aarch64: fix pac-ret support in _mcount Date: Mon, 22 Jun 2020 15:01:10 +0100 Message-Id: <8f62ca73284bb85ad0b7a50dfa5a9ecae27bdc0b.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: LO3P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::14) 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 LO3P265CA0009.GBRP265.PROD.OUTLOOK.COM (2603:10a6:600:bb::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3109.22 via Frontend Transport; Mon, 22 Jun 2020 14:01:16 +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: 403db745-e4c8-4077-e7a2-08d816b4bf88 X-MS-TrafficTypeDiagnostic: AM6PR08MB4341:|AM0PR08MB3874: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 2t3jIFqS1CQ08nd9/ay5l1RncHZ8JJzVao8Hm6dcnhsDWCJ7Oa/lD6S2Ul+iUiJ36p7hPXrg0OvOBf8et+PnRIynV7tjW1b1xroMbhqaeyleVqeHBk9yNZI1Y/WWbdCszTDvEmLz3J/3wH1EPHn4gxl0QLfii2oPlYlLMU9h5DmenHNK3U2ccjCZeTaYSvyYEKUvt4E+uDUOBlVFy3mXAGNGxNZC9vhdG7INpzIoEvGwUrP8NALFfv2IFKLnIjvz/r7SE3jPTEc8TPrkBN13x2RiRZcMFqa5WEu5pTeURmfV1eDD2htim8owrEU8hb8w/1ocZgMDD4B38OfuFNMh2S6Z9pv7+wzv97seHinLBHmNqPdKSUjDZAjbP3gvuqAGN4kCHvdwxp9oyXk/ESl3p2cLl8Ti4Wm3usqzDPpSc/g= 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)(346002)(39860400002)(136003)(376002)(366004)(396003)(16526019)(186003)(66476007)(66556008)(2906002)(36756003)(6486002)(2616005)(44832011)(956004)(6512007)(316002)(66946007)(6666004)(478600001)(6506007)(69590400007)(52116002)(5660300002)(8936002)(8676002)(26005)(83380400001)(86362001)(6916009)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: L+g6ZLE5RgjOEKenluTLLK9Gs0xsL5Slsv+zHKZTte9HQh5qxsv/lMFKgUqAJBt62fXqSmTZWrOpmJ4tNovWYvvEY5dwgA64W7dYNpIjOMj3R4LJ1PRPlguQ1kzdppHNYKCRbIZb15v95OPGJfbu2iwq2l7rTDSSX2Zyp2n65L66zkh3cGFNK1goADusKhEFGkHXwdnxECKWHqZmXtiaeQrjFlUV3htmsCYsjxQI5IK8UwiAda4+2AF5j322qjLHtEstlx5vlXqM3Y/TzLlBvc8eRyaA1gw3RJY6VFaClyKaZIcw30vC+nLfKfOjZMtpYIHIGeg+35RGOBdoFWZfY6s1SkUtKnuBqSI82/1P26RFaFHpDUIkNb2RQWTsFLjC4sWvVFPUbFx2vuwk1GtRNF+WKVGr7SjDVMm/6rDMwbCnf/BiU8QrpDDOR5d9ty1iSCyzrSwPAIWKKamLSzZh1g691z8WCI0LPJ909wPFUqc= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4341 Original-Authentication-Results: sourceware.org; dkim=none (message not signed) header.d=none; sourceware.org; dmarc=none action=none header.from=arm.com; X-EOPAttributedMessage: 0 X-MS-Exchange-Transport-CrossTenantHeadersStripped: DB5EUR03FT020.eop-EUR03.prod.protection.outlook.com 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)(396003)(136003)(39860400002)(376002)(346002)(46966005)(82310400002)(6666004)(86362001)(186003)(8936002)(16526019)(336012)(81166007)(5660300002)(70206006)(478600001)(70586007)(356005)(44832011)(6506007)(83380400001)(82740400003)(26005)(36756003)(6512007)(956004)(2616005)(69590400007)(316002)(6916009)(8676002)(2906002)(47076004)(6486002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 249242bd-0947-4014-647b-08d816b4bb7d X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 71pVfhioCd/x46HzJM+RAsS/w/gAKQNGpr7klsSnCSQUUpuYnNR3Lb8Gi0DrGpPdWB33wT+Pr8SdO7XngBVs0r2gKTRkMprOKed6TKVJEzbLBe0d9IEk8qooeKyZiCaVTpfoR/+6L+4DuzPT6aOg5ZYNMXI1v+wGURj2LYg2Je74pKKvWriMjLF6oygnMI6RcahgL4hotIAMr92o5MND3ANp2+j2bqDU8eqLlrO1GhC8tLA7sKsun7MqcUid4vZE9GUr7k+t20wgJuZc/YOLVi2Tor/Ak2L9yYsqOkNYdyAgR8xXdtPuWeUFGORhiDLhKXgQBF3zf4ylmcLUaNdz5we2iSF9WmH92G3NS276ZIczAprvu4SGUsJPSSgmk7nWYp5/UiUWM1t6XvLvYhbly1IQ+1yJ/qNP7QuGXT5ZH/rINA6hB0toNnTBoxt0MGpZgzWfU1b6TDMtTSNBGDzvJQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:01:23.6200 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 403db745-e4c8-4077-e7a2-08d816b4bf88 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-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR08MB3874 X-Spam-Status: No, score=-16.8 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: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Currently gcc -pg -mbranch-protection=pac-ret passes signed return address to _mcount, so _mcount now has to always strip pac from the frompc since that's from user code that may be built with pac-ret. This is gcc PR target/94791: signed pointers should not escape and get passed across extern call boundaries, since that's an ABI break, but because existing gcc has this issue we work it around in glibc until that is resolved. This is compatible with a fixed gcc and it is a nop on systems without PAuth support. The bug was introduced in gcc-7 with -msign-return-address=non-leaf|all support which in gcc-9 got renamed to -mbranch-protection=pac-ret|pac-ret+leaf|standard. strip_pac uses inline asm instead of __builtin_aarch64_xpaclri since that is not a documented api and not available in all supported gccs. --- sysdeps/aarch64/machine-gmon.h | 3 ++- sysdeps/aarch64/sysdep.h | 11 +++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/machine-gmon.h b/sysdeps/aarch64/machine-gmon.h index 730a23b781..a687298b1c 100644 --- a/sysdeps/aarch64/machine-gmon.h +++ b/sysdeps/aarch64/machine-gmon.h @@ -27,8 +27,9 @@ static void mcount_internal (u_long frompc, u_long selfpc); #define _MCOUNT_DECL(frompc, selfpc) \ static inline void mcount_internal (u_long frompc, u_long selfpc) +/* Note: strip_pac is needed for frompc because of gcc PR target/94791. */ #define MCOUNT \ void __mcount (void *frompc) \ { \ - mcount_internal ((u_long) frompc, (u_long) RETURN_ADDRESS (0)); \ + mcount_internal ((u_long) strip_pac (frompc), (u_long) RETURN_ADDRESS (0)); \ } diff --git a/sysdeps/aarch64/sysdep.h b/sysdeps/aarch64/sysdep.h index 500c272745..2879aeaa5c 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -35,6 +35,17 @@ #define PTR_SIZE (1<