From patchwork Wed Jul 8 12:13:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39976 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 B2BB838618F6; Wed, 8 Jul 2020 12:14:16 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60085.outbound.protection.outlook.com [40.107.6.85]) by sourceware.org (Postfix) with ESMTPS id 01A803861872 for ; Wed, 8 Jul 2020 12:14:14 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 01A803861872 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=LDzPuE7zf5sIsXXta2NKv45eddNLE0+GaJYKiD4Sfun7YLMg+CBKt7oNdJp2QKw3zwc9bhYaJjadTrdIb8Nsx5kwOxmIZQAiRk3z9rSWDJ+ogzx2ZTnCgwMz/mTlMaXanU+jetEVNjbXn1NuiXZAQWXdilo6AXHI46laeZiPnnk= Received: from AM7PR03CA0027.eurprd03.prod.outlook.com (2603:10a6:20b:130::37) by DB8PR08MB5482.eurprd08.prod.outlook.com (2603:10a6:10:116::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:12 +0000 Received: from VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:130:cafe::55) by AM7PR03CA0027.outlook.office365.com (2603:10a6:20b:130::37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:12 +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 VE1EUR03FT022.mail.protection.outlook.com (10.152.18.64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3174.21 via Frontend Transport; Wed, 8 Jul 2020 12:14:12 +0000 Received: ("Tessian outbound 2dd9eeca983c:v62"); Wed, 08 Jul 2020 12:14:12 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 7b87f53c2a08b72a X-CR-MTA-TID: 64aa7808 Received: from fde60c2b094c.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 71FE3973-0C5D-42C7-8E82-2B438DC4DD03.1; Wed, 08 Jul 2020 12:14:07 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id fde60c2b094c.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Wed, 08 Jul 2020 12:14:07 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oe6S/Pz+DZ25ROR9qiuGvu8Iyx8+8+/mpqDKslAghWcmsxWm1tv/i/Lz6MM2nMBOJMDT1KBr7OD22f+wdC1XfslVKf654bSJp37Hs15SRNTHcO6KDJ32pTzt2ZryQOpkr42egjyrIeJHZZYo+MGjbK3aaUP6uslc5Ow5ML8x4dCdq8wmA6KvmBEdHcS6kQkVOB+FYGwaVx0vre8olWcXFzblTVc1xDl+FWjJHq7l++sPjMZUq3uMXSmyUg8P046eIto+q/YI4VqC2OLsO6AoREurDDUQVKoQ/4gW3Qxu2VyfXQlHsvCTnkvR0MQs405zk/GXC/TzVHVoiiDn1A9wNw== 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=YI7Lee8zNJmbwZeorqcWJ5Nh6cE1ED0uOXMXeggHAWHhRzAJa59VwXNhNItmZKxcbcqKoYKgNC3WFR/MIIaJ8PQL4RHjUEsWDGQ7XEG8dm/BZNx3WFB4Bq9xcaUrxPSRf6MKjWHH+hFEpSBud7UNQk62xEaBuQ53xFmVA5NPJ9XWLOIjYMLMgSxov2VA9QiPEutp8pxbLpqfTE/mmF4w3EheBnqXx7WL/BNQQur6PTlPTJHRbnOUNo4vyZ8fUmIvcNu5Y7DkvA2bAoYdpNxBpB7q0bcpgYg8AwK2HsKfvMfB1PNfjjTbWsZYH9f5Qc+p465bDnGvZFYrTGkfpszKag== 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=S4hGujQ0QLt/MzWi0JeNnCM+WTkka0iZlsCo+d1aEso=; b=LDzPuE7zf5sIsXXta2NKv45eddNLE0+GaJYKiD4Sfun7YLMg+CBKt7oNdJp2QKw3zwc9bhYaJjadTrdIb8Nsx5kwOxmIZQAiRk3z9rSWDJ+ogzx2ZTnCgwMz/mTlMaXanU+jetEVNjbXn1NuiXZAQWXdilo6AXHI46laeZiPnnk= 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 AM7PR08MB5527.eurprd08.prod.outlook.com (2603:10a6:20b:de::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.28; Wed, 8 Jul 2020 12:14:06 +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.3153.031; Wed, 8 Jul 2020 12:14:06 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v7 12/14] aarch64: fix pac-ret support in _mcount Date: Wed, 8 Jul 2020 13:13:55 +0100 Message-Id: X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: DM6PR08CA0049.namprd08.prod.outlook.com (2603:10b6:5:1e0::23) 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 DM6PR08CA0049.namprd08.prod.outlook.com (2603:10b6:5:1e0::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.23 via Frontend Transport; Wed, 8 Jul 2020 12:14:05 +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: 1af72184-eddb-477b-0050-08d823386cdd X-MS-TrafficTypeDiagnostic: AM7PR08MB5527:|DB8PR08MB5482: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:7691;OLM:7691; X-Forefront-PRVS: 04583CED1A X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: AuODUyqVZ/vhQkuZC97ME8XWP0SYW4kmNQGGfV6W0TXNWTrBZFc9Uz9qkxcNkLXnVnh8qG27Ipa16EH1Gjr/6yt8pEFeKmT5OKn+uGKCRUBAB+pJ9ZnF2CywTgzlRFTU5K+NDwg/lVZ/qB43CPR9yW7drWFI33qRoTLBA6dCpo3s0vWw4htwuMrOd4spcPjnjXVSvBwl2fKh07GFbxcnuIY9G5rfw+zwjPGSKgAZFHYv3JEX48HYvqb890T7qjy7vxI3ghHnMi0Q4ABYpfUO2kYkfxpsZ8TKK4oSmFqV9GZrtxl2MSLZMIPAtP1htRBVbr/PbyhY3wklGuLf4Z7BcnIYOM0OHfns2vp6W8VYtDx6AS/nDfKkdXy5Tggwaky44UrF1ya/FsFmfpJzD+nRS7Q49FNQGjofVeQkqrNXJ7c= 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)(39860400002)(396003)(376002)(346002)(366004)(8676002)(478600001)(6506007)(2616005)(956004)(8936002)(44832011)(16526019)(2906002)(186003)(26005)(36756003)(66476007)(66556008)(6916009)(316002)(66946007)(6666004)(5660300002)(83380400001)(86362001)(69590400007)(6512007)(6486002)(52116002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: LHN6Gsu+l6LlJxnxkSf8Tprq+wP3UGvkRfjIxxmcvQ2farZg+Q4A09XJ4Evjf7Rwyg9FX8A5Fc4+D+FD3uiZUgdZ/nTgboZ0B1tbiwYKUa5Xp9kRAtYHLe+UhPUsarYJDMS1GfyBTIoHvCaitg/6Itt8NEbskKdZ28K7V5fn2uERFXix4OMf8zJ2lmB2wZVlgnv6ecUph2+RiJ/ahz3WCfvRfLz86SI1JuGlNRDpLz4Mgf6oCj1qeBoNEm6ogNc0/4tOFgTw06KU70H5aI2YxsGyJT5AlzSc0rbtdnT4+apimhOt0+USL+zd1o0Hf61bn/Z6/VagT7DLiH/O/Gd/WK6UIsAkENDv88FhofROIrA4S3THAFF+iFhnHohihUaDOQHhzEV9bpcDUBEAHCC4sDaCH3AYcgv1MKTQZWr9Jb3m+Cq7s9JEVHzUh5MX30tMHWxZDAyvil89NiqJmIX2cX4i0pI1z5li3N/LQxyVQ94= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM7PR08MB5527 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: VE1EUR03FT022.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)(39860400002)(396003)(136003)(346002)(376002)(46966005)(36906005)(70206006)(6512007)(70586007)(44832011)(5660300002)(186003)(956004)(2616005)(6486002)(36756003)(26005)(8936002)(16526019)(478600001)(69590400007)(6506007)(81166007)(6666004)(6916009)(8676002)(86362001)(47076004)(83380400001)(356005)(82310400002)(336012)(2906002)(82740400003)(316002)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 240966b4-3f2f-4556-c489-08d8233868d9 X-Forefront-PRVS: 04583CED1A X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: G/OFICgCKtIhxCT7VNKLIJchgtUgwn3NUVnVi2eKboNFpXIM4tIizPfze23nHCGaoILhYpIzXdwsDnWc6JiMsuoReKSGdeAI2Sm+q1INY/sYOl+LFmb2FVmC5qOj1hqpcSXmWPb2zil4kSJxA0p8WzWJOVeAWCFHUcf+JaA+mZDn5WDTUMfhzPwuZv0/vFB0tpFq8z/WnLlrpDVPbqDHrXgFTTDiF1Ryiq9R+CdKNhFvFsSndHyBUL7beKHvrk79iPRzjxvmNsktaMRuip4UcIlrVPCltvJxVyn+1lErL2KaduJYl6+meQbcr1At+pE1a0YK44r7f9B9JmQ41ixtEJHeAyYIhEz06f1YYTRfEYiFbYx2H8XM4C1GdNzQIdpGBio/AFi13ZP4+tyEoBO8cYoZE3m66iXYga0MS2WCX+Pd5oiVGkXO4s2u0+hFs0HK8Wv1lSyxnenrlJOELX2aVw== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2020 12:14:12.2999 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1af72184-eddb-477b-0050-08d823386cdd 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: VE1EUR03FT022.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR08MB5482 X-Spam-Status: No, score=-16.0 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 cd88023163..f442506952 100644 --- a/sysdeps/aarch64/sysdep.h +++ b/sysdeps/aarch64/sysdep.h @@ -35,6 +35,17 @@ #define PTR_SIZE (1<