From patchwork Mon Jun 22 14:00:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39722 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 8157D388A81F; Mon, 22 Jun 2020 14:00:30 +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-eopbgr60088.outbound.protection.outlook.com [40.107.6.88]) by sourceware.org (Postfix) with ESMTPS id 17EDB3887002 for ; Mon, 22 Jun 2020 14:00:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 17EDB3887002 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=dYXlLmsaV1K7g41fzyJ8I4kpUurGuGbkHnYTs6x1Uhklu7aF+VvnX1guuRpidtZjXPsKE8NwUqKNpL3sddNZceArG5/uRlBOIGpQwRjoPhC07hol4thaN7S3RQvWsyrDPfHb6Dz8geNOmoz3M/zG0gq1pDQTTw/Te/3P6/L2Jf4= Received: from AM5PR04CA0021.eurprd04.prod.outlook.com (2603:10a6:206:1::34) by VI1PR08MB4480.eurprd08.prod.outlook.com (2603:10a6:803:f6::18) 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:00:24 +0000 Received: from AM5EUR03FT038.eop-EUR03.prod.protection.outlook.com (2603:10a6:206:1:cafe::dc) by AM5PR04CA0021.outlook.office365.com (2603:10a6:206:1::34) 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:00:24 +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 AM5EUR03FT038.mail.protection.outlook.com (10.152.17.118) 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:00:24 +0000 Received: ("Tessian outbound 022d32fb9a40:v59"); Mon, 22 Jun 2020 14:00:24 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: a3f564c2511388ad X-CR-MTA-TID: 64aa7808 Received: from d52b19b3b46f.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id F6C38426-CB7B-48A8-A751-414C44549B21.1; Mon, 22 Jun 2020 14:00:19 +0000 Received: from EUR04-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id d52b19b3b46f.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Mon, 22 Jun 2020 14:00:19 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j/aAnapM2x7l+ODJEYUPKK0oQjAhsUdF+CioRaJ31Pk++wG/2Aje7uvgGtI/R7su6Ron8x4TUfE+0POlFyjSj+bunCDbs13GMvGzYwoMnzwZyWS/yQIzqUCzbgJnwRvE2jRkAUErlgYh6VQ8ZY8AooYjQvLF8sUqND9MAIu9ZsvIQCFokkr/+0bsxjpyt5/yQHIOdA4MKxwD820MJNnxRpr3lZS3nS0xjF/Fv7NMfNT9xoufgdav+CXLwgeGNpcRc/+T8tJyLjTEctob3AyN6zAxRHldp2xuCYEOwz1kfSNB28uNC23tSWjLjcZwHKJQIpwINKhkDLv9pJwGJMHdVw== 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=hkTIr7YLd/uugbDrviiaDc8FQqk5lzGvQphtwfEUSfXc5VIetY0Mf1vOB1RXNRikP+PQhObck0q78ugLhy7gzSoFOudyy2sRhpQRPtsoj4iVeUC2eaUi9zY/l/xsV8oUfMQigBAlgdU+jPkLvOxK7caRCo63x70m8QQ7jXcOZ7TugXIXNsuKW7Cr6G16ft0kAzjsIypAktvKEBiZ6QbSfLMChg0eAGNi6soajQ275Y1XYGdGEwSkq9+Vc2oYmPz2BhtZjAHsflJhULqFOWOxhAIncE/w9sulgz1BgcSTY6qUPe+AIHH6Svtrv2wXUa+uMoqpek3qKUVpHW5QQTmDTg== 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=xO+GjftqZsZae5+TyfKkB+AZBpc/CdAj9KfbqhuP/s8=; b=dYXlLmsaV1K7g41fzyJ8I4kpUurGuGbkHnYTs6x1Uhklu7aF+VvnX1guuRpidtZjXPsKE8NwUqKNpL3sddNZceArG5/uRlBOIGpQwRjoPhC07hol4thaN7S3RQvWsyrDPfHb6Dz8geNOmoz3M/zG0gq1pDQTTw/Te/3P6/L2Jf4= 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 AM6PR08MB4344.eurprd08.prod.outlook.com (2603:10a6:20b:74::11) 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:00: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:00:17 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v5 06/14] aarch64: fix RTLD_START for BTI Date: Mon, 22 Jun 2020 15:00:06 +0100 Message-Id: <479a62fd3c85faba620481f83e7cf7ae017d8d9d.1592834304.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: SN6PR2101CA0020.namprd21.prod.outlook.com (2603:10b6:805:106::30) 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 SN6PR2101CA0020.namprd21.prod.outlook.com (2603:10b6:805:106::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3153.2 via Frontend Transport; Mon, 22 Jun 2020 14:00: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: b4d86505-d293-46e6-ad15-08d816b49c5d X-MS-TrafficTypeDiagnostic: AM6PR08MB4344:|VI1PR08MB4480: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0442E569BC X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: 7az9TD/MH65bN1kAtkQCTjgp0IwI12UcWdAmnFRyzkMdtMqN02NSSwRljxlT5/C4P45JJVh6vfOlVSSZrppx/J8drJj9cAMaCWeW51Ge8el92Zbji1FcBkqIklghfJyS6r8SsXhAs2z8bNf4dhOVcyf078i1ryeH+ovG+YFeOmxgp3HABNgeJHkhLZ40yNATMAtQwos+YZ2Y8nGnTa7TP6OLXs1t/x+vFmaQQUnOqhVZn5L2+QF56aePf7PWZV3TQVl5A+vvR9ZSBVxxxq/pfCnBAuce0MrqyvcJWxnNK45vpfnLaKGjuEAUzb3q6sNIRHsA7QzMKZnbBGgw1LZ5tPEcnV4Zx8G5EORBbzlro1FiSvt/rmM0fKMCNohdNO5mQ6L/kf/0gp51CIs52N06dydBNc17kGGIx+LV93u2OPg= 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)(136003)(396003)(346002)(366004)(376002)(52116002)(2616005)(69590400007)(66946007)(66556008)(26005)(66476007)(6916009)(956004)(6666004)(6506007)(2906002)(186003)(16526019)(86362001)(6486002)(44832011)(478600001)(8936002)(36756003)(316002)(5660300002)(83380400001)(6512007)(8676002)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: MeyvHB+pd5EdsmGb1RBkwfjMqYMXZ7jAUrVJQ2/TY5+WhzEHhHhpfdq6kQkahu6DUnu1yTDLD+wn6TRlI/ZrIOtPSRxhkXVk+HCoEJH6psDdRnNzJ1Us9DEFb9ytiXQsJPqVBHLfBC/Hcs7cHWa3T6E6mrMGMOKXjjSsyFwED0CK8yLUOYEHyEBbq+iG+nG25VwZ1pGAq7Hwdm66Jjh0k7Eea0sTqv0xhuwaqsBi8nEN9tRx6ZrNJteve60LeKK79i7QPySD6aHSRqEfBpgi0EzhopMutIrKIKESVfsCqS4aCaflsvHPkjwYOxeGUbfsuFx/ljxjBTGQCYuQixyOpcjYBRbEt9dS3EpZ8gi8JGkbkgAgUmdr48SmUzxvSenFHXD/yRfpMYN04EIozshikhrPde2mnXWL40gupu6oGKzfXIREu/IJESKCSwM9GyGBCGXSLoBR5cbLevKSIv6xxemCFupZnHM1fSzKtkokUZo+rzn6A6xLjPCbzHcSUPiV X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB4344 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: AM5EUR03FT038.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)(376002)(39860400002)(136003)(46966005)(316002)(44832011)(47076004)(186003)(356005)(82740400003)(6512007)(36756003)(956004)(6916009)(2616005)(8936002)(478600001)(83380400001)(336012)(6506007)(8676002)(36906005)(5660300002)(70206006)(70586007)(26005)(81166007)(16526019)(69590400007)(86362001)(6486002)(2906002)(82310400002)(6666004)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 7606c461-dc0c-4d10-4c8d-08d816b497fa X-Forefront-PRVS: 0442E569BC X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: OIi43H9S+uym256RyAMSSpKiLS5mbLZja0klhBv9dxieQOQznZbpesgIQ8M+d7tcTHZ6dBFynG5LYgw0051oa1g1gCWOUaCOCSkTr1FCMcI0uFJPvqGXQNqYXJsK+f0Di51rISTvYexNQtdJOgLLiBXQWheJeCt0SToOkCMhTCakinFcFcrvz7VYt0MkaADMBnR94TSg0R2vCosrPf8uO/B14TwgT1HKSYbGMrLT1pzWneVLODJmNgDse4po6u3Tb4CT2zn92mDNxvcI9XTPWr3OOvx+WysLYH8yAX+xJYRqKzuMDGTOcRvTefOMVXXtprt/r2O7ODlu68tLy5QhFB6M4rEiaFblq7UubJXEPtD3yP3sPh+RfxGHjyntlMpl2rc/oL9/J+bCRelpzsDsnRhKgJn6VkuqZVd9gJNZh+7GfUmWF3Kdrv1ycbmN606RFYj0GHRuZQ4VNDF0bDaTIg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jun 2020 14:00:24.5614 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b4d86505-d293-46e6-ad15-08d816b49c5d 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: VI1PR08MB4480 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" Tailcalls must use x16 or x17 for the indirect branch instruction to be compatible with code that uses BTI c at function entries. (Other forms of indirect branches can only land on BTI j.) Also added a BTI c at the ELF entry point of rtld, this is not strictly necessary since the kernel does not use indirect branch to get there, but it seems safest once building glibc itself with BTI is supported. Reviewed-by: Adhemerval Zanella --- sysdeps/aarch64/dl-machine.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sysdeps/aarch64/dl-machine.h b/sysdeps/aarch64/dl-machine.h index db3335e5ad..70b9ed3925 100644 --- a/sysdeps/aarch64/dl-machine.h +++ b/sysdeps/aarch64/dl-machine.h @@ -125,6 +125,8 @@ elf_machine_runtime_setup (struct link_map *l, int lazy, int profile) .globl _dl_start_user \n\ .type _dl_start_user, %function \n\ _start: \n\ + // bti c \n\ + hint 34 \n\ mov " PTR "0, " PTR_SP " \n\ bl _dl_start \n\ // returns user entry point in x0 \n\ @@ -178,7 +180,8 @@ _dl_start_user: \n\ adrp x0, _dl_fini \n\ add " PTR "0, " PTR "0, #:lo12:_dl_fini \n\ // jump to the user_s entry point \n\ - br x21 \n\ + mov x16, x21 \n\ + br x16 \n\ "); #define elf_machine_type_class(type) \