KVM: PPC: select IRQ_BYPASS_MANAGER
authorSuresh Warrier <warrier@linux.vnet.ibm.com>
Fri, 19 Aug 2016 05:35:47 +0000 (15:35 +1000)
committerPaul Mackerras <paulus@ozlabs.org>
Fri, 9 Sep 2016 06:26:19 +0000 (16:26 +1000)
Select IRQ_BYPASS_MANAGER for PPC when CONFIG_KVM is set.
Add the PPC producer functions for add and del producer.

[paulus@ozlabs.org - Moved new functions from book3s.c to powerpc.c
 so booke compiles; added kvm_arch_has_irq_bypass implementation.]

Signed-off-by: Suresh Warrier <warrier@linux.vnet.ibm.com>
Signed-off-by: Paul Mackerras <paulus@ozlabs.org>
arch/powerpc/include/asm/kvm_ppc.h
arch/powerpc/kvm/Kconfig
arch/powerpc/kvm/powerpc.c

index 2544edabe7f392f1edb25fdf0c1c79a146b1c28b..94715e22d6a29c1f0034c0bffad1c7eb658c3b09 100644 (file)
@@ -287,6 +287,10 @@ struct kvmppc_ops {
        long (*arch_vm_ioctl)(struct file *filp, unsigned int ioctl,
                              unsigned long arg);
        int (*hcall_implemented)(unsigned long hcall);
+       int (*irq_bypass_add_producer)(struct irq_bypass_consumer *,
+                                      struct irq_bypass_producer *);
+       void (*irq_bypass_del_producer)(struct irq_bypass_consumer *,
+                                       struct irq_bypass_producer *);
 };
 
 extern struct kvmppc_ops *kvmppc_hv_ops;
index c0a2478a8a2c1fa10d7de9459c6c656cabfa90f2..029be26b5a17edc01b5486bde83baea9a2b3765f 100644 (file)
@@ -23,6 +23,8 @@ config KVM
        select HAVE_KVM_EVENTFD
        select SRCU
        select KVM_VFIO
+       select IRQ_BYPASS_MANAGER
+       select HAVE_KVM_IRQ_BYPASS
 
 config KVM_BOOK3S_HANDLER
        bool
index ab2b3d54493785f412418c35d421a568f1b3c792..0b7d6642265066c69cef30ee64ff415c12204edd 100644 (file)
@@ -27,6 +27,8 @@
 #include <linux/slab.h>
 #include <linux/file.h>
 #include <linux/module.h>
+#include <linux/irqbypass.h>
+#include <linux/kvm_irqfd.h>
 #include <asm/cputable.h>
 #include <asm/uaccess.h>
 #include <asm/kvm_ppc.h>
@@ -739,6 +741,42 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 #endif
 }
 
+/*
+ * irq_bypass_add_producer and irq_bypass_del_producer are only
+ * useful if the architecture supports PCI passthrough.
+ * irq_bypass_stop and irq_bypass_start are not needed and so
+ * kvm_ops are not defined for them.
+ */
+bool kvm_arch_has_irq_bypass(void)
+{
+       return ((kvmppc_hv_ops && kvmppc_hv_ops->irq_bypass_add_producer) ||
+               (kvmppc_pr_ops && kvmppc_pr_ops->irq_bypass_add_producer));
+}
+
+int kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
+                                    struct irq_bypass_producer *prod)
+{
+       struct kvm_kernel_irqfd *irqfd =
+               container_of(cons, struct kvm_kernel_irqfd, consumer);
+       struct kvm *kvm = irqfd->kvm;
+
+       if (kvm->arch.kvm_ops->irq_bypass_add_producer)
+               return kvm->arch.kvm_ops->irq_bypass_add_producer(cons, prod);
+
+       return 0;
+}
+
+void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
+                                     struct irq_bypass_producer *prod)
+{
+       struct kvm_kernel_irqfd *irqfd =
+               container_of(cons, struct kvm_kernel_irqfd, consumer);
+       struct kvm *kvm = irqfd->kvm;
+
+       if (kvm->arch.kvm_ops->irq_bypass_del_producer)
+               kvm->arch.kvm_ops->irq_bypass_del_producer(cons, prod);
+}
+
 static void kvmppc_complete_mmio_load(struct kvm_vcpu *vcpu,
                                       struct kvm_run *run)
 {