Skip to contentSkip to conversation

KVM: IRQ ACK notifier should be used with in-kernel irqchip

PATCH In review Sheng Yang 2 participants 4 messages Oct 9, 2008 – Oct 19, 2008 KVM

lore
Share & tools
lore

Sheng Yang

author
#0 lore raw

PATCH 1/1 KVM: IRQ ACK notifier should be used with in-kernel irqchip

Also remove unnecessary parameter of unregister irq ack notifier.

---
 include/linux/kvm_host.h |    3 +--
 virt/kvm/irq_comm.c      |    8 ++++++--
 virt/kvm/kvm_main.c      |    2 +-
 3 files changed, 8 insertions(+), 5 deletions(-)
include/linux/kvm_host.h +1 -2
index 3833c48..41955ed 100644
@@ -313,8 +313,7 @@ void kvm_set_irq(struct kvm *kvm, int irq, int level);
 void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi);
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian);
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian);
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian);
 
 #ifdef CONFIG_DMAR
 int kvm_iommu_map_pages(struct kvm *kvm, gfn_t base_gfn,
virt/kvm/irq_comm.c +6 -2
index d0169f5..54b251d 100644
@@ -50,11 +50,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }
 
-void kvm_unregister_irq_ack_notifier(struct kvm *kvm,
-				     struct kvm_irq_ack_notifier *kian)
+void kvm_unregister_irq_ack_notifier(struct kvm_irq_ack_notifier *kian)
 {
+	if (!kian)
+		return;
 	hlist_del(&kian->link);
 }
virt/kvm/kvm_main.c +1 -1
index cf0ab8e..d2ae1c9 100644
@@ -145,7 +145,7 @@ static void kvm_free_assigned_device(struct kvm *kvm,
 	if (irqchip_in_kernel(kvm) && assigned_dev->irq_requested)
 		free_irq(assigned_dev->host_irq, (void *)assigned_dev);
 
-	kvm_unregister_irq_ack_notifier(kvm, &assigned_dev->ack_notifier);
+	kvm_unregister_irq_ack_notifier(&assigned_dev->ack_notifier);
 
 	if (cancel_work_sync(&assigned_dev->interrupt_work))
 		/* We had pending work. That means we will have to take
Signature · 1 line
1.5.4.5
#1 lore raw
Quoted 7 lines · Sheng Yang

Also remove unnecessary parameter of unregister irq ack notifier.

virt/kvm/irq_comm.c +0 -0
index d0169f5..54b251d 100644

virt/kvm/irq_comm.c void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi) · line 58

Quoted 9 lines
virt/kvm/irq_comm.c +3 -0
@@ -50,11 +50,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned gsi)
 void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }
 

We don't want a BUG() here is the user specifies -no-kvm-irqchip; is there a check on the irq assignment ioctls before calling this?

Signature · 1 line
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
author
#2 lore raw
Quoted 19 lines · On Thursday 09 October 2008 16:34:47 Avi Kivity wrote:
Quoted 7 lines · Sheng Yang

Also remove unnecessary parameter of unregister irq ack notifier.

virt/kvm/irq_comm.c +0 -0
index d0169f5..54b251d 100644

virt/kvm/irq_comm.c void kvm_notify_acked_irq(struct kvm *kvm, unsigned · line 57

Quoted 8 lines
virt/kvm/irq_comm.c +3 -0
@@ -50,11 +50,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned
 gsi) void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }

We don't want a BUG() here is the user specifies -no-kvm-irqchip; is there a check on the irq assignment ioctls before calling this?

Yes. kvm_register_irq_ack_notifier should be called within irqchip_in_kernel() (on the other side, only if we have irqchip_in_kernel(), ack_notifier is useful, so we shouldn't call it without it), And I can't see if this would be useful with userspace irqchip, so add a ASSERT here.

--
regards
Yang, Sheng

#3 lore raw
Quoted 24 lines · Sheng Yang
Quoted 4 lines · On Thursday 09 October 2008 16:34:47 Avi Kivity wrote:
Quoted 2 lines · Sheng Yang

Also remove unnecessary parameter of unregister irq ack notifier.

Quoted 17 lines
Quoted 5 lines
virt/kvm/irq_comm.c +0 -0
index d0169f5..54b251d 100644

virt/kvm/irq_comm.c void kvm_notify_acked_irq(struct kvm *kvm, unsigned · line 58

Quoted 9 lines
virt/kvm/irq_comm.c +3 -0
@@ -50,11 +50,15 @@ void kvm_notify_acked_irq(struct kvm *kvm, unsigned
 gsi) void kvm_register_irq_ack_notifier(struct kvm *kvm,
 				   struct kvm_irq_ack_notifier *kian)
 {
+	/* Must be called with in-kernel IRQ chip, otherwise it's nonsense */
+	ASSERT(irqchip_in_kernel(kvm));
+	ASSERT(kian);
 	hlist_add_head(&kian->link, &kvm->arch.irq_ack_notifier_list);
 }
 

We don't want a BUG() here is the user specifies -no-kvm-irqchip; is there a check on the irq assignment ioctls before calling this?

Quoted 2 lines

Yes. kvm_register_irq_ack_notifier should be called within irqchip_in_kernel() (on the other side, only if we have irqchip_in_kernel(), ack_notifier is useful, so we shouldn't call it without it), And I can't see if this would be useful with userspace irqchip, so add a ASSERT here.

Yes.

The code changed quite a lot here due to ia64 gaining VT-d support. Can you regenerate the patch?

Signature · 1 line
error compiling committee.c: too many arguments to function