Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM/ARM64: KVM: Nuke Hyp-mode tlbs before enabling MMU

X-Gene u-boot runs in EL2 mode with MMU enabled hence we might
have stale EL2 tlb enteris when we enable EL2 MMU on each host CPU.

This can happen on any ARM/ARM64 board running bootloader in
Hyp-mode (or EL2-mode) with MMU enabled.

This patch ensures that we flush all Hyp-mode (or EL2-mode) TLBs
on each host CPU before enabling Hyp-mode (or EL2-mode) MMU.

Cc: <stable@vger.kernel.org>
Tested-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Pranavkumar Sawargaonkar <pranavkumar@linaro.org>
Signed-off-by: Anup Patel <anup.patel@linaro.org>
Signed-off-by: Christoffer Dall <christoffer.dall@linaro.org>

authored by

Pranavkumar Sawargaonkar and committed by
Christoffer Dall
f6edbbf3 30d1e0e8

+8
+4
arch/arm/kvm/init.S
··· 99 99 mrc p15, 0, r0, c10, c2, 1 100 100 mcr p15, 4, r0, c10, c2, 1 101 101 102 + @ Invalidate the stale TLBs from Bootloader 103 + mcr p15, 4, r0, c8, c7, 0 @ TLBIALLH 104 + dsb ish 105 + 102 106 @ Set the HSCTLR to: 103 107 @ - ARM/THUMB exceptions: Kernel config (Thumb-2 kernel) 104 108 @ - Endianness: Kernel config
+4
arch/arm64/kvm/hyp-init.S
··· 80 80 msr mair_el2, x4 81 81 isb 82 82 83 + /* Invalidate the stale TLBs from Bootloader */ 84 + tlbi alle2 85 + dsb sy 86 + 83 87 mrs x4, sctlr_el2 84 88 and x4, x4, #SCTLR_EL2_EE // preserve endianness of EL2 85 89 ldr x5, =SCTLR_EL2_FLAGS