KVM: arm64: Don't corrupt tpidr_el2 on failed HVC call
authorMarc Zyngier <maz@kernel.org>
Mon, 26 Oct 2020 09:51:09 +0000 (09:51 +0000)
committerMarc Zyngier <maz@kernel.org>
Thu, 29 Oct 2020 19:49:02 +0000 (19:49 +0000)
commit28e81c6270b3d0e9faadd565f314ad9ac8256620
tree0ecf256edc134a02c827573c6260bf08d2595e7e
parent4e5dc64c43192b4fd4c96ac150a8f013065f5f5b
KVM: arm64: Don't corrupt tpidr_el2 on failed HVC call

The hyp-init code starts by stashing a register in TPIDR_EL2
in in order to free a register. This happens no matter if the
HVC call is legal or not.

Although nothing wrong seems to come out of it, it feels odd
to alter the EL2 state for something that eventually returns
an error.

Instead, use the fact that we know exactly which bits of the
__kvm_hyp_init call are non-zero to perform the check with
a series of EOR/ROR instructions, combined with a build-time
check that the value is the one we expect.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201026095116.72051-2-maz@kernel.org
arch/arm64/kvm/hyp/nvhe/hyp-init.S