From patchwork Tue May 12 10:14:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 38960 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 48D6D395441B; Tue, 12 May 2020 10:15:13 +0000 (GMT) X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30082.outbound.protection.outlook.com [40.107.3.82]) by sourceware.org (Postfix) with ESMTPS id E553D3947C3A for ; Tue, 12 May 2020 10:15:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org E553D3947C3A 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=1ujMe9dEIcdAPAIKrZJi16dairW0GaJ5P8q8LiboE+HcQfLLV5VHb+Dj9n1i7AUnLwdc7/14e6lHAiBICqart6sYBvDdlmCfBXvUr+TXPpCkCtmR0PFnuXPLpDSbi/6npubQB4ZQe0t/Uaj793EtJVQOxiRgAl2J35+a/f6QzU0= Received: from AM0PR03CA0030.eurprd03.prod.outlook.com (2603:10a6:208:14::43) by AM4PR0802MB2259.eurprd08.prod.outlook.com (2603:10a6:200:5e::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Tue, 12 May 2020 10:15:07 +0000 Received: from AM5EUR03FT064.eop-EUR03.prod.protection.outlook.com (2603:10a6:208:14:cafe::28) by AM0PR03CA0030.outlook.office365.com (2603:10a6:208:14::43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.28 via Frontend Transport; Tue, 12 May 2020 10:15:07 +0000 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 AM5EUR03FT064.mail.protection.outlook.com (10.152.17.53) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 10:15:06 +0000 Received: ("Tessian outbound e88319d7ccd0:v54"); Tue, 12 May 2020 10:15:06 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 917fd2659f76cd7e X-CR-MTA-TID: 64aa7808 Received: from f87fe47b74a4.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 0B0A43E1-D9D7-44EF-A6F5-45D47C57A755.1; Tue, 12 May 2020 10:15:01 +0000 Received: from EUR04-VI1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id f87fe47b74a4.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 12 May 2020 10:15:01 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HkRYe9yYqU7vbHqQx6wVSGT6g0LQy2Ra8SX9PKaUr1QHdy+j9WOgfckoYKNHx2ufwVWIw3dPRHvu2PZTRZl+n4CSdmkKHKbOzG5Q2fD/fnIC66DwRoVDWVbx+pMXOlg33fhnb7AnOyaE9k3LPLIXtNIa/rTJ9Ggn9YGPiMR6s+0B9rnqYJnnB83ODWQOck8ao+TDxDF8dVy3rMgyXkb1HXV9pF4yvhujxhtmXObCpyJpyH516olCRm176n34Nt7lgZg16HgoN3/BbNJYdNs4DtV1Ess/0Bu4CLteYwgfqytHPWoThEmJYvHEzMiBBe71MIQD6Q7BPXCQTDLsIQj5xA== 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=V1RjozlBMijuZPjLOyDs+/O8Kx4z3HS4FuPbZtOtJkPVbK67lItHdLaegWX6nsLLwZaqQLSyslUdxD2NbX1zbu5Y2F8x4u7wwNbI0XvKMr5IXJzcjjIQJY1Qg0PeH8tkIdRixUXvtVoYqn7DpPR2+yiK9j56R8Y0he740c2/RUpWi+h107dPl7IC/Ql+seBANK5aYjPnufdyH4cesTdiiekQ9xhBozD/wtYB5tDdlAT3A9vdCktIs6zdhyehRG5LJdR8hIcvBeJhfRWE3XDUKS49isEgoc8ZLrGrgL95Lg6rjbqZ4gFs1g0ThvoR8us/zS90VmQnHR7tx/35++xhxA== 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=1ujMe9dEIcdAPAIKrZJi16dairW0GaJ5P8q8LiboE+HcQfLLV5VHb+Dj9n1i7AUnLwdc7/14e6lHAiBICqart6sYBvDdlmCfBXvUr+TXPpCkCtmR0PFnuXPLpDSbi/6npubQB4ZQe0t/Uaj793EtJVQOxiRgAl2J35+a/f6QzU0= 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 AM6PR08MB3703.eurprd08.prod.outlook.com (2603:10a6:20b:83::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.33; Tue, 12 May 2020 10:14:59 +0000 Received: from AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862]) by AM6PR08MB3047.eurprd08.prod.outlook.com ([fe80::49fd:6ded:4da7:8862%7]) with mapi id 15.20.2979.033; Tue, 12 May 2020 10:14:59 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v2 08/13] aarch64: fix RTLD_START for BTI Date: Tue, 12 May 2020 11:14:44 +0100 Message-Id: <3b7c87b1784c8b610686c1dd9bc881a60ffaa788.1589277641.git.szabolcs.nagy@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: References: X-ClientProxiedBy: CWLP123CA0056.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:59::20) 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.55) by CWLP123CA0056.GBRP123.PROD.OUTLOOK.COM (2603:10a6:401:59::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.2979.27 via Frontend Transport; Tue, 12 May 2020 10:14:59 +0000 X-Mailer: git-send-email 2.17.1 X-Originating-IP: [217.140.106.55] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: f9a1ebcc-b5bf-4342-a862-08d7f65d5832 X-MS-TrafficTypeDiagnostic: AM6PR08MB3703:|AM4PR0802MB2259: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0401647B7F X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: sHuZhcCy5QbyU5hu0HImIkhMT/lLqcXd9fq1T9p5KzbJ29VQKNrpU7dZCUNnA7nPFNtxvny0WI1pGfDdOuEusRJc0gDVDcAE3SQ+FaYDXCIrJx8vdc+WNBsGwDPMbRZBw0z6/czyWI8eXPsf/GlwshqquLyP/kE2Rv+raJubhuXHDDwb8afI2Q1VnlzvNpSbl0FIzSVyhRGZPLc5+7zYebKwPyXhy/z/nKS4a/vgo6FjyZSUE2sua/xy4/QuCUkLbq//7rtNasGdpkryNagY0HWJEc0AfuyvkTV9BzIIAmwd01hG4CY33oPporw69HugTKcdXJB7Exe1GjcJ/hyT7B8nT/EEPvQs9/Ed1CPsmid1euySZCuZi7kXcJ03eVK23ka3xFaDhAI+tuhI28M1Ubk9MOcJskIN5ySaB5u40mmWqpyV8JwUKShWYpSoR1MrePFvOTDtPIVS85y2+J0iqyd9MVZ4EzV6+6y0jYWiStCLISrqXdoj8QY3y4dLyPU0tU643ZqeFtJwZkdjq3X+zo888oH4EfPcF5ZA9TqAB2CiSHUsDRvFSNIiqg1y8ddhkqOTKmCfN+Z+u9j7PuOj77ukpcU97mcGIKrBIhmhq/4= 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)(376002)(396003)(346002)(39860400002)(136003)(366004)(33430700001)(33440700001)(8676002)(8936002)(478600001)(6512007)(6486002)(186003)(26005)(36756003)(2906002)(16526019)(69590400007)(52116002)(44832011)(6666004)(2616005)(5660300002)(6506007)(6916009)(316002)(956004)(66476007)(66556008)(66946007)(86362001)(136400200001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: N+3b7wm5cUBz7X9iXvnhjRPljA80Wpuk0CDtt5ozshCixYdPbJnF82JSidFZqIv43uQ/qEU6E0V9Dj3nnGGaAOIVQdQGxonJheiNoJ5l3O9hp4cAqZ4tT0LGWEv1mhFq303dt0SmUPWF6rRRvRBJVeAURO5BcDVZm4r8bjM6PWXZ234YNcBdu9naKqTPsgnswrkO3/jRM6Iy5wnFO1vgKTiDwoe1HcspbvIFvm6lU9jFHwyEjt3+vUNpZX5gw4PUygmHGIJ7kdQLeHF6bGNtci7ST28Dt/cGFCr0M+1j8kOrYXAtswljRkQb/iZ9P+Q3AMieeSJVHVdVfsrHmhwP7mw+zB9VVq8eDE+OkyYLHfmbbd5dyCEEwg+vkb22+aamhLbgfYi8Ny1wzmCe+Zh5Ilp+B2gBmWs0ox0iFctA8Pxx6FGyxnudJ/YYssFGcn6o1S2AAgNjHADsXZaGvrQ7Vb28CliBtw+kMiUAaR7mAw3y627iRM7326+8Anz5SGsa X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM6PR08MB3703 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: AM5EUR03FT064.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)(136003)(39860400002)(396003)(376002)(346002)(46966005)(33430700001)(6916009)(8676002)(70586007)(33440700001)(6666004)(5660300002)(478600001)(316002)(36906005)(356005)(70206006)(8936002)(82310400002)(2906002)(44832011)(86362001)(36756003)(6506007)(69590400007)(16526019)(336012)(26005)(956004)(6486002)(82740400003)(47076004)(186003)(2616005)(6512007)(81166007)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 4fb829f8-ff97-487c-7901-08d7f65d5391 X-Forefront-PRVS: 0401647B7F X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gMFjdM71GVZ47ng+9w4CvmGRO8fGrnmsfDLXn+7hh81q4HYEx+Pva6cSpHCN/zkJ9lQtTH6AKTcUVhshxdp0KRtXLKYaNjbSmbppaO9dZ5lsr0WUxN8TkF0K7XJk9BCBnZEVg2AZN8j/ss6pG8sy0/mFuVInQKE1AUV3yUO6cotrAiJEI8LgHs2mQ0iUf0xWueJd65M5qEe7fVKbt1yfAeUPoLBaR66SHX47Jwfax6NieCs9JPuPg/PyWsIF/JFgPoqtTWBuJCJwi9TZPxJiA7MDzv3gc9xyXBAhCmTlOj1XbXCnv981H03DCSbJyMF+aK3XXnF4YR0IrHV+ADW1id9gj0o7THxyHFQJ2QjbzhzLdrmcbqAKbNnFHYJlXDOWTBdH7sPmfI7yCvMpWQDjoYhLd2PTelUvhXbpsKPSrnEmAuiLMNweMLkiQRXsl4MM4ApTnvAm7aYe/ffkRoiZp4pgLwe6bwNjSgWP1qzFImz+MCfg/US2/u9MTS5SA+aYeAzRgGu1cJpctERPplL71JOAmstQxkm8MfZK+VVZZw79/ucmYufMcOkNXwpCg9Gzdk+i+vVCUpCTAvek9x5fNy9J5BPqS2s1dXGLXdRTpgYr9TmK67+eC7Tt3lkXznkoMDGoI1iNWYBM33TMo2z8GA== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2020 10:15:06.7651 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f9a1ebcc-b5bf-4342-a862-08d7f65d5832 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: AM4PR0802MB2259 X-Spam-Status: No, score=-20.1 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) \