KVM: arm64: Fix hVHE init on CPUs where HCR_EL2.E2H is not RES1
authorMarc Zyngier <maz@kernel.org>
Wed, 14 Jun 2023 15:51:29 +0000 (16:51 +0100)
committerOliver Upton <oliver.upton@linux.dev>
Thu, 15 Jun 2023 09:27:51 +0000 (09:27 +0000)
commit1700f89cb99aae19e4f8ec38b1b59f3b7ae71b91
tree7a6f04c6ee0b24f9b2d01197c9049866d3666ec4
parentad744e8cb346743dd76425942910c7b75a782ed0
KVM: arm64: Fix hVHE init on CPUs where HCR_EL2.E2H is not RES1

On CPUs where E2H is RES1, we very quickly set the scene for
running EL2 with a VHE configuration, as we do not have any other
choice.

However, CPUs that conform to the current writing of the architecture
start with E2H=0, and only later upgrade with E2H=1. This is all
good, but nothing there is actually reconfiguring EL2 to be able
to correctly run the kernel at EL1. Huhuh...

The "obvious" solution is not to just reinitialise the timer
controls like we do, but to really intitialise *everything*
unconditionally.

This requires a bit of surgery, and is a good opportunity to
remove the macro that messes with SPSR_EL2 in init_el2_state.

With that, hVHE now works correctly on my trusted A55 machine!

Reported-by: Oliver Upton <oliver.upton@linux.dev>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230614155129.2697388-1-maz@kernel.org
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/include/asm/el2_setup.h
arch/arm64/kernel/head.S
arch/arm64/kvm/hyp/nvhe/hyp-init.S