alistair23-linux/arch/mips/kvm
James Hogan 9078210ef4 KVM: MIPS: Fix lazy user ASID regenerate for SMP
kvm_mips_check_asids() runs before entering the guest and performs lazy
regeneration of host ASID for guest usermode, using last_user_gasid to
track the last guest ASID in the VCPU that was used by guest usermode on
any host CPU.

last_user_gasid is reset after performing the lazy ASID regeneration on
the current CPU, and by kvm_arch_vcpu_load() if the host ASID for guest
usermode is regenerated due to staleness (to cancel outstanding lazy
ASID regenerations). Unfortunately neither case handles SMP hosts
correctly:

 - When the lazy ASID regeneration is performed it should apply to all
   CPUs (as last_user_gasid does), so reset the ASID on other CPUs to
   zero to trigger regeneration when the VCPU is next loaded on those
   CPUs.

 - When the ASID is found to be stale on the current CPU, we should not
   cancel lazy ASID regenerations globally, so drop the reset of
   last_user_gasid altogether here.

Both cases would require a guest ASID change and two host CPU migrations
(and in the latter case one of the CPUs to start a new ASID cycle)
before guest usermode could potentially access stale user pages from a
previously running ASID in the same VCPU.

Fixes: 25b08c7fb0 ("KVM: MIPS: Invalidate TLB by regenerating ASIDs")
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: "Radim Krčmář <rkrcmar@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org
Cc: kvm@vger.kernel.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-10-26 13:43:41 +02:00
..
00README.txt
callback.c MIPS: KVM: Convert EXPORT_SYMBOL to _GPL 2016-01-24 03:13:24 +01:00
commpage.c MIPS: kvm: Audit and remove any unnecessary uses of module.h 2016-10-05 01:31:20 +02:00
commpage.h
dyntrans.c MIPS: kvm: Audit and remove any unnecessary uses of module.h 2016-10-05 01:31:20 +02:00
emulate.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2016-10-15 09:26:12 -07:00
entry.c MIPS: KVM: Use 64-bit CP0_EBase when appropriate 2016-08-01 18:42:24 +02:00
fpu.S MIPS: KVM: Fix fpu.S misassembly with r6 2016-07-05 16:09:11 +02:00
interrupt.c MIPS: kvm: Audit and remove any unnecessary uses of module.h 2016-10-05 01:31:20 +02:00
interrupt.h MIPS; KVM: Convert exception entry to uasm 2016-07-05 16:08:46 +02:00
Kconfig MIPS; KVM: Convert exception entry to uasm 2016-07-05 16:08:46 +02:00
Makefile MIPS; KVM: Convert exception entry to uasm 2016-07-05 16:08:46 +02:00
mips.c KVM: MIPS: Fix lazy user ASID regenerate for SMP 2016-10-26 13:43:41 +02:00
mmu.c KVM: MIPS: Fix lazy user ASID regenerate for SMP 2016-10-26 13:43:41 +02:00
msa.S
stats.c MIPS: KVM: Clean up kvm_exit trace event 2016-06-14 11:16:23 +02:00
tlb.c MIPS: KVM: Reset CP0_PageMask during host TLB flush 2016-08-01 18:42:27 +02:00
trace.h MIPS: KVM: Combine entry trace events into class 2016-06-23 19:17:30 +02:00
trap_emul.c Merge branch 'upstream' of git://git.linux-mips.org/pub/scm/ralf/upstream-linus 2016-10-15 09:26:12 -07:00