KVM: MMU: make kvm_mmu_reset_context() flush the guest TLB
authorAvi Kivity <avi@redhat.com>
Sun, 12 Jun 2011 15:14:08 +0000 (18:14 +0300)
committerAvi Kivity <avi@redhat.com>
Tue, 12 Jul 2011 10:16:27 +0000 (13:16 +0300)
kvm_set_cr0() and kvm_set_cr4(), and possible other functions,
assume that kvm_mmu_reset_context() flushes the guest TLB.  However,
it does not.

Fix by flushing the tlb (and syncing the new root as well).

Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/kvm/mmu.c

index da0f3b0810765e04de2eda2cd167d693f9f35a55..9c629b54d36220dda63e0d911311899fdf9c95a0 100644 (file)
@@ -3054,8 +3054,18 @@ static void destroy_kvm_mmu(struct kvm_vcpu *vcpu)
 
 int kvm_mmu_reset_context(struct kvm_vcpu *vcpu)
 {
+       int r;
+
        destroy_kvm_mmu(vcpu);
-       return init_kvm_mmu(vcpu);
+       r = init_kvm_mmu(vcpu);
+
+       if (r)
+               goto err;
+
+       kvm_mmu_sync_roots(vcpu);
+       kvm_mmu_flush_tlb(vcpu);
+err:
+       return r;
 }
 EXPORT_SYMBOL_GPL(kvm_mmu_reset_context);