aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/kvm/kvm_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/kvm/kvm_main.c')
-rw-r--r--drivers/kvm/kvm_main.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index 3c3231d8dabf..3ff8ee56279c 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -381,6 +381,16 @@ static void free_pio_guest_pages(struct kvm_vcpu *vcpu)
381 } 381 }
382} 382}
383 383
384static void kvm_unload_vcpu_mmu(struct kvm_vcpu *vcpu)
385{
386 if (!vcpu->vmcs)
387 return;
388
389 vcpu_load(vcpu);
390 kvm_mmu_unload(vcpu);
391 vcpu_put(vcpu);
392}
393
384static void kvm_free_vcpu(struct kvm_vcpu *vcpu) 394static void kvm_free_vcpu(struct kvm_vcpu *vcpu)
385{ 395{
386 if (!vcpu->vmcs) 396 if (!vcpu->vmcs)
@@ -401,6 +411,11 @@ static void kvm_free_vcpus(struct kvm *kvm)
401{ 411{
402 unsigned int i; 412 unsigned int i;
403 413
414 /*
415 * Unpin any mmu pages first.
416 */
417 for (i = 0; i < KVM_MAX_VCPUS; ++i)
418 kvm_unload_vcpu_mmu(&kvm->vcpus[i]);
404 for (i = 0; i < KVM_MAX_VCPUS; ++i) 419 for (i = 0; i < KVM_MAX_VCPUS; ++i)
405 kvm_free_vcpu(&kvm->vcpus[i]); 420 kvm_free_vcpu(&kvm->vcpus[i]);
406} 421}