From patchwork Fri Jun 12 13:29:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39581 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 7A993395B0A4; Fri, 12 Jun 2020 13:30:07 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-eopbgr80052.outbound.protection.outlook.com [40.107.8.52]) by sourceware.org (Postfix) with ESMTPS id 67CC4395B033 for ; Fri, 12 Jun 2020 13:30:04 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 67CC4395B033 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=PwLxOsYzXVc4FPRK6sd8AMPsOPLVcsLr3EAuHHz9OCsn4NRD60QdTvfxGevmbScK7RraCydbMTUCW64KGkupBWMruWlIbjlYetnqTU1SYaPXhSvPJJZGTzjdWGjU9QBX3jtlW4KWQJUIjQoPqhL8fMxirL+jUNg1UQulJhHxft0= Received: from AM6PR05CA0023.eurprd05.prod.outlook.com (2603:10a6:20b:2e::36) by DB8PR08MB5004.eurprd08.prod.outlook.com (2603:10a6:10:ef::32) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18; Fri, 12 Jun 2020 13:30:02 +0000 Received: from AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::52) by AM6PR05CA0023.outlook.office365.com (2603:10a6:20b:2e::36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.19 via Frontend Transport; Fri, 12 Jun 2020 13:30:01 +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 AM5EUR03FT050.mail.protection.outlook.com (10.152.17.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.18 via Frontend Transport; Fri, 12 Jun 2020 13:30:01 +0000 Received: ("Tessian outbound 56dbe829191e:v59"); Fri, 12 Jun 2020 13:30:01 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a6e54ee44cec21e2 X-CR-MTA-TID: 64aa7808 Received: from e63d6670032c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 537F9861-D122-472E-9856-8739F4A42548.1; Fri, 12 Jun 2020 13:29:56 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id e63d6670032c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Jun 2020 13:29:56 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=FbkwJjIxNLEjml0Zor93+ABlOfyt4QqguGLIRdc/VHwulifow9daP6lE90UIkP5UmAy+ldJS39zwOng3p2BEi5m3uVOqEGxMoBEl/NBnPkhUGyd4lxZEtkbGaONbxUVh9bF3lw/KnDaEolDsQMzO/KxNJMCd7MfeuxcUbKcWjwzARB1xyn207IfpO8aKGRZttZ70EP8jbfgbgp0fiAE1zPhA0hcAUgXzCbeq793Tg+Vcq+DIlAAgv4THmdT6ho3tKp2lTp9OJw5b0F9GdFDE1HSl04tTG+Agp88oqB05y5oL050YHrVSsogHIhH8U45tZTir25PmhshuFjwRd1ZcBQ== 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=IaGta6+aBt9OajoK+Lv+eFAdUZCIrtpkwGmfXJQzVPrnVN+XUThCUdLEkaZdTBqoxQCVRf1BcwYu349BIjtNzXny6BZyZRHXZK2t4hGNOmTdxVApXCNsZ9D7JnJbgzPm/ern9S30IrDwFwHl2EmzEG7YHhxQ2nEVd4u+A3gb5GRPYA/M8GB+3FwXxG4GrTI4nFVVnrxGDF9Hrz1W/Eqv1wBltpQUcr+DkE/SBIeUhQosaKH4oQi1qk7rPjXPPcDKoES0hSTamdjrXHLY48jU4N5DX0G+sBKOkfN8j0jUA4q919nGpTV/pOKHh7Gx27UuFyTBFbUIL5vEq6UkYCxrSQ== 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=PwLxOsYzXVc4FPRK6sd8AMPsOPLVcsLr3EAuHHz9OCsn4NRD60QdTvfxGevmbScK7RraCydbMTUCW64KGkupBWMruWlIbjlYetnqTU1SYaPXhSvPJJZGTzjdWGjU9QBX3jtlW4KWQJUIjQoPqhL8fMxirL+jUNg1UQulJhHxft0= 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 AM6PR08MB3912.eurprd08.prod.outlook.com (2603:10a6:20b:86::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3088.24; Fri, 12 Jun 2020 13:29:55 +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.3088.022; Fri, 12 Jun 2020 13:29:55 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v4 10/12] aarch64: fix pac-ret support in _mcount Date: Fri, 12 Jun 2020 14:29:28 +0100 Message-Id: <97703fc5fc42e66ef56c3d6d2585253a7a013272.1591899092.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) 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 SA9PR03CA0017.namprd03.prod.outlook.com (2603:10b6:806:20::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.20 via Frontend Transport; Fri, 12 Jun 2020 13:29:54 +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: 87c81799-04c2-45a2-3d38-08d80ed4b5d7 X-MS-TrafficTypeDiagnostic: AM6PR08MB3912:|DB8PR08MB5004: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 0432A04947 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: uyYEK6qzP2000F4K7RTw2jpQoHzix9VmVgib3Bber3lEaXl2bZe1Coe7KGUAHK4GiGdnkWIG0QiiYEVtmmLI2rlcKbCesPNUgYYQcOoJm5lMh+lrhz3+LsavY1iehzlD3FgpRdt39uciyk/bbxX52qqKZP0P5rSnfLiljn/PgBZxW+jxrlcu49FopPgcxKW//S2PnBt8tKQiGgdVTeb0af7vIMZqw6u+hp86PcjW9yEmJvMxzK+Sqm54JfOKAtNeeQaQHY7I3GyZQhWkK62uoq9phnBWSsZ+W19WF8RGNrrTKX6yBzQ3vW+5/B7rA/ZF88x9qBnhB5kNVw+zIsDZhxQtDw5bYWM5J4eF8r7lI++q+dsjjDb7TCe1I3xRMu1AIWUIXcwHHK66TDkki5ky6aMuuXkkZ7+AU1hxzov91LQ= 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)(376002)(346002)(396003)(39860400002)(366004)(956004)(66476007)(66556008)(66946007)(6506007)(26005)(6512007)(5660300002)(6916009)(6666004)(2906002)(8676002)(6486002)(52116002)(8936002)(44832011)(186003)(16526019)(36756003)(2616005)(316002)(86362001)(83380400001)(69590400007)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: /B60HtXrQlfcabZ5eVw7ThAQC1wYayXurVQqN/1lW57oTE5YnKkZaLpTLdWcmiL2lXwaKvXmcGEpOTEyGOSSbXgLjnW7h9I50e5RicQAO/IZ2uv8VfdLJur3tfjjxA/bLwasiI9RCXB172h8L3HeANv4KaXcCDF9svicPyLC00sR7+38yp7p20SzfPk2SwaaT0EMp1XpnQAcreWLyoNE2NT/msW+c0cu6hu9ibmza42+EZ9Y/19Z2+8icOOwCkisY0ZEi3NENMh2Lu1MbnAaMML6khS0F/c0eM/HXWCPsfG4rcmeah/QioZyyFZIa1WG7yJcuDCEtm+bMHpaIZKLQreBPRyf1xEi1i4DO9UeGM8O7wfKRuzIs0yFGepI9iKzEBNbLRTQ+2VHYLeyeFNv6zD9zH/D4orXgV1f2tT58/NMIslbqBpo0A9Anac8ZNfQZaRidxV796lGj+7iS3oj2yGTjSlaj38yNCo2TcS3L+0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3912 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: AM5EUR03FT050.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)(346002)(136003)(39860400002)(376002)(46966005)(44832011)(6666004)(356005)(82310400002)(69590400007)(36906005)(82740400003)(2906002)(36756003)(186003)(316002)(81166007)(16526019)(6486002)(47076004)(8676002)(8936002)(6916009)(86362001)(70586007)(83380400001)(6506007)(5660300002)(26005)(336012)(2616005)(6512007)(956004)(478600001)(70206006)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 8aaff92d-856d-43d4-cba6-08d80ed4b1b3 X-Forefront-PRVS: 0432A04947 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6KLyRHnoyuJcPDcD5KL5vGK9sM8YfInuxQY7EkXGASi+Z900bFDofnVIIspcYbqSUFkCK2OzSzbCKTvD5Q4SgIPK1MIvxJouOHjbCSwUIeNtZOVFq2BqSHwXj4Zvij0wTOK6hy645VoSQwbCYiq9u6oWm3BNP5lPZ3E2gSyywYpF4w1+HB1OIeKjY/EYonJAotVTjwUWcp15zysiL/vdwCVv2ZgZ1BUWJk4EdKTSgsON6Eu5Rx1BChWOqS7P4hx9UAdVR9YDdMXSirKKdMfimVs/t3qtGVO2y3q2YPCOVnd2Yd4jIzeQgTyghjfcrimfEasA/YtEE/MSp/GXLBdd8OJDHNJsHuQBEQkEDUpWN3by4n9LLUVCNaP1yAqpsiuT7ebZGT8i0AsbIPy/73b5Uspk9RI0Nz3c/pEW4GZLQD9fp2b01IAZsdDGBqR07SjI1BwdErQeaAINVDOJOHpaSg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2020 13:30:01.8963 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 87c81799-04c2-45a2-3d38-08d80ed4b5d7 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: DB8PR08MB5004 X-Spam-Status: No, score=-17.4 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<