KVM: arm64: Restore the stage-2 context in VHE's __tlb_switch_to_host()
authorMarc Zyngier <maz@kernel.org>
Wed, 18 Oct 2023 23:32:09 +0000 (23:32 +0000)
committerOliver Upton <oliver.upton@linux.dev>
Fri, 20 Oct 2023 17:52:01 +0000 (17:52 +0000)
commit4288ff7ba195f49138eec0d9c4ff8c049714e918
tree8149edc081a71a6bd216840a914878e59513a0eb
parent38ce26bf26666779565c2770e7ef36c02e0212d7
KVM: arm64: Restore the stage-2 context in VHE's __tlb_switch_to_host()

An MMU notifier could cause us to clobber the stage-2 context loaded on
a CPU when we switch to another VM's context to invalidate. This isn't
an issue right now as the stage-2 context gets reloaded on every guest
entry, but is disastrous when moving __load_stage2() into the
vcpu_load() path.

Restore the previous stage-2 context on the way out of a TLB
invalidation if we installed something else. Deliberately do this after
TGE=1 is synchronized to keep things safe in light of the speculative AT
errata.

Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20231018233212.2888027-3-oliver.upton@linux.dev
Signed-off-by: Oliver Upton <oliver.upton@linux.dev>
arch/arm64/kvm/hyp/vhe/tlb.c