From patchwork Mon Sep 14 09:56:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254227 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B998BC43461 for ; Mon, 14 Sep 2020 09:57:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 832CC21BE5 for ; Mon, 14 Sep 2020 09:57:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077453; bh=ZktTHwaeE3hkSCjdusjTsi9JrBRGAVazC164mdkYVqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=H63f+MZS5RjluN/7aaN9Zh3bWWFnRz0yrE4QhZ5oWIVgVKMhS/zT3Au+ex5oL7bkQ qV6xAHFVdP6OdfnKqmCCsz+Gq3Wdko9/ougxZsdFbkOvlZyuOAo2mPGDyzXt5Vuovn a9Gm4QfK6xeaim6JGt6Hzvyzfjg7qk44G+stjjAY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgINJ5c (ORCPT ); Mon, 14 Sep 2020 05:57:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:48784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgINJ5c (ORCPT ); Mon, 14 Sep 2020 05:57:32 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 639062192A; Mon, 14 Sep 2020 09:57:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077451; bh=ZktTHwaeE3hkSCjdusjTsi9JrBRGAVazC164mdkYVqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cW1LmI0SZDI8ktFDsBtRXB0+cefaZK+U3d02oWFgqAqFKroV1hWwu2dxQMr+FoWtP Bz35iuitbsrZqI5FP4T/iGWpLa3nrOucotZo/v5WSNueYQf9tqQGq2WkAYqNTf63zB r/VFQ1vHghjntZcG4n5YdqvM96fQ7iioarW7Y5Sc= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 02/12] ARM: efistub: replace adrl pseudo-op with adr_l macro invocation Date: Mon, 14 Sep 2020 12:56:56 +0300 Message-Id: <20200914095706.3985-3-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org The ARM 'adrl' pseudo instruction is a bit problematic, as it does not exist in Thumb mode, and it is not implemented by Clang either. Since the Thumb variant has a slightly bigger range, it is sometimes necessary to emit the 'adrl' variant in ARM mode where Thumb mode can use adr just fine. However, that still leaves the Clang issue, which does not appear to be supporting this any time soon. So let's switch to the adr_l macro, which works for both ARM and Thumb, and has unlimited range. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/head.S | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 434a16982e34..6a430d1f4d31 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -1444,8 +1444,7 @@ ENTRY(efi_enter_kernel) mov r4, r0 @ preserve image base mov r8, r1 @ preserve DT pointer - ARM( adrl r0, call_cache_fn ) - THUMB( adr r0, call_cache_fn ) + adr_l r0, call_cache_fn adr r1, 0f @ clean the region of code we bl cache_clean_flush @ may run with the MMU off From patchwork Mon Sep 14 09:56:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254226 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFB85C2BC11 for ; Mon, 14 Sep 2020 09:57:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AFD7B21D1A for ; Mon, 14 Sep 2020 09:57:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077465; bh=TKAzFxIirDIxYLKYqD+6+dUlS9CQKVaHrk/5tQYGlrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=RM1pR+usyRDgznATW2biEQnblz57L2bksKvDROJ3HoA9CX/4wFdK9lWe1LmUQXesh u8cO5eW7eMlEOW5YfOmxTFk+ZpG8qF8Wr/RimeaMP2XMpm4O1YzhZfgCDHLWieY/7O Le/VtjU8wDD8Px7kZl6tKYJ2aiT1D1IMIqcdCCzk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726343AbgINJ5o (ORCPT ); Mon, 14 Sep 2020 05:57:44 -0400 Received: from mail.kernel.org ([198.145.29.99]:48914 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726308AbgINJ5k (ORCPT ); Mon, 14 Sep 2020 05:57:40 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AC47420731; Mon, 14 Sep 2020 09:57:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077460; bh=TKAzFxIirDIxYLKYqD+6+dUlS9CQKVaHrk/5tQYGlrg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ZkICpSKb6xO0VKoVM+24PwfMqMcyAc5VY534f4aYsk0mlyIwTsDxXXDFqvRY1Pw1q lHjz5BHkDOJL4hp4SrsAYA+ytLIuluK2IygS2mhgQg5FwebZ78krigh987/OJmXYia itPwELzY9tmQ6lTi0U9Sz2uMJ8JqqhzCpD4R05QQ= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 04/12] ARM: head-common.S: use PC-relative insn sequence for __proc_info Date: Mon, 14 Sep 2020 12:56:58 +0300 Message-Id: <20200914095706.3985-5-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Replace the open coded PC relative offset calculations with a pair of adr_l invocations. This removes some open coded arithmetic involving virtual addresses, avoids literal pools on v7+, and slightly reduces the footprint of the code. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/head-common.S | 22 ++++++-------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/arch/arm/kernel/head-common.S b/arch/arm/kernel/head-common.S index 4a3982812a40..9a5ab6c19568 100644 --- a/arch/arm/kernel/head-common.S +++ b/arch/arm/kernel/head-common.S @@ -170,11 +170,12 @@ ENDPROC(lookup_processor_type) * r9 = cpuid (preserved) */ __lookup_processor_type: - adr r3, __lookup_processor_type_data - ldmia r3, {r4 - r6} - sub r3, r3, r4 @ get offset between virt&phys - add r5, r5, r3 @ convert virt addresses to - add r6, r6, r3 @ physical address space + /* + * Look in for information about the __proc_info + * structure. + */ + adr_l r5, __proc_info_begin + adr_l r6, __proc_info_end 1: ldmia r5, {r3, r4} @ value, mask and r4, r4, r9 @ mask wanted bits teq r3, r4 @@ -186,17 +187,6 @@ __lookup_processor_type: 2: ret lr ENDPROC(__lookup_processor_type) -/* - * Look in for information about the __proc_info structure. - */ - .align 2 - .type __lookup_processor_type_data, %object -__lookup_processor_type_data: - .long . - .long __proc_info_begin - .long __proc_info_end - .size __lookup_processor_type_data, . - __lookup_processor_type_data - __error_lpae: #ifdef CONFIG_DEBUG_LL adr r0, str_lpae From patchwork Mon Sep 14 09:57:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254225 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 909DCC433E2 for ; Mon, 14 Sep 2020 09:57:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4B9B4221E3 for ; Mon, 14 Sep 2020 09:57:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077470; bh=Wkk64XuID7r9R1jYYqwP5aBOfNogdTl+OiAJ/dFmveI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=n4Zta7NFC2Q29kLkaM1kLvzGDbRfFbZSDUBrhhMUig/Bizn6+zIYhrDDiR6TL7fK9 q/3rl/Dm+OvsH3qPvgOwHiZtrM2MOMg0nemFc9gJjjTHyc6ThC7/6UotcIZin1h55w cm7helpuugbUyhow9Ex6kZ4gfsS5ZkiHmFFUY2wY= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726308AbgINJ5t (ORCPT ); Mon, 14 Sep 2020 05:57:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:49012 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726239AbgINJ5s (ORCPT ); Mon, 14 Sep 2020 05:57:48 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C2A1E20732; Mon, 14 Sep 2020 09:57:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077468; bh=Wkk64XuID7r9R1jYYqwP5aBOfNogdTl+OiAJ/dFmveI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fR20cE2OUxGxtkPOvbgPhceoIQMNNLlPvb+J5wHhlLztBQ15T/8VZcmxvctJcLf84 tvkegZjd1D2h9+4VPwu1Q+V5+nqFyjeeyxhV8KSLZWvPL2uolHmZTVR0qvyt8+CAJz B6CaC88fZgExSVbrSfplllfDP1rmYEKFynUHmcjs= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 06/12] ARM: head.S: use PC-relative insn sequence for secondary_data Date: Mon, 14 Sep 2020 12:57:00 +0300 Message-Id: <20200914095706.3985-7-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Replace the open coded PC relative offset calculations with adr_l and ldr_l invocations. This removes some open coded arithmetic involving virtual addresses, avoids literal pools on v7+, and slightly reduces the footprint of the code. Note that it also removes a stale comment about the contents of r6. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/head.S | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 7d8e2a296216..40407a4727e0 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -383,10 +383,8 @@ ENTRY(secondary_startup) /* * Use the page tables supplied from __cpu_up. */ - adr r4, __secondary_data - ldmia r4, {r5, r7, r12} @ address to jump to after - sub lr, r4, r5 @ mmu has been enabled - add r3, r7, lr + adr_l r3, secondary_data + mov_l r12, __secondary_switched ldrd r4, r5, [r3, #0] @ get secondary_data.pgdir ARM_BE8(eor r4, r4, r5) @ Swap r5 and r4 in BE: ARM_BE8(eor r5, r4, r5) @ it can be done in 3 steps @@ -401,22 +399,13 @@ ARM_BE8(eor r4, r4, r5) @ without using a temp reg. ENDPROC(secondary_startup) ENDPROC(secondary_startup_arm) - /* - * r6 = &secondary_data - */ ENTRY(__secondary_switched) - ldr sp, [r7, #12] @ get secondary_data.stack + ldr_l r7, secondary_data + 12 @ get secondary_data.stack + mov sp, r7 mov fp, #0 b secondary_start_kernel ENDPROC(__secondary_switched) - .align - - .type __secondary_data, %object -__secondary_data: - .long . - .long secondary_data - .long __secondary_switched #endif /* defined(CONFIG_SMP) */ From patchwork Mon Sep 14 09:57:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254224 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 61063C43461 for ; Mon, 14 Sep 2020 09:58:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2259521BE5 for ; Mon, 14 Sep 2020 09:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077482; bh=NieCvGRheFFDbEqkhq2wZXvPlHLF2jc+r0dsBAFUpts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=VvsUhyXAhJqFKaEu6nFrDhuheJ7QEC5M3CeszSn8db8VHAtoL1u0/MrrJC5D0djsQ nU1cteHlXhwz/g3BcAeZKHl0h5FzsC/j81sH08b2oWMRGzxGi4asp/SDZfqqZIe7By pYrTjFX4vdd3uMCXX5qmiDibDE/g+IR1XusJ4HP4= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726239AbgINJ6A (ORCPT ); Mon, 14 Sep 2020 05:58:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:49162 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726344AbgINJ54 (ORCPT ); Mon, 14 Sep 2020 05:57:56 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CAF0620732; Mon, 14 Sep 2020 09:57:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077476; bh=NieCvGRheFFDbEqkhq2wZXvPlHLF2jc+r0dsBAFUpts=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=IrTJe8wuKdcrh7xrNMc0YSktFTDDzj+c+yI2G+rxxmUXFmnSKkCuEEhenYNlYa53F ichgvGT2PD2zpwx3Ft9oV9fdgmugIi3xY769bkJO9T1N8Iv7DlkOXZxq6Ki9WN1w1E l6La3wbzAz4w+QT/eYKCXYS8+czinU9wCbX2WOQ0= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 08/12] ARM: head: use PC-relative insn sequence for __smp_alt Date: Mon, 14 Sep 2020 12:57:02 +0300 Message-Id: <20200914095706.3985-9-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Now that calling __do_fixup_smp_on_up() can be done without passing the physical-to-virtual offset in r3, we can replace the open coded PC relative offset calculations with a pair of adr_l invocations. This removes some open coded arithmetic involving virtual addresses, avoids literal pools on v7+, and slightly reduces the footprint of the code. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/head.S | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 3199d29f4480..5f6436a40db1 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -520,19 +520,11 @@ ARM_BE8(rev r0, r0) @ byteswap if big endian retne lr __fixup_smp_on_up: - adr r0, 1f - ldmia r0, {r3 - r5} - sub r3, r0, r3 - add r4, r4, r3 - add r5, r5, r3 + adr_l r4, __smpalt_begin + adr_l r5, __smpalt_end b __do_fixup_smp_on_up ENDPROC(__fixup_smp) - .align -1: .word . - .word __smpalt_begin - .word __smpalt_end - .pushsection .data .align 2 .globl smp_on_up From patchwork Mon Sep 14 09:57:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254223 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4E4D9C433E2 for ; Mon, 14 Sep 2020 09:58:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E28420735 for ; Mon, 14 Sep 2020 09:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077488; bh=rDotRQsUER7JLdwSfGEMxdL7nO34me7IugF3nMXAYlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=QaX03cAzx5hXXhHrv84bitvfH+H5Dnh56g/Ur2iEzNficyP2pMqP4nnIKu53UJr6x BRoVEuK37HAYRfQPQnPTpv5A8XE8NIohcbrwIVAeyk7xd2jTPa96aBthrU+WtJLNtm czD/lf7vYmS6D0mrJ6flUwFkFlN9ouIpdRlk7gDs= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726340AbgINJ6G (ORCPT ); Mon, 14 Sep 2020 05:58:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:49306 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgINJ6F (ORCPT ); Mon, 14 Sep 2020 05:58:05 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 0A7E420732; Mon, 14 Sep 2020 09:58:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077484; bh=rDotRQsUER7JLdwSfGEMxdL7nO34me7IugF3nMXAYlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W1HPTfiHuliPl4mO/sR3G+2DeNSY4A+fgylwco9iQXzL+vujkIn0fG31nrxl+i/rt fj70N4gmv9suVWiBm+i0FrPJwcnFMdAVvhrJAl4VQyTY2Xm0GrxzoJ52b5GGyZsJQN 5ZmS5fs2Dlfy6278xlt9tb47omIJ7pU812cV5yg8= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 10/12] ARM: head.S: use PC-relative insn sequences for __fixup_pv_table Date: Mon, 14 Sep 2020 12:57:04 +0300 Message-Id: <20200914095706.3985-11-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Replace the open coded PC relative offset calculations with adr_l and mov_l invocations. This removes some open coded arithmetic involving virtual addresses and avoids literal pools on v7+. Note that the footprint of the code increases slightly, but the resulting code is a bit easier to follow. Signed-off-by: Ard Biesheuvel --- arch/arm/kernel/head.S | 27 ++++++-------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/arch/arm/kernel/head.S b/arch/arm/kernel/head.S index 5f6436a40db1..6f334df5d3b9 100644 --- a/arch/arm/kernel/head.S +++ b/arch/arm/kernel/head.S @@ -576,14 +576,11 @@ ENDPROC(fixup_smp) */ __HEAD __fixup_pv_table: - adr r0, 1f - ldmia r0, {r3-r7} + adr_l r6, __pv_phys_pfn_offset + adr_l r7, __pv_offset @ __pa(__pv_offset) + mov_l r3, __pv_offset @ __va(__pv_offset) mvn ip, #0 - subs r3, r0, r3 @ PHYS_OFFSET - PAGE_OFFSET - add r4, r4, r3 @ adjust table start address - add r5, r5, r3 @ adjust table end address - add r6, r6, r3 @ adjust __pv_phys_pfn_offset address - add r7, r7, r3 @ adjust __pv_offset address + subs r3, r7, r3 @ PHYS_OFFSET - PAGE_OFFSET mov r0, r8, lsr #PAGE_SHIFT @ convert to PFN str r0, [r6] @ save computed PHYS_OFFSET to __pv_phys_pfn_offset strcc ip, [r7, #HIGH_OFFSET] @ save to __pv_offset high bits @@ -592,20 +589,15 @@ __fixup_pv_table: THUMB( it ne @ cross section branch ) bne __error str r3, [r7, #LOW_OFFSET] @ save to __pv_offset low bits + adr_l r4, __pv_table_begin + adr_l r5, __pv_table_end b __fixup_a_pv_table ENDPROC(__fixup_pv_table) - - .align -1: .long . - .long __pv_table_begin - .long __pv_table_end -2: .long __pv_phys_pfn_offset - .long __pv_offset + .ltorg .text __fixup_a_pv_table: - adr r0, 3f - ldr r6, [r0] + mov_l r6, __pv_offset add r6, r6, r3 ldr r0, [r6, #HIGH_OFFSET] @ pv_offset high word ldr r6, [r6, #LOW_OFFSET] @ pv_offset low word @@ -674,9 +666,6 @@ ARM_BE8(rev16 ip, ip) #endif ENDPROC(__fixup_a_pv_table) - .align -3: .long __pv_offset - ENTRY(fixup_pv_table) stmfd sp!, {r4 - r7, lr} mov r3, #0 @ no offset From patchwork Mon Sep 14 09:57:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 254222 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 32F5CC43461 for ; Mon, 14 Sep 2020 09:58:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED03320732 for ; Mon, 14 Sep 2020 09:58:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077495; bh=77RIzJYqzlmKEeo4Ksd7J+ddgYyfqCTidiKyeJAjbLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=W81SdJ60gqMV+egbHHVdJbs1+4fMZ5tGE6YyZRLADntIM4WEgrsRThSFW2WUohYKQ n1G9cvCaumdpQ+7oEWlhejIcFPEanM7S4jL3Ci2L0Kb/M/Dqv9zu2k/gUwoALOMlwW s4mZdrwphymMxnwqOTXg7IHJNNNkxb33YogssFN0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbgINJ6O (ORCPT ); Mon, 14 Sep 2020 05:58:14 -0400 Received: from mail.kernel.org ([198.145.29.99]:49422 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726302AbgINJ6N (ORCPT ); Mon, 14 Sep 2020 05:58:13 -0400 Received: from e123331-lin.nice.arm.com (unknown [37.6.197.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3061D20735; Mon, 14 Sep 2020 09:58:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1600077492; bh=77RIzJYqzlmKEeo4Ksd7J+ddgYyfqCTidiKyeJAjbLY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=s5+J05zaCKdaonqfYWnG4GkCswxWHBEuzx5BYysTrZ70lqnJ3BUi0EfnVSklZQQm+ UPGfiLWoRjv2Ssntm0x9ov2aChKYUgdVUX5nBksu7OSNAObD9TFN3ILNvBdFlKpHM2 TqC1fdWrQqxdjfg/hHOhIVTtC+kQN42qp1xsqmnM= From: Ard Biesheuvel To: linux-efi@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Russell King , Linus Walleij , Nicolas Pitre , Nick Desaulniers , Stefan Agner , Peter Smith , Marc Zyngier , Will Deacon Subject: [PATCH 12/12] ARM: kvm: replace open coded VA->PA calculations with adr_l call Date: Mon, 14 Sep 2020 12:57:06 +0300 Message-Id: <20200914095706.3985-13-ardb@kernel.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200914095706.3985-1-ardb@kernel.org> References: <20200914095706.3985-1-ardb@kernel.org> Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Replace the open coded calculations of the actual physical address of the KVM stub vector table with a single adr_l invocation. Signed-off-by: Ard Biesheuvel --- arch/arm/boot/compressed/head.S | 15 ++--------- arch/arm/kernel/hyp-stub.S | 27 +++++++++----------- 2 files changed, 14 insertions(+), 28 deletions(-) diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S index 6a430d1f4d31..ab800f7e0dc1 100644 --- a/arch/arm/boot/compressed/head.S +++ b/arch/arm/boot/compressed/head.S @@ -472,15 +472,10 @@ dtb_check_done: /* * Compute the address of the hyp vectors after relocation. - * This requires some arithmetic since we cannot directly - * reference __hyp_stub_vectors in a PC-relative way. * Call __hyp_set_vectors with the new address so that we * can HVC again after the copy. */ -0: adr r0, 0b - movw r1, #:lower16:__hyp_stub_vectors - 0b - movt r1, #:upper16:__hyp_stub_vectors - 0b - add r0, r0, r1 + adr_l r0, __hyp_stub_vectors sub r0, r0, r5 add r0, r0, r10 bl __hyp_set_vectors @@ -631,17 +626,11 @@ not_relocated: mov r0, #0 cmp r0, #HYP_MODE @ if not booted in HYP mode... bne __enter_kernel @ boot kernel directly - adr r12, .L__hyp_reentry_vectors_offset - ldr r0, [r12] - add r0, r0, r12 - + adr_l r0, __hyp_reentry_vectors bl __hyp_set_vectors __HVC(0) @ otherwise bounce to hyp mode b . @ should never be reached - - .align 2 -.L__hyp_reentry_vectors_offset: .long __hyp_reentry_vectors - . #else b __enter_kernel #endif diff --git a/arch/arm/kernel/hyp-stub.S b/arch/arm/kernel/hyp-stub.S index 26d8e03b1dd3..103d0bdb2b7e 100644 --- a/arch/arm/kernel/hyp-stub.S +++ b/arch/arm/kernel/hyp-stub.S @@ -24,41 +24,38 @@ ENTRY(__boot_cpu_mode) .text /* - * Save the primary CPU boot mode. Requires 3 scratch registers. + * Save the primary CPU boot mode. Requires 2 scratch registers. */ - .macro store_primary_cpu_mode reg1, reg2, reg3 + .macro store_primary_cpu_mode reg1, reg2 mrs \reg1, cpsr and \reg1, \reg1, #MODE_MASK - adr \reg2, .L__boot_cpu_mode_offset - ldr \reg3, [\reg2] - str \reg1, [\reg2, \reg3] + str_l \reg1, __boot_cpu_mode, \reg2 .endm /* * Compare the current mode with the one saved on the primary CPU. * If they don't match, record that fact. The Z bit indicates * if there's a match or not. - * Requires 3 additionnal scratch registers. + * Requires 2 additional scratch registers. */ - .macro compare_cpu_mode_with_primary mode, reg1, reg2, reg3 - adr \reg2, .L__boot_cpu_mode_offset - ldr \reg3, [\reg2] - ldr \reg1, [\reg2, \reg3] + .macro compare_cpu_mode_with_primary mode, reg1, reg2 + adr_l \reg2, __boot_cpu_mode + ldr \reg1, [\reg2] cmp \mode, \reg1 @ matches primary CPU boot mode? orrne \reg1, \reg1, #BOOT_CPU_MODE_MISMATCH - strne \reg1, [\reg2, \reg3] @ record what happened and give up + strne \reg1, [\reg2] @ record what happened and give up .endm #else /* ZIMAGE */ - .macro store_primary_cpu_mode reg1:req, reg2:req, reg3:req + .macro store_primary_cpu_mode reg1:req, reg2:req .endm /* * The zImage loader only runs on one CPU, so we don't bother with mult-CPU * consistency checking: */ - .macro compare_cpu_mode_with_primary mode, reg1, reg2, reg3 + .macro compare_cpu_mode_with_primary mode, reg1, reg2 cmp \mode, \mode .endm @@ -73,7 +70,7 @@ ENTRY(__boot_cpu_mode) */ @ Call this from the primary CPU ENTRY(__hyp_stub_install) - store_primary_cpu_mode r4, r5, r6 + store_primary_cpu_mode r4, r5 ENDPROC(__hyp_stub_install) @ fall through... @@ -87,7 +84,7 @@ ENTRY(__hyp_stub_install_secondary) * If the secondary has booted with a different mode, give up * immediately. */ - compare_cpu_mode_with_primary r4, r5, r6, r7 + compare_cpu_mode_with_primary r4, r5, r6 retne lr /*