From patchwork Tue Jun 19 19:26:32 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 10475271 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE42D601D7 for ; Tue, 19 Jun 2018 19:28:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A3B0628438 for ; Tue, 19 Jun 2018 19:28:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9882228459; Tue, 19 Jun 2018 19:28:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 34D2F28438 for ; Tue, 19 Jun 2018 19:28:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=/DRsm8euH6p78dSDbF3ne4atkHVT02mWfXoLZM+6dUU=; b=b7HpYPp2ThimHNMqKKzcxzE0bC jc8ekJPNegHWSIzo8H9/cn7hHWhHv6G3CrnHwIOZHWTfZPYdZMKgWi7pgQTy7BQgHTwlV6AGCSpE5 EW/02JwVjzJW3IGSGfyap8m7WYxID6M8ReDbNt7QqkmPXKPaqy87U3nrtHE95cufx4yRT1jXx6hNl EJpv5IrJAlUYjOtyUekEmmahAli2vT+yIARwSKkVpiWdjd0prZP9n9JIpjRAZNfGxoaxOZSqpkwql DvshttU5RjLSkfV1JbBRDAtLcB0/SDy1RWn9FYy84uPb8YTrEAKgNg4Cto+3xZdjWhIv+3V/ASKvr fGzzg46g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVMIj-0002d4-38; Tue, 19 Jun 2018 19:28:25 +0000 Received: from mail-wr0-x242.google.com ([2a00:1450:400c:c0c::242]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fVMII-0002MS-1t for linux-arm-kernel@lists.infradead.org; Tue, 19 Jun 2018 19:27:59 +0000 Received: by mail-wr0-x242.google.com with SMTP id w7-v6so793631wrn.6 for ; Tue, 19 Jun 2018 12:27:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=DW28HMLEUGoRqgLlA7upbDDKO5Z+/RlxqvmR8s+h2lw=; b=hj1YTnmPbXxhKwvZEAVYKAjMPvGhzmGIgOZPls9AssyYVdfnulHJUr1bdvCOeNVBOF VLQRfv2CfWaZDO6wolpcmcWLW69oOD69fccM2NZ0maQgaUAvVYEYx+knBdKq6C+O7v4N Fh3E7OXHIkK65PWzlDmcpb88sSwdw6+ttuDtg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=DW28HMLEUGoRqgLlA7upbDDKO5Z+/RlxqvmR8s+h2lw=; b=fhnPWmZ7j2LHanCybXyU64v5NEA4jAjMB72Y5+vw/T4/AirxSDx+B78l29P/dRcawi LhOGeiy1l1dPF6morLD8XWpPNitI1W04bT+Bl1yrYGEIO8vdqwhoyHQOUfbFIEY2jRuU vZ/Tc+u3FBWUNGRvsd7UUsZP07fJ04Mkx/84E+JNuvkTLdfNC2nkHaNHdNe3w9rGKkbe pRbb5fFvgb0rBwaYhqJVPBTs1Z1HMUg1YAjsPiFL1jU9ZPJKfa/V5WG6uT1XLMMkiPO9 thlVIo+zbA0vGCK5T4OeDY6Ai3YPdzM3te49uOdoWoLeI9w+so0SSq4vPuFn0zd4dRlE FIrA== X-Gm-Message-State: APt69E2gKNyQk4stHv2ZS113S54GRAuGOf6RuDGX/QRpMM428+mDJtwG kMCeAPkUnvUZOAlH5dWgBhwzJJxgzAA= X-Google-Smtp-Source: ADUXVKJwf3eTpJ9Lawx/SKxU/m8QWpVYkUL8zCbDIA9zliiYrUeOFbBHqVCPqiTYMqm6QpUEwDbrMw== X-Received: by 2002:adf:9187:: with SMTP id 7-v6mr16335104wri.69.1529436466172; Tue, 19 Jun 2018 12:27:46 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:a06d:5653:4fd5:13a]) by smtp.gmail.com with ESMTPSA id c53-v6sm982601wrg.12.2018.06.19.12.27.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 19 Jun 2018 12:27:45 -0700 (PDT) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] ARM: avoid badr macro for switching to Thumb-2 mode Date: Tue, 19 Jun 2018 21:26:32 +0200 Message-Id: <20180619192633.21846-2-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180619192633.21846-1-ard.biesheuvel@linaro.org> References: <20180619192633.21846-1-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180619_122758_091637_BC273111 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, arnd@arndb.de, Ard Biesheuvel , linux@armlinux.org.uk, linux-kernel@vger.kernel.org, linux@roeck-us.net MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Switching to Thumb-2 mode can be done using a single 'sub' instruction so use that instead of the badr macro in various places in the code. This allows us to reimplement the macro in a way that does not allow it to be used in ARM code sequences when building a Thumb2 kernel. Signed-off-by: Ard Biesheuvel --- arch/arm/common/mcpm_head.S | 5 ++--- arch/arm/kernel/head-nommu.S | 7 +++---- arch/arm/kernel/head.S | 15 +++++++-------- arch/arm/kernel/sleep.S | 7 +++---- 4 files changed, 15 insertions(+), 19 deletions(-) diff --git a/arch/arm/common/mcpm_head.S b/arch/arm/common/mcpm_head.S index 08b3bb9bc6a2..4c72314e87a3 100644 --- a/arch/arm/common/mcpm_head.S +++ b/arch/arm/common/mcpm_head.S @@ -49,10 +49,9 @@ ENTRY(mcpm_entry_point) ARM_BE8(setend be) - THUMB( badr r12, 1f ) - THUMB( bx r12 ) + THUMB( sub pc, pc, #3 ) THUMB( .thumb ) -1: + mrc p15, 0, r0, c0, c0, 5 @ MPIDR ubfx r9, r0, #0, #8 @ r9 = cpu ubfx r10, r0, #8, #8 @ r10 = cluster diff --git a/arch/arm/kernel/head-nommu.S b/arch/arm/kernel/head-nommu.S index dae8fa2f72c5..406dab0b773c 100644 --- a/arch/arm/kernel/head-nommu.S +++ b/arch/arm/kernel/head-nommu.S @@ -47,10 +47,9 @@ ENTRY(stext) .arm ENTRY(stext) - THUMB( badr r9, 1f ) @ Kernel is always entered in ARM. - THUMB( bx r9 ) @ If this is a Thumb-2 kernel, - THUMB( .thumb ) @ switch to Thumb now. - THUMB(1: ) + THUMB( sub pc, pc, #3 ) @ Kernel is always entered in ARM. + THUMB( .thumb ) @ If this is a Thumb-2 kernel, + @ switch to Thumb now. #endif setmode PSR_F_BIT | PSR_I_BIT | SVC_MODE, r9 @ ensure svc mode diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 4b815821ec02..1e44ee9b2074 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -80,10 +80,9 @@ ENTRY(stext) ARM_BE8(setend be ) @ ensure we are in BE8 mode - THUMB( badr r9, 1f ) @ Kernel is always entered in ARM. - THUMB( bx r9 ) @ If this is a Thumb-2 kernel, - THUMB( .thumb ) @ switch to Thumb now. - THUMB(1: ) + THUMB( sub pc, pc, #3 ) @ Kernel is always entered in ARM. + THUMB( .thumb ) @ If this is a Thumb-2 kernel, + @ switch to Thumb now. #ifdef CONFIG_ARM_VIRT_EXT bl __hyp_stub_install @@ -363,10 +362,10 @@ __turn_mmu_on_loc: .text .arm ENTRY(secondary_startup_arm) - THUMB( badr r9, 1f ) @ Kernel is entered in ARM. - THUMB( bx r9 ) @ If this is a Thumb-2 kernel, - THUMB( .thumb ) @ switch to Thumb now. - THUMB(1: ) + THUMB( sub pc, pc, #3 ) @ Kernel is entered in ARM. + THUMB( .thumb ) @ If this is a Thumb-2 kernel, + @ switch to Thumb now. + ENTRY(secondary_startup) /* * Common entry point for secondary CPUs. diff --git a/arch/arm/kernel/sleep.S b/arch/arm/kernel/sleep.S index a8257fc9cf2a..76b3d7c1c8d0 100644 --- a/arch/arm/kernel/sleep.S +++ b/arch/arm/kernel/sleep.S @@ -123,10 +123,9 @@ ENDPROC(cpu_resume_after_mmu) #ifdef CONFIG_MMU .arm ENTRY(cpu_resume_arm) - THUMB( badr r9, 1f ) @ Kernel is entered in ARM. - THUMB( bx r9 ) @ If this is a Thumb-2 kernel, - THUMB( .thumb ) @ switch to Thumb now. - THUMB(1: ) + THUMB( sub pc, pc, #3 ) @ Kernel is entered in ARM. + THUMB( .thumb ) @ If this is a Thumb-2 kernel, + @ switch to Thumb now. #endif ENTRY(cpu_resume)