arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 18 Oct 2016 17:37:49 +0000 (18:37 +0100)
committerMarc Zyngier <marc.zyngier@arm.com>
Fri, 4 Nov 2016 17:56:28 +0000 (17:56 +0000)
commit94d0e5980d6791b9f98a9b6c586c1f7cb76b2178
treef513c7147798d74dee9b3f1a79dd0ded62d9aa37
parent07d9a380680d1c0eb51ef87ff2eab5c994949e69
arm/arm64: KVM: Perform local TLB invalidation when multiplexing vcpus on a single CPU

Architecturally, TLBs are private to the (physical) CPU they're
associated with. But when multiple vcpus from the same VM are
being multiplexed on the same CPU, the TLBs are not private
to the vcpus (and are actually shared across the VMID).

Let's consider the following scenario:

- vcpu-0 maps PA to VA
- vcpu-1 maps PA' to VA

If run on the same physical CPU, vcpu-1 can hit TLB entries generated
by vcpu-0 accesses, and access the wrong physical page.

The solution to this is to keep a per-VM map of which vcpu ran last
on each given physical CPU, and invalidate local TLBs when switching
to a different vcpu from the same VM.

Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
arch/arm/include/asm/kvm_asm.h
arch/arm/include/asm/kvm_host.h
arch/arm/include/asm/kvm_hyp.h
arch/arm/kvm/arm.c
arch/arm/kvm/hyp/tlb.c
arch/arm64/include/asm/kvm_asm.h
arch/arm64/include/asm/kvm_host.h
arch/arm64/include/asm/kvm_mmu.h
arch/arm64/kvm/hyp/tlb.c