summaryrefslogtreecommitdiffstats
path: root/arch/mips/kvm/trap_emul.c
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2016-11-15 00:06:05 +0000
committerJames Hogan <james.hogan@imgtec.com>2017-02-03 15:20:48 +0000
commita7ebb2e410f8be2b061557fd85241d75a1094221 (patch)
tree2cd2cb798f22db8427b732a79cb4fd74ed9b8070 /arch/mips/kvm/trap_emul.c
parent91cdee5710d5fe8f81915307b5ff38d364fbde33 (diff)
downloadlinux-a7ebb2e410f8be2b061557fd85241d75a1094221.tar.gz
linux-a7ebb2e410f8be2b061557fd85241d75a1094221.tar.bz2
linux-a7ebb2e410f8be2b061557fd85241d75a1094221.zip
KVM: MIPS/T&E: active_mm = init_mm in guest context
Set init_mm as the active_mm and update mm_cpumask(current->mm) to reflect that it isn't active when in guest context. This prevents cache management code from attempting cache flushes on host virtual addresses while in guest context, for example due to a cache management IPIs or later when writing of dynamically translated code hits copy on write. We do this using helpers in static kernel code to avoid having to export init_mm to modules. 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
Diffstat (limited to 'arch/mips/kvm/trap_emul.c')
-rw-r--r--arch/mips/kvm/trap_emul.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/arch/mips/kvm/trap_emul.c b/arch/mips/kvm/trap_emul.c
index 3e1dbcbcea85..9cfe4d2a283c 100644
--- a/arch/mips/kvm/trap_emul.c
+++ b/arch/mips/kvm/trap_emul.c
@@ -670,6 +670,7 @@ static int kvm_trap_emul_vcpu_load(struct kvm_vcpu *vcpu, int cpu)
write_c0_entryhi(cpu_asid(cpu, kern_mm));
else
write_c0_entryhi(cpu_asid(cpu, user_mm));
+ kvm_mips_suspend_mm(cpu);
ehb();
}
@@ -689,6 +690,7 @@ static int kvm_trap_emul_vcpu_put(struct kvm_vcpu *vcpu, int cpu)
get_new_mmu_context(current->mm, cpu);
}
write_c0_entryhi(cpu_asid(cpu, current->mm));
+ kvm_mips_resume_mm(cpu);
ehb();
}
@@ -723,7 +725,7 @@ static void kvm_trap_emul_vcpu_reenter(struct kvm_run *run,
static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
{
- int cpu;
+ int cpu = smp_processor_id();
int r;
/* Check if we have any exceptions/interrupts pending */
@@ -735,6 +737,13 @@ static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
/* Disable hardware page table walking while in guest */
htw_stop();
+ /*
+ * While in guest context we're in the guest's address space, not the
+ * host process address space, so we need to be careful not to confuse
+ * e.g. cache management IPIs.
+ */
+ kvm_mips_suspend_mm(cpu);
+
r = vcpu->arch.vcpu_run(run, vcpu);
/* We may have migrated while handling guest exits */
@@ -745,6 +754,7 @@ static int kvm_trap_emul_vcpu_run(struct kvm_run *run, struct kvm_vcpu *vcpu)
asid_version_mask(cpu)))
get_new_mmu_context(current->mm, cpu);
write_c0_entryhi(cpu_asid(cpu, current->mm));
+ kvm_mips_resume_mm(cpu);
htw_start();