Commit 64749204 authored by Marcelo Tosatti's avatar Marcelo Tosatti

KVM: fix cleanup_srcu_struct on vm destruction

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: default avatarMarcelo Tosatti <mtosatti@redhat.com>
Reported-by: default avatarJan Kiszka <jan.kiszka@siemens.com>
parent ccd46936
...@@ -1404,6 +1404,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) ...@@ -1404,6 +1404,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
kfree(kvm->arch.vioapic); kfree(kvm->arch.vioapic);
kvm_release_vm_pages(kvm); kvm_release_vm_pages(kvm);
kvm_free_physmem(kvm); kvm_free_physmem(kvm);
cleanup_srcu_struct(&kvm->srcu);
free_kvm(kvm); free_kvm(kvm);
} }
......
...@@ -137,6 +137,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) ...@@ -137,6 +137,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
{ {
kvmppc_free_vcpus(kvm); kvmppc_free_vcpus(kvm);
kvm_free_physmem(kvm); kvm_free_physmem(kvm);
cleanup_srcu_struct(&kvm->srcu);
kfree(kvm); kfree(kvm);
} }
......
...@@ -242,6 +242,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) ...@@ -242,6 +242,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
kvm_free_physmem(kvm); kvm_free_physmem(kvm);
free_page((unsigned long)(kvm->arch.sca)); free_page((unsigned long)(kvm->arch.sca));
debug_unregister(kvm->arch.dbf); debug_unregister(kvm->arch.dbf);
cleanup_srcu_struct(&kvm->srcu);
kfree(kvm); kfree(kvm);
} }
......
...@@ -5547,6 +5547,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm) ...@@ -5547,6 +5547,7 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
put_page(kvm->arch.apic_access_page); put_page(kvm->arch.apic_access_page);
if (kvm->arch.ept_identity_pagetable) if (kvm->arch.ept_identity_pagetable)
put_page(kvm->arch.ept_identity_pagetable); put_page(kvm->arch.ept_identity_pagetable);
cleanup_srcu_struct(&kvm->srcu);
kfree(kvm->arch.aliases); kfree(kvm->arch.aliases);
kfree(kvm); kfree(kvm);
} }
......
...@@ -506,7 +506,6 @@ static void kvm_destroy_vm(struct kvm *kvm) ...@@ -506,7 +506,6 @@ static void kvm_destroy_vm(struct kvm *kvm)
#else #else
kvm_arch_flush_shadow(kvm); kvm_arch_flush_shadow(kvm);
#endif #endif
cleanup_srcu_struct(&kvm->srcu);
kvm_arch_destroy_vm(kvm); kvm_arch_destroy_vm(kvm);
hardware_disable_all(); hardware_disable_all();
mmdrop(mm); mmdrop(mm);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment