From patchwork Wed Jul 1 14:40:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39872 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 3D38238618C0; Wed, 1 Jul 2020 14:40:59 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR05-VI1-obe.outbound.protection.outlook.com (mail-vi1eur05on2055.outbound.protection.outlook.com [40.107.21.55]) by sourceware.org (Postfix) with ESMTPS id 2AD6D38618C0 for ; Wed, 1 Jul 2020 14:40:56 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2AD6D38618C0 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=x1urL5qpkklF7iY1wY4tGvZQ/S2HP0uSO5qmmmYE4WaCQJGtGge0ptx8cngH6Uawj7LjJy/0zybzGlqBxUsN/zuHiiMURYr5f3QaOsnqh+ROvLBKnilpMno1f8zdhThdbF1na38iGMIZ3+VHk1C8tsYi5KoZcA8b6kYr9CgQbTo= Received: from AM6PR01CA0066.eurprd01.prod.exchangelabs.com (2603:10a6:20b:e0::43) by DB8PR08MB4057.eurprd08.prod.outlook.com (2603:10a6:10:a5::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.23; Wed, 1 Jul 2020 14:40:54 +0000 Received: from AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:e0:cafe::25) by AM6PR01CA0066.outlook.office365.com (2603:10a6:20b:e0::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.28 via Frontend Transport; Wed, 1 Jul 2020 14:40:54 +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 AM5EUR03FT029.mail.protection.outlook.com (10.152.16.150) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.20 via Frontend Transport; Wed, 1 Jul 2020 14:40:54 +0000 Received: ("Tessian outbound 8239f48e56bd:v62"); Wed, 01 Jul 2020 14:40:54 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 2a509d73cf907769 X-CR-MTA-TID: 64aa7808 Received: from edff83bcf7fa.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 9A4F4689-3015-46CC-A417-A770FDBF220E.1; Wed, 01 Jul 2020 14:40:48 +0000 Received: from EUR05-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id edff83bcf7fa.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 01 Jul 2020 14:40:48 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ToO9beHa0L2Sc3QHz+qR7d9MBcykjyI3/B/hd3vFWl9quEFJlnEOrfZswXVGpmcIBG0roqP2qEQ8DXJgm8A8zY+J2pRhESMi5dcEp5s+imX7kzh2Z8yHxFS1qWO0Y+2Mu/CgPcn2RfQyPD90tgrGRlBH02OStzgJAJUpUvP4n2v/Ph3GQR6/yII/dTcap8G1Oxdw4vGxhkFCjgP+B/tMaYXxJDMr41FSRfnwjMDCQkEMffgo2D5KJ0hnsFO+TMCeEbR9tb5h/KmvYtWSgsEnzglT8AOB4BfiSvuMvkV4eSavLlO6QCJB7ZPu9pM1g19LBSy/Q3Xmkv6HfjTBsX5OcQ== 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=Af3jhb4euPOMPMUjACIJHdemQKIV2ElOdL+PSduGm95Sj+awFbqrZCQl72jWItSjxAWbjJIYk9Xp+jtSFIAgpDDG2zkKuAT6S8hzW2ufRtGZAW4lmlovdSNFy/Mw/mBBFOw3I8CFoqI2lJbIATnOaVhb2xpv6CMsrIN5BcsVl97fvSgjuRyLxr8mgX7vGnYstNgRgexkUVTt60IYYTnnbNBo5szBhJ0noFPV1j2BtkkJzfU/Y5RR+gW3JbGSH+cjOojDWDX3uBpMvY1CualftgsEIpQ8FVdEKDtZPVQ263O0YYtb5O3ISyeaGCbTULQeFggO7l+xEKWCA3nJMKjk4Q== 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=x1urL5qpkklF7iY1wY4tGvZQ/S2HP0uSO5qmmmYE4WaCQJGtGge0ptx8cngH6Uawj7LjJy/0zybzGlqBxUsN/zuHiiMURYr5f3QaOsnqh+ROvLBKnilpMno1f8zdhThdbF1na38iGMIZ3+VHk1C8tsYi5KoZcA8b6kYr9CgQbTo= 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 AM6PR08MB3879.eurprd08.prod.outlook.com (2603:10a6:20b:8c::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3131.24; Wed, 1 Jul 2020 14:40:47 +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.3131.033; Wed, 1 Jul 2020 14:40:47 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v6 12/14] aarch64: fix pac-ret support in _mcount Date: Wed, 1 Jul 2020 15:40:36 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN4PR0201CA0024.namprd02.prod.outlook.com (2603:10b6:803:2b::34) 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 SN4PR0201CA0024.namprd02.prod.outlook.com (2603:10b6:803:2b::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.22 via Frontend Transport; Wed, 1 Jul 2020 14:40:46 +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: bb02dc24-9737-4274-c55d-08d81dccc232 X-MS-TrafficTypeDiagnostic: AM6PR08MB3879:|DB8PR08MB4057: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 04519BA941 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: kfS/eQXKBh0yIvL0mANIbUPTVPr2gS1oI98BPB5zDUE0kEIPVgN64kdLogpSWFLCPCzl1XcDBMPPs6ZRab86Tvy3c0X/2pq6jmbVLbzxx80w6UI7n9z+eEQr6XRP1xXaaLImlakecZ4GgWq1P+Evy9YsTOcfoOi8RdM2di0B7FAHYbYyqEE1x9HnOTijJ9yEgTIi8qKDygLSEAVkUrRCvA3UpY0hErkvOd+z5DBqTe6eLmN/dBrNh7qMUjvr2Wrf/7n/poOqA5UnHS++xglOWay/FvcSgLJi340jgZNb3PeDQBypN2HtA0IDMYFCfp3N32zny6nuHlDbbKFP/ufEd0jfJFEqm81gQn9FrUmLhvOK44HJkrkvPXyqkolPc0ln7Rm60R4Fwkqa+sUYMgLSNIrjicg0BxVw56Dh/Agc8lE= 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)(39860400002)(366004)(136003)(346002)(376002)(396003)(186003)(2906002)(52116002)(478600001)(36756003)(956004)(2616005)(6916009)(6512007)(66946007)(66476007)(44832011)(6666004)(66556008)(6486002)(69590400007)(83380400001)(5660300002)(26005)(6506007)(16526019)(86362001)(8936002)(316002)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: Yfox/aCliEHxZxmFks1CaLBco0BPm1eUjokMVYFTmeHsZpwBqkoiqHAtE+OaVsQPJB+sv4SE+RHuU9UN7LnVYeGXrQitWBeWwjT4AJ1ICP2pgrhZErOF2C/JAES6Gq4Xk0cuh3mlFWKpkO6RNkVCZmCq6VsifmSfug4c1yBYmOsAowOso+iPjCURG50d36qjAhyOS8mUbUgCF00kracCyaKD/LlWonhGVFSAXRUiPRN2/ENgtQZzV/JT9lvEtixITg0mZBgADgDrnB2hxzewYMebz7c424+5xaSurUza+GfvpGbOnkPrawvqt/Ib1KRvBAM7x3B6VS6Etf/CoQyaqr1LGeo9LIiiSRGVIxskhSIcLM7+yzYnQM0z5WGSXdI3jVdA3hqqB8W3mNNO6Or2pU8n1haDoxfztNJGPsCaYUcZ0W+/OhBQPlMtjuIYnJYXNdNcJUS7jZSXHTttilRMDDqGX/coVyDt3Z4TF8JVYmI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3879 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: AM5EUR03FT029.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)(376002)(396003)(136003)(346002)(39860400002)(46966005)(6506007)(186003)(70206006)(70586007)(36756003)(69590400007)(47076004)(5660300002)(83380400001)(82740400003)(86362001)(81166007)(356005)(316002)(82310400002)(6486002)(6512007)(36906005)(26005)(6666004)(8676002)(44832011)(956004)(2616005)(2906002)(336012)(16526019)(6916009)(8936002)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 59c8c2ad-d698-44e3-9f16-08d81dccbe13 X-Forefront-PRVS: 04519BA941 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: FSReK400jWbyJ+TYnYgcxNlerhLJ39KTXvqkxpyOxguVkkSd6+YL7LnPx2lIW43N/L/G34RXxVyrYNjB/jZAMYO9w+Dw85Is7LMeKfF/2ZQ8m6LMKA3vakOp+iHqwuTRIqrtbhCnfk8hw+a0k3TNkGqqArbRqeyu+Taj8+GV9jkEm1d9tL1dMVffKiHCahmFZa/S/gp97pSLN78OF6gTMCYO0wZUKZ89bmTzVmJrVS26kD6AN2hmTjllChUvJPcSmQgFsj3KRhtyNdyOrfG4BfaUTHH+WuEEKpgEXYSQLJ5N2eq8Z/TFizfXJA89hJZI6v8ST1oiB5CO+mRLQq1c6+GRvZxghxeASICiMdMc6DXjRosx/Eka6YyA9ZhT9cu2HT8UxFeg5mPolgD+96NcmHIVt3+Gtt6DJdUPrETXdOymigSiXiCqLJZXfHA+/DiRHdxszaxgVvMR7UTYgmnJWQ== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jul 2020 14:40:54.0976 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: bb02dc24-9737-4274-c55d-08d81dccc232 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: AM5EUR03FT029.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB4057 X-Spam-Status: No, score=-16.3 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. Reviewed-by: Adhemerval Zanella --- 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<