From: Ard Biesheuvel <ardb@kernel.org>
To: linux-efi@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org, keescook@chromium.org,
mark.rutland@arm.com, catalin.marinas@arm.com,
Ard Biesheuvel <ardb@kernel.org>
Subject: [RFC PATCH v2 13/18] arm64: head: record CPU boot mode after enabling the MMU
Date: Wed, 30 Mar 2022 17:42:00 +0200 [thread overview]
Message-ID: <20220330154205.2483167-14-ardb@kernel.org> (raw)
In-Reply-To: <20220330154205.2483167-1-ardb@kernel.org>
In order to avoid having to touch memory with the MMU and caches
disabled, and therefore having to invalidate it from the caches
explicitly, just defer storing the boot mode until after the MMU has
been turned on.
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
---
arch/arm64/kernel/head.S | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/kernel/head.S b/arch/arm64/kernel/head.S
index db315129f15d..ec57a29f3f43 100644
--- a/arch/arm64/kernel/head.S
+++ b/arch/arm64/kernel/head.S
@@ -81,7 +81,8 @@
* The following callee saved general purpose registers are used on the
* primary lowlevel boot path:
*
- * Register Scope Purpose
+ * Register Scope Purpose
+ * x20 primary_entry() .. __primary_switch() CPU boot mode
* x21 primary_entry() .. start_kernel() FDT pointer passed at boot in x0
* x22 primary_entry() .. start_kernel() whether we entered with the MMU on
* x23 __primary_switch() .. relocate_kernel() physical misalignment/KASLR offset
@@ -91,7 +92,7 @@ SYM_CODE_START(primary_entry)
bl preserve_boot_args
bl create_idmap
bl init_kernel_el // w0=cpu_boot_mode
- bl set_cpu_boot_mode_flag
+ mov x20, x0
/*
* The following calls CPU setup code, see arch/arm64/mm/proc.S for
@@ -576,8 +577,6 @@ SYM_FUNC_START_LOCAL(set_cpu_boot_mode_flag)
b.ne 1f
add x1, x1, #4
1: str w0, [x1] // Save CPU boot mode
- dmb sy
- dc ivac, x1 // Invalidate potentially stale cache line
ret
SYM_FUNC_END(set_cpu_boot_mode_flag)
@@ -615,7 +614,7 @@ SYM_DATA_END(__early_cpu_boot_status)
*/
SYM_FUNC_START(secondary_holding_pen)
bl init_kernel_el // w0=cpu_boot_mode
- bl set_cpu_boot_mode_flag
+ mov x20, x0
mrs x0, mpidr_el1
mov_q x1, MPIDR_HWID_BITMASK
and x0, x0, x1
@@ -633,7 +632,7 @@ SYM_FUNC_END(secondary_holding_pen)
*/
SYM_FUNC_START(secondary_entry)
bl init_kernel_el // w0=cpu_boot_mode
- bl set_cpu_boot_mode_flag
+ mov x20, x0
b secondary_startup
SYM_FUNC_END(secondary_entry)
@@ -646,6 +645,8 @@ SYM_FUNC_START_LOCAL(secondary_startup)
bl __cpu_setup // initialise processor
adrp x1, swapper_pg_dir
bl __enable_mmu
+ mov x0, x20
+ bl set_cpu_boot_mode_flag
ldr x8, =__secondary_switched
br x8
SYM_FUNC_END(secondary_startup)
@@ -861,6 +862,9 @@ SYM_FUNC_START_LOCAL(__primary_switch)
bl __enable_mmu
bl clear_page_tables
+ mov x0, x20
+ bl set_cpu_boot_mode_flag
+
#ifdef CONFIG_RELOCATABLE
adrp x23, __PHYS_OFFSET
and x23, x23, MIN_KIMG_ALIGN - 1
--
2.30.2
next prev parent reply other threads:[~2022-03-30 15:42 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-30 15:41 [RFC PATCH v2 00/18] arm64: efi: leave MMU and caches on at boot Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 01/18] arm64: head: drop idmap_ptrs_per_pgd Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 02/18] arm64: head: split off idmap creation code Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 03/18] arm64: kernel: drop unnecessary PoC cache clean+invalidate Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 04/18] arm64: head: cover entire kernel image in ID map Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 05/18] arm64: head: factor out TTBR1 assignment into a macro Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 06/18] arm64: head: populate kernel page tables with MMU and caches on Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 07/18] arm64: kaslr: deal with init called with VA randomization enabled Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 08/18] arm64: setup: defer R/O remapping of FDT Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 09/18] arm64: head: relocate kernel only a single time if KASLR is enabled Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 10/18] arm64: head: record the MMU state at primary entry Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 11/18] arm64: mm: make vabits_actual a build time constant if possible Ard Biesheuvel
2022-03-30 15:41 ` [RFC PATCH v2 12/18] arm64: head: avoid cache invalidation when entering with the MMU on Ard Biesheuvel
2022-03-30 15:42 ` Ard Biesheuvel [this message]
2022-03-30 15:42 ` [RFC PATCH v2 14/18] arm64: head: clean the ID map page to the PoC Ard Biesheuvel
2022-03-30 15:42 ` [RFC PATCH v2 15/18] arm64: lds: move idmap_pg_dir out of .rodata Ard Biesheuvel
2022-03-30 15:42 ` [RFC PATCH v2 16/18] efi: libstub: pass image handle to handle_kernel_image() Ard Biesheuvel
2022-03-30 15:42 ` [RFC PATCH v2 17/18] efi/arm64: libstub: run image in place if randomized by the loader Ard Biesheuvel
2022-03-30 15:42 ` [RFC PATCH v2 18/18] arm64: efi/libstub: enter with the MMU on if executing in place Ard Biesheuvel
2022-03-31 15:37 ` [RFC PATCH v2 00/18] arm64: efi: leave MMU and caches on at boot Mark Rutland
2022-03-31 16:20 ` Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220330154205.2483167-14-ardb@kernel.org \
--to=ardb@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=keescook@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-efi@vger.kernel.org \
--cc=mark.rutland@arm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).