KVM: MIPS: Disable HTW while in guest
authorJames Hogan <james.hogan@imgtec.com>
Wed, 4 Feb 2015 10:52:03 +0000 (10:52 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 4 Feb 2015 15:23:33 +0000 (16:23 +0100)
commitc4c6f2cad9e1d4cc076bc183c3689cc9e7019c75
treee7afc343303e4e6a048fd67156ff6fa7a68885cd
parent705699a139948a671cd66b915e8095c95fdf44d9
KVM: MIPS: Disable HTW while in guest

Ensure any hardware page table walker (HTW) is disabled while in KVM
guest mode, as KVM doesn't yet set up hardware page table walking for
guest mappings so the wrong mappings would get loaded, resulting in the
guest hanging or crashing once it reaches userland.

The HTW is disabled and re-enabled around the call to
__kvm_mips_vcpu_run() which does the initial switch into guest mode and
the final switch out of guest context. Additionally it is enabled for
the duration of guest exits (i.e. kvm_mips_handle_exit()), getting
disabled again before returning back to guest or host.

In all cases the HTW is only disabled in normal kernel mode while
interrupts are disabled, so that the HTW doesn't get left disabled if
the process is preempted.

Signed-off-by: James Hogan <james.hogan@imgtec.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Ralf Baechle <ralf@linux-mips.org>
Cc: Markos Chandras <markos.chandras@imgtec.com>
Cc: Gleb Natapov <gleb@kernel.org>
Cc: kvm@vger.kernel.org
Cc: linux-mips@linux-mips.org
Cc: <stable@vger.kernel.org> # v3.17+
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/mips/kvm/mips.c