From patchwork Fri Jun 12 13:29:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Szabolcs Nagy X-Patchwork-Id: 39577 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 F2E40395B057; Fri, 12 Jun 2020 13:30:00 +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-eopbgr80080.outbound.protection.outlook.com [40.107.8.80]) by sourceware.org (Postfix) with ESMTPS id 5286B395B04B for ; Fri, 12 Jun 2020 13:29:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 5286B395B04B 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=lLK4HZD7bXNQw3+NicfAn1dGOXUjk7gVbJ/4m/i4q0nvQTA0Z1CmjyhY5B3zyt/8q4C4VfDqbRLmDVRzI7HABA83KnAX+kF4XdffrXXQwfrk84bgZG23sVToH+15rs5BEKf1IY6EedIwZ6TPAnDZaHsx7otNwtiMO8jdPtbJsg0= Received: from AM6PR05CA0003.eurprd05.prod.outlook.com (2603:10a6:20b:2e::16) by HE1PR0802MB2378.eurprd08.prod.outlook.com (2603:10a6:3:c8::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3066.23; Fri, 12 Jun 2020 13:29:56 +0000 Received: from AM5EUR03FT050.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:2e:cafe::55) by AM6PR05CA0003.outlook.office365.com (2603:10a6:20b:2e::16) 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:29:56 +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:29:56 +0000 Received: ("Tessian outbound 56dbe829191e:v59"); Fri, 12 Jun 2020 13:29:56 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 695c80cb209c5c57 X-CR-MTA-TID: 64aa7808 Received: from 76c30fe3e585.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id A7227179-A6BB-4E82-8D93-723568EBCC2D.1; Fri, 12 Jun 2020 13:29:51 +0000 Received: from EUR02-HE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id 76c30fe3e585.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Fri, 12 Jun 2020 13:29:51 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=futpian6yZtx80sD3/sYtAzG4Jz2mDxtADt5DcZrvOMSo4LKJwO/XPGIPZF5LdxoYYOsns03n7Sd+n/AYZ1nHIvPYycBgCrcT358pJty81Sy8hYKZOi+J7dGwfqJ/epwXrvZXM0LbBVMOUomGJZHy/IOdO3Gu5RM4dPDLQ6vSB3ntYSdEj1JrWdKOjRDyIaLlWNNXjJ1sBoBZjmjMsdXPwB5nRiD+pqV9XpnFlSNCkyBWZtqvpP4HQyCxNZoPRBpALjlbkpY4Zmj4b1wiF6p1PRkp4snocAG/Cjy1290SXijZ8EdYGmdJzgml+GPcF6VOuzH4TBpqlD2RuN6AICh0w== 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=B1d5ZRQ3UCVMoCC3p82BFuJmnWOWqiwXIE8ONLooabKVe4YQ2Jd0OC32Pajv6qbbFUpZd+EKeH07KrQrQAz1oSNz66v/J6QDEIfvGKyn1oBY0w4WGdCWCtotwA2THQWHjlWV+xg+yRB3QjkApqRBSZAcLQDN3l3MTolC5XktTTZkHuYA6SBfuLY0TAG35e1OslmLTduAq5saddk6U99oPiu2SCHW0/Hhc/7MPewiKBpUrbe1f+j5ITjTpePupAgWcXr9+FDCWqQTBt1bHQO1FBxPf1AHF6sFBtSSkav3BnBpiXY45Vi+jSIG8bUyy3dhzDQcOox9ppLovs3oUgrT/A== 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=lLK4HZD7bXNQw3+NicfAn1dGOXUjk7gVbJ/4m/i4q0nvQTA0Z1CmjyhY5B3zyt/8q4C4VfDqbRLmDVRzI7HABA83KnAX+kF4XdffrXXQwfrk84bgZG23sVToH+15rs5BEKf1IY6EedIwZ6TPAnDZaHsx7otNwtiMO8jdPtbJsg0= 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:49 +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:49 +0000 From: Szabolcs Nagy To: libc-alpha@sourceware.org Subject: [PATCH v4 06/12] aarch64: fix RTLD_START for BTI Date: Fri, 12 Jun 2020 14:29:24 +0100 Message-Id: <57cb426ba11bb6b9938179dbf7f3deba2512f7c0.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:48 +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: cd03fa65-6e33-41b6-be14-08d80ed4b29e X-MS-TrafficTypeDiagnostic: AM6PR08MB3912:|HE1PR0802MB2378: X-Microsoft-Antispam-PRVS: x-checkrecipientrouted: true NoDisclaimer: true X-MS-Oob-TLC-OOBClassifiers: OLM:9508;OLM:9508; X-Forefront-PRVS: 0432A04947 X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: gYEcZNw0VfYUxPM8lp4fkEwF2T5f7UWbU4QPQQL+VqkDvCEqsocDGqpxaoL/bgeucwsJj+qADt2ptdHQSFm5ecGUqylktKI8SQqV5vGybuGK76rGsKazPkeKBesJdXQi4W6V98w0zE+u+BulSf4AFviAxnvfTixpNenLHbGlLOlXbCz3tWjwVCOmHQqLpDkq6hygr1OlP0LNsa7xfqrO/Vv+1a40GaouWRqa04AyFQmri1NyKvJdVYBItMaGb+5rVmoAmbY9PaVIXh06o97wHXkWeApmrejDY0LArC6s4FLB842iY17WK2KkxPAqVj7ML7ASokPNb66DxoChZwBlAAzQtgJnEa9Ny5mfHBRjV8DK6Q3JHdvDc3WDxfQsIRFq4/vcQNtraVO7WTpEagQKBQnQquMsTB7tpHMbMpPHL3A= 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: N1Rlgb1pSaIPAunr5Fxy8wCLwCLPoZdgEuOwZX1as6OXO+zvXkvpXcVFbla/kMZcnHZgSjIQ+sfBwTP2W9/x7kYlxnNnk72EI1sWPEUW4GlWxDY9EaT48G9gsGhMdVrFACa3BX4B1+QacT4xImRKGggTvC/ho/VyDaV3SO0o036WslYmaerBlZAPxOyg1aGATySw6/Tny/wOFuwqVoUkDoXJixNIO8S3fO/vIlSjFzcTuRVMAtsM39xdMx3mpNs9f2/I35hzvtVeJJmuPFhzeGetagJnn3LJKLd3y/MCBcpQ1qsqQ8VlbYxNCldMx1OdVyGmpRqBEZAPqmYzVREolzx42rsBsrv/TB7/kpWe/gjDtAu7dAGBi+vLJBNMIH3t4ywhKXIYuwzNdYvotvfGqzwPEtr/ac+gC8z9EVwRp3bHcGmQoDfTLMsHnE3B1eMKnSBggvQkzBetmq4nCeVs8/ZzPBOZMuOC0c5JxWeKWiw= 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)(39860400002)(136003)(346002)(376002)(396003)(46966005)(8676002)(16526019)(186003)(5660300002)(356005)(36756003)(83380400001)(86362001)(316002)(36906005)(2616005)(44832011)(26005)(82310400002)(8936002)(956004)(6506007)(336012)(2906002)(82740400003)(47076004)(81166007)(6916009)(6666004)(69590400007)(70586007)(6512007)(6486002)(70206006)(478600001)(136400200001); DIR:OUT; SFP:1101; X-MS-Office365-Filtering-Correlation-Id-Prvs: 535eaa48-9e76-4b72-b1d1-08d80ed4ae69 X-Forefront-PRVS: 0432A04947 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: kNrLvee1e3rtxd/qhYMBYIQukKvfiRdujiN32A4xi9xRvEYg1ZeQubsZSRiKkIauKvhnMn5f/1vJNLscFfWgw0OIfuGM5g1uTN+vflMu8w+cVMI02+AMwlpKy10Ts/7s4CIa5kdkgNtftNGu5B4jUlJ/fWAdyJnkrHDW+JJ+rY0H/4FosyQCuY4x7/I6zey0WZU0ci2GtKK/FXn9geXbtPxyQ03V1pD4XvmmpcMqFhjrQv0jsWn70+0sC6cynbWE3ynKQs1d5CmyY0ZWbJkRSOewsPlyUc1uPlCZqOvdxLSKjqDnM2KxpqGKhIbJDYd8wL7ItR+0cnXtP9/qcZOu5BQjgec35ST/LHU/itH5P8+04tKdbAV9Jg39Wid+9xoBldyZ7CZVcAO0c6wom84knzsJA0defA+ieNexpXSxoMC7U/gV8frqals1JFhgTHWg/pgFRMLZEJOklcIJG5pTpg== X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jun 2020 13:29:56.4928 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cd03fa65-6e33-41b6-be14-08d80ed4b29e 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: HE1PR0802MB2378 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" 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) \