All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] KVM: x86: cancel delayed EOI work on vm shutdown
@ 2015-04-28 14:00 Radim Krčmář
  2015-04-28 14:13 ` Paolo Bonzini
  0 siblings, 1 reply; 2+ messages in thread
From: Radim Krčmář @ 2015-04-28 14:00 UTC (permalink / raw)
  To: linux-kernel; +Cc: kvm, Paolo Bonzini

kvm_ioapic_eoi_inject_work() can be called after ioapic has been freed,
fix it by cancelling its delayed work via a slightly better freeing.
(Could have been a one-liner.)

Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
---
 I noticed it while reviewing the "KVM: x86: drop unneeded null test",
 so it applies after.

 arch/x86/kvm/ioapic.c | 6 ++++++
 arch/x86/kvm/ioapic.h | 1 +
 arch/x86/kvm/x86.c    | 2 +-
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kvm/ioapic.c b/arch/x86/kvm/ioapic.c
index 09828e2cacfb..88de47ba4058 100644
--- a/arch/x86/kvm/ioapic.c
+++ b/arch/x86/kvm/ioapic.c
@@ -642,6 +642,12 @@ void kvm_ioapic_destroy(struct kvm *kvm)
 	kfree(ioapic);
 }
 
+void kvm_free_ioapic(struct kvm *kvm)
+{
+	if (kvm->arch.vioapic)
+		kvm_ioapic_destroy(kvm);
+}
+
 int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state)
 {
 	struct kvm_ioapic *ioapic = ioapic_irqchip(kvm);
diff --git a/arch/x86/kvm/ioapic.h b/arch/x86/kvm/ioapic.h
index ca0b0b4e6256..7c5579c24fc8 100644
--- a/arch/x86/kvm/ioapic.h
+++ b/arch/x86/kvm/ioapic.h
@@ -122,5 +122,6 @@ int kvm_get_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
 int kvm_set_ioapic(struct kvm *kvm, struct kvm_ioapic_state *state);
 void kvm_ioapic_scan_entry(struct kvm_vcpu *vcpu, u64 *eoi_exit_bitmap,
 			u32 *tmr);
+void kvm_free_ioapic(struct kvm *kvm);
 
 #endif
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index c73efcd03e29..bb7f1b5881d5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -7468,6 +7468,7 @@ void kvm_arch_sync_events(struct kvm *kvm)
 	cancel_delayed_work_sync(&kvm->arch.kvmclock_update_work);
 	kvm_free_all_assigned_devices(kvm);
 	kvm_free_pit(kvm);
+	kvm_free_ioapic(kvm);
 }
 
 void kvm_arch_destroy_vm(struct kvm *kvm)
@@ -7491,7 +7492,6 @@ void kvm_arch_destroy_vm(struct kvm *kvm)
 	}
 	kvm_iommu_unmap_guest(kvm);
 	kfree(kvm->arch.vpic);
-	kfree(kvm->arch.vioapic);
 	kvm_free_vcpus(kvm);
 	kfree(rcu_dereference_check(kvm->arch.apic_map, 1));
 }
-- 
2.3.6

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-04-28 14:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-04-28 14:00 [PATCH] KVM: x86: cancel delayed EOI work on vm shutdown Radim Krčmář
2015-04-28 14:13 ` Paolo Bonzini

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.