KVM: Add an arch specific hooks in 'struct kvm_kernel_irqfd'
authorFeng Wu <feng.wu@intel.com>
Fri, 18 Sep 2015 14:29:53 +0000 (22:29 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 1 Oct 2015 13:06:47 +0000 (15:06 +0200)
This patch adds an arch specific hooks 'arch_update' in
'struct kvm_kernel_irqfd'. On Intel side, it is used to
update the IRTE when VT-d posted-interrupts is used.

Signed-off-by: Feng Wu <feng.wu@intel.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_host.h
virt/kvm/eventfd.c

index b8543b02b7bcd021d3901a847d97ddf689c80285..5c3f4538807fcad383f3e19e95b0972509511a1a 100644 (file)
@@ -1172,5 +1172,7 @@ void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *,
                           struct irq_bypass_producer *);
 void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *);
 void kvm_arch_irq_bypass_start(struct irq_bypass_consumer *);
+int kvm_arch_update_irqfd_routing(struct kvm *kvm, unsigned int host_irq,
+                                 uint32_t guest_irq, bool set);
 #endif /* CONFIG_HAVE_KVM_IRQ_BYPASS */
 #endif
index 7df356d8f1fd66dfe74f7561ae8f1fb99d373520..b637965746bb57d5ba7fbfed14eeb841963d8a10 100644 (file)
@@ -266,6 +266,13 @@ void __attribute__((weak)) kvm_arch_irq_bypass_start(
                                struct irq_bypass_consumer *cons)
 {
 }
+
+int  __attribute__((weak)) kvm_arch_update_irqfd_routing(
+                               struct kvm *kvm, unsigned int host_irq,
+                               uint32_t guest_irq, bool set)
+{
+       return 0;
+}
 #endif
 
 static int
@@ -586,9 +593,19 @@ void kvm_irq_routing_update(struct kvm *kvm)
 
        spin_lock_irq(&kvm->irqfds.lock);
 
-       list_for_each_entry(irqfd, &kvm->irqfds.items, list)
+       list_for_each_entry(irqfd, &kvm->irqfds.items, list) {
                irqfd_update(kvm, irqfd);
 
+#ifdef CONFIG_HAVE_KVM_IRQ_BYPASS
+               if (irqfd->producer) {
+                       int ret = kvm_arch_update_irqfd_routing(
+                                       irqfd->kvm, irqfd->producer->irq,
+                                       irqfd->gsi, 1);
+                       WARN_ON(ret);
+               }
+#endif
+       }
+
        spin_unlock_irq(&kvm->irqfds.lock);
 }