Skip to content

Commit 34e526c

Browse files
ardbiesheuvelctmarinas
authored andcommitted
arm64/head: Disable MMU at EL2 before clearing HCR_EL2.E2H
Even though the boot protocol stipulates otherwise, an exception has been made for the EFI stub, and entering the core kernel with the MMU enabled is permitted. This allows a substantial amount of cache maintenance to be elided, wich is significant when fast boot times are critical (e.g., for booting micro-VMs) Once the initial ID map has been populated, the MMU is disabled as part of the logic sequence that puts all system registers into a known state. Any code that needs to execute within the window where the MMU is off is cleaned to the PoC explicitly, which includes all of HYP text when entering at EL2. However, the current sequence of initializing the EL2 system registers is not safe: HCR_EL2 is set to its nVHE initial state before SCTLR_EL2 is reprogrammed, and this means that a VHE-to-nVHE switch may occur while the MMU is enabled. This switch causes some system registers as well as page table descriptors to be interpreted in a different way, potentially resulting in spurious exceptions relating to MMU translation. So disable the MMU explicitly first when entering in EL2 with the MMU and caches enabled. Fixes: 6178617 ("efi: arm64: enter with MMU and caches enabled") Signed-off-by: Ard Biesheuvel <[email protected]> Cc: <[email protected]> # 6.3.x Acked-by: Mark Rutland <[email protected]> Acked-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Catalin Marinas <[email protected]>
1 parent 2b504e1 commit 34e526c

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

arch/arm64/kernel/head.S

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,11 @@ SYM_INNER_LABEL(init_el2, SYM_L_LOCAL)
289289
adr_l x1, __hyp_text_end
290290
adr_l x2, dcache_clean_poc
291291
blr x2
292+
293+
mov_q x0, INIT_SCTLR_EL2_MMU_OFF
294+
pre_disable_mmu_workaround
295+
msr sctlr_el2, x0
296+
isb
292297
0:
293298
mov_q x0, HCR_HOST_NVHE_FLAGS
294299

0 commit comments

Comments
 (0)