[RFC PATCH v2 13/18] arm64: head: record CPU boot mode after enabling the MMU
Ard Biesheuvel
ardb at kernel.org
Wed Mar 30 08:42:00 PDT 2022
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 at 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
More information about the linux-arm-kernel
mailing list