KVM: fix cleanup_srcu_struct on vm destruction
authorMarcelo Tosatti <mtosatti@redhat.com>
Tue, 19 Jan 2010 14:45:23 +0000 (12:45 -0200)
committerMarcelo Tosatti <mtosatti@redhat.com>
Mon, 1 Mar 2010 15:36:01 +0000 (12:36 -0300)
cleanup_srcu_struct on VM destruction remains broken:

BUG: unable to handle kernel paging request at ffffffffffffffff
IP: [<ffffffff802533d2>] srcu_read_lock+0x16/0x21
RIP: 0010:[<ffffffff802533d2>]  [<ffffffff802533d2>] srcu_read_lock+0x16/0x21
Call Trace:
 [<ffffffffa05354c4>] kvm_arch_vcpu_uninit+0x1b/0x48 [kvm]
 [<ffffffffa05339c6>] kvm_vcpu_uninit+0x9/0x15 [kvm]
 [<ffffffffa0569f7d>] vmx_free_vcpu+0x7f/0x8f [kvm_intel]
 [<ffffffffa05357b5>] kvm_arch_destroy_vm+0x78/0x111 [kvm]
 [<ffffffffa053315b>] kvm_put_kvm+0xd4/0xfe [kvm]

Move it to kvm_arch_destroy_vm.

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reported-by: Jan Kiszka <jan.kiszka@siemens.com>
arch/ia64/kvm/kvm-ia64.c
arch/powerpc/kvm/powerpc.c
arch/s390/kvm/kvm-s390.c
arch/x86/kvm/x86.c
virt/kvm/kvm_main.c

index e6ac549f8d55794b91c1f976a8351a8f825626f6..06188988ed27f5de8bd43c8f532580a9bd413bf9 100644 (file)
@@ -1404,6 +1404,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
        kfree(kvm->arch.vioapic);
        kvm_release_vm_pages(kvm);
        kvm_free_physmem(kvm);
+       cleanup_srcu_struct(&kvm->srcu);
        free_kvm(kvm);
 }
 
index 2c291161df89018c0d14a96d29749bef77086177..51aedd7f16bcb14d5d2f073da2fc55a53ec18575 100644 (file)
@@ -137,6 +137,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 {
        kvmppc_free_vcpus(kvm);
        kvm_free_physmem(kvm);
+       cleanup_srcu_struct(&kvm->srcu);
        kfree(kvm);
 }
 
index c8002193d9d41649c2279e8b68c9dd1afdf09617..49292869a5cdbeb18cb2a3a17e46a25f68d21b55 100644 (file)
@@ -242,6 +242,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
        kvm_free_physmem(kvm);
        free_page((unsigned long)(kvm->arch.sca));
        debug_unregister(kvm->arch.dbf);
+       cleanup_srcu_struct(&kvm->srcu);
        kfree(kvm);
 }
 
index 9b0758b4d5504e38605f0c12e043047bb1c35abe..322c2c5f9bc4a6b2b28b6e322c2e9b123b6574d9 100644 (file)
@@ -5547,6 +5547,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
                put_page(kvm->arch.apic_access_page);
        if (kvm->arch.ept_identity_pagetable)
                put_page(kvm->arch.ept_identity_pagetable);
+       cleanup_srcu_struct(&kvm->srcu);
        kfree(kvm->arch.aliases);
        kfree(kvm);
 }
index 2b7cd6c0d9cab3cb97aea6dd694205d94b98606d..7c5c873812ff8dc0a834a0694dd6dea079d0bae1 100644 (file)
@@ -506,7 +506,6 @@ static void kvm_destroy_vm(struct kvm *kvm)
 #else
        kvm_arch_flush_shadow(kvm);
 #endif
-       cleanup_srcu_struct(&kvm->srcu);
        kvm_arch_destroy_vm(kvm);
        hardware_disable_all();
        mmdrop(mm);