kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts
@ 2015-07-10  3:00 Feng Wu
  2015-07-10  3:00 ` [RFC v1 1/5] vfio: Register/unregister irq_bypass_producer Feng Wu
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

This series is based on Alex and Eric's irq bypass manager framework. To
make things clear, I only send out the patches related to irq bypass
manager, the purpose here is to show how certain callbacks are used
in VT-d PI and help to improve the irqbypass manager itself.

Feng Wu (5):
  vfio: Register/unregister irq_bypass_producer
  KVM: x86: Update IRTE for posted-interrupts
  KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd'
  KVM: x86: Add arch specific routines for irqbypass manager
  Call irqbypass update routine when updating irqfd

 arch/x86/kvm/Kconfig                |   1 +
 arch/x86/kvm/x86.c                  | 128 ++++++++++++++++++++++++++++++++++++
 drivers/vfio/pci/vfio_pci_intrs.c   |   8 ++-
 drivers/vfio/pci/vfio_pci_private.h |   2 +
 include/linux/kvm_irqfd.h           |   1 +
 virt/kvm/eventfd.c                  |   4 +-
 6 files changed, 141 insertions(+), 3 deletions(-)

-- 
2.1.0


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

* [RFC v1 1/5] vfio: Register/unregister irq_bypass_producer
  2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
@ 2015-07-10  3:00 ` Feng Wu
  2015-07-10  3:00 ` [RFC v1 2/5] KVM: x86: Update IRTE for posted-interrupts Feng Wu
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

This patch adds the registration/unregistration of an
irq_bypass_producer for MSI/MSIx on vfio pci devices.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 drivers/vfio/pci/vfio_pci_intrs.c   | 8 ++++++--
 drivers/vfio/pci/vfio_pci_private.h | 2 ++
 2 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c
index 4e053be..6e86292 100644
--- a/drivers/vfio/pci/vfio_pci_intrs.c
+++ b/drivers/vfio/pci/vfio_pci_intrs.c
@@ -322,7 +322,7 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
 
 	if (vdev->ctx[vector].trigger) {
 		free_irq(irq, vdev->ctx[vector].trigger);
-		/* irq_bypass_unregister_producer(); */
+		irq_bypass_unregister_producer(&vdev->ctx[vector].producer);
 		kfree(vdev->ctx[vector].name);
 		eventfd_ctx_put(vdev->ctx[vector].trigger);
 		vdev->ctx[vector].trigger = NULL;
@@ -364,7 +364,11 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev,
 		return ret;
 	}
 
-	/* irq_bypass_register_producer(); */
+	INIT_LIST_HEAD(&vdev->ctx[vector].producer.node);
+	vdev->ctx[vector].producer.token = trigger;
+	vdev->ctx[vector].producer.irq = irq;
+	ret = irq_bypass_register_producer(&vdev->ctx[vector].producer);
+	WARN_ON(ret);
 
 	vdev->ctx[vector].trigger = trigger;
 
diff --git a/drivers/vfio/pci/vfio_pci_private.h b/drivers/vfio/pci/vfio_pci_private.h
index ae0e1b4..0e7394f 100644
--- a/drivers/vfio/pci/vfio_pci_private.h
+++ b/drivers/vfio/pci/vfio_pci_private.h
@@ -13,6 +13,7 @@
 
 #include <linux/mutex.h>
 #include <linux/pci.h>
+#include <linux/irqbypass.h>
 
 #ifndef VFIO_PCI_PRIVATE_H
 #define VFIO_PCI_PRIVATE_H
@@ -29,6 +30,7 @@ struct vfio_pci_irq_ctx {
 	struct virqfd		*mask;
 	char			*name;
 	bool			masked;
+	struct irq_bypass_producer	producer;
 };
 
 struct vfio_pci_device {
-- 
2.1.0


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

* [RFC v1 2/5] KVM: x86: Update IRTE for posted-interrupts
  2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
  2015-07-10  3:00 ` [RFC v1 1/5] vfio: Register/unregister irq_bypass_producer Feng Wu
@ 2015-07-10  3:00 ` Feng Wu
  2015-07-10  3:00 ` [RFC v1 3/5] KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd' Feng Wu
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

This patch adds the routine to update IRTE for posted-interrupts
when guest changes the interrupt configuration.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 arch/x86/kvm/x86.c | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 73 insertions(+)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 26eaeb5..d81ac02 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -63,6 +63,7 @@
 #include <asm/fpu/internal.h> /* Ugh! */
 #include <asm/pvclock.h>
 #include <asm/div64.h>
+#include <asm/irq_remapping.h>
 
 #define MAX_IO_MSRS 256
 #define KVM_MAX_MCE_BANKS 32
@@ -7950,6 +7951,78 @@ bool kvm_arch_has_noncoherent_dma(struct kvm *kvm)
 }
 EXPORT_SYMBOL_GPL(kvm_arch_has_noncoherent_dma);
 
+/*
+ * kvm_arch_update_pi_irte - set IRTE for Posted-Interrupts
+ *
+ * @kvm: kvm
+ * @host_irq: host irq of the interrupt
+ * @guest_irq: gsi of the interrupt
+ * @set: set or unset PI
+ * returns 0 on success, < 0 on failure
+ */
+int kvm_arch_update_pi_irte(struct kvm *kvm, unsigned int host_irq,
+			    uint32_t guest_irq, bool set)
+{
+	struct kvm_kernel_irq_routing_entry *e;
+	struct kvm_irq_routing_table *irq_rt;
+	struct kvm_lapic_irq irq;
+	struct kvm_vcpu *vcpu;
+	struct vcpu_data vcpu_info;
+	int idx, ret = -EINVAL;
+
+	if (!irq_remapping_cap(IRQ_POSTING_CAP))
+		return 0;
+
+	idx = srcu_read_lock(&kvm->irq_srcu);
+	irq_rt = srcu_dereference(kvm->irq_routing, &kvm->irq_srcu);
+	BUG_ON(guest_irq >= irq_rt->nr_rt_entries);
+
+	hlist_for_each_entry(e, &irq_rt->map[guest_irq], link) {
+		if (e->type != KVM_IRQ_ROUTING_MSI)
+			continue;
+		/*
+		 * VT-d PI cannot support posting multicast/broadcast
+		 * interrupts to a VCPU, we still use interrupt remapping
+		 * for these kind of interrupts.
+		 *
+		 * For lowest-priority interrupts, we only support
+		 * those with single CPU as the destination, e.g. user
+		 * configures the interrupts via /proc/irq or uses
+		 * irqbalance to make the interrupts single-CPU.
+		 *
+		 * We will support full lowest-priority interrupt later.
+		 *
+		 */
+
+		kvm_set_msi_irq(e, &irq);
+		if (!kvm_intr_is_single_vcpu(kvm, &irq, &vcpu))
+			continue;
+
+		vcpu_info.pi_desc_addr = kvm_x86_ops->get_pi_desc_addr(vcpu);
+		vcpu_info.vector = irq.vector;
+
+		if (set)
+			ret = irq_set_vcpu_affinity(host_irq, &vcpu_info);
+		else {
+			/* suppress notification event before unposting */
+			kvm_x86_ops->pi_set_sn(vcpu);
+			ret = irq_set_vcpu_affinity(host_irq, NULL);
+			kvm_x86_ops->pi_clear_sn(vcpu);
+		}
+
+		if (ret < 0) {
+			printk(KERN_INFO "%s: failed to update PI IRTE\n",
+					__func__);
+			goto out;
+		}
+	}
+
+	ret = 0;
+out:
+	srcu_read_unlock(&kvm->irq_srcu, idx);
+	return ret;
+}
+
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_page_fault);
-- 
2.1.0


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

* [RFC v1 3/5] KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd'
  2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
  2015-07-10  3:00 ` [RFC v1 1/5] vfio: Register/unregister irq_bypass_producer Feng Wu
  2015-07-10  3:00 ` [RFC v1 2/5] KVM: x86: Update IRTE for posted-interrupts Feng Wu
@ 2015-07-10  3:00 ` Feng Wu
  2015-07-10  3:00 ` [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager Feng Wu
  2015-07-10  3:00 ` [RFC v1 5/5] Call irqbypass update routine when updating irqfd Feng Wu
  4 siblings, 0 replies; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

Add reference to struct irq_bypass_produce so we can get the producer
information from the consumer side.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 include/linux/kvm_irqfd.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/linux/kvm_irqfd.h b/include/linux/kvm_irqfd.h
index 3c0bd07..0c1de05 100644
--- a/include/linux/kvm_irqfd.h
+++ b/include/linux/kvm_irqfd.h
@@ -65,6 +65,7 @@ struct kvm_kernel_irqfd {
 	poll_table pt;
 	struct work_struct shutdown;
 	struct irq_bypass_consumer consumer;
+	struct irq_bypass_producer *producer;
 };
 
 #endif /* __LINUX_KVM_IRQFD_H */
-- 
2.1.0


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

* [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager
  2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
                   ` (2 preceding siblings ...)
  2015-07-10  3:00 ` [RFC v1 3/5] KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd' Feng Wu
@ 2015-07-10  3:00 ` Feng Wu
  2015-07-10  3:27   ` Alex Williamson
  2015-07-10  3:00 ` [RFC v1 5/5] Call irqbypass update routine when updating irqfd Feng Wu
  4 siblings, 1 reply; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

Add the following x86 specific routines for irqbypass manger:

- kvm_arch_irq_bypass_add_producer
- kvm_arch_irq_bypass_del_producer
- kvm_arch_irq_bypass_stop
- kvm_arch_irq_bypass_resume
- kvm_arch_irq_bypass_update

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 arch/x86/kvm/Kconfig |  1 +
 arch/x86/kvm/x86.c   | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 56 insertions(+)

diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
index 22f6fcb..ae68f2a 100644
--- a/arch/x86/kvm/Kconfig
+++ b/arch/x86/kvm/Kconfig
@@ -62,6 +62,7 @@ config KVM_INTEL
 	# for perf_guest_get_msrs():
 	depends on CPU_SUP_INTEL
 	select IRQ_BYPASS_MANAGER
+	select HAVE_KVM_IRQ_BYPASS
 	---help---
 	  Provides support for KVM on Intel processors equipped with the VT
 	  extensions.
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index d81ac02..a59f7e3 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -49,6 +49,8 @@
 #include <linux/pci.h>
 #include <linux/timekeeper_internal.h>
 #include <linux/pvclock_gtod.h>
+#include <linux/kvm_irqfd.h>
+#include <linux/irqbypass.h>
 #include <trace/events/kvm.h>
 
 #define CREATE_TRACE_POINTS
@@ -8023,6 +8025,59 @@ out:
 	return ret;
 }
 
+void kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
+				      struct irq_bypass_producer *prod)
+{
+	int ret;
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(cons, struct kvm_kernel_irqfd, consumer);
+
+	irqfd->producer = prod;
+
+	ret = kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 1);
+	WARN_ON(ret);
+}
+
+void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
+				      struct irq_bypass_producer *prod)
+{
+	int ret;
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(cons, struct kvm_kernel_irqfd, consumer);
+
+	irqfd->producer = NULL;
+
+	/*
+	 * When producer of consumer is unregistered, we change back to
+	 * remapped mode, so we can re-use the current implementation
+	 * when the irq is masked/disabed or the consumer side (KVM
+	 * int this case doesn't want to receive the interrupts.
+	 */
+	ret = kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 0);
+	WARN_ON(ret);
+}
+
+void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *cons)
+{
+}
+
+void kvm_arch_irq_bypass_resume(struct irq_bypass_consumer *cons)
+{
+}
+
+void kvm_arch_irq_bypass_update(struct irq_bypass_consumer *cons)
+{
+	int ret;
+	struct kvm_kernel_irqfd *irqfd =
+		container_of(cons, struct kvm_kernel_irqfd, consumer);
+
+	BUG_ON(!irqfd->producer);
+
+	ret = kvm_arch_update_pi_irte(irqfd->kvm, irqfd->producer->irq,
+				      irqfd->gsi, 1);
+	WARN_ON(ret);
+}
+
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq);
 EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_page_fault);
-- 
2.1.0


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

* [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
                   ` (3 preceding siblings ...)
  2015-07-10  3:00 ` [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager Feng Wu
@ 2015-07-10  3:00 ` Feng Wu
  2015-07-10  3:26   ` Alex Williamson
  4 siblings, 1 reply; 12+ messages in thread
From: Feng Wu @ 2015-07-10  3:00 UTC (permalink / raw)
  To: kvm; +Cc: alex.williamson, pbonzini, joro, avi.kivity, eric.auger, feng.wu

Call update routine when updating irqfd, this can update the
IRTE for Intel posted-interrupts.

Signed-off-by: Feng Wu <feng.wu@intel.com>
---
 virt/kvm/eventfd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
index a32cf6c..1226835 100644
--- a/virt/kvm/eventfd.c
+++ b/virt/kvm/eventfd.c
@@ -570,8 +570,10 @@ 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);
+		irqfd->consumer.update(&irqfd->consumer);
+	}
 
 	spin_unlock_irq(&kvm->irqfds.lock);
 }
-- 
2.1.0


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

* Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10  3:00 ` [RFC v1 5/5] Call irqbypass update routine when updating irqfd Feng Wu
@ 2015-07-10  3:26   ` Alex Williamson
  2015-07-10  4:12     ` Wu, Feng
  0 siblings, 1 reply; 12+ messages in thread
From: Alex Williamson @ 2015-07-10  3:26 UTC (permalink / raw)
  To: Feng Wu; +Cc: kvm, pbonzini, joro, avi.kivity, eric.auger

On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:
> Call update routine when updating irqfd, this can update the
> IRTE for Intel posted-interrupts.
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  virt/kvm/eventfd.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> index a32cf6c..1226835 100644
> --- a/virt/kvm/eventfd.c
> +++ b/virt/kvm/eventfd.c
> @@ -570,8 +570,10 @@ 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);
> +		irqfd->consumer.update(&irqfd->consumer);
> +	}
>  
>  	spin_unlock_irq(&kvm->irqfds.lock);
>  }

I don't understand why the irq bypass manager needs to know about this
update callback.  We could just as easily make it be a function pointer
on the irqfd structure or maybe just open code it.  It's defined by the
consumer and called by the consumer, the irq bypass manager shouldn't
know about it.  Thanks,

Alex


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

* Re: [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager
  2015-07-10  3:00 ` [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager Feng Wu
@ 2015-07-10  3:27   ` Alex Williamson
  0 siblings, 0 replies; 12+ messages in thread
From: Alex Williamson @ 2015-07-10  3:27 UTC (permalink / raw)
  To: Feng Wu; +Cc: kvm, pbonzini, joro, avi.kivity, eric.auger

On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:
> Add the following x86 specific routines for irqbypass manger:
> 
> - kvm_arch_irq_bypass_add_producer
> - kvm_arch_irq_bypass_del_producer
> - kvm_arch_irq_bypass_stop
> - kvm_arch_irq_bypass_resume
> - kvm_arch_irq_bypass_update
> 
> Signed-off-by: Feng Wu <feng.wu@intel.com>
> ---
>  arch/x86/kvm/Kconfig |  1 +
>  arch/x86/kvm/x86.c   | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 56 insertions(+)
> 
> diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig
> index 22f6fcb..ae68f2a 100644
> --- a/arch/x86/kvm/Kconfig
> +++ b/arch/x86/kvm/Kconfig
> @@ -62,6 +62,7 @@ config KVM_INTEL
>  	# for perf_guest_get_msrs():
>  	depends on CPU_SUP_INTEL
>  	select IRQ_BYPASS_MANAGER
> +	select HAVE_KVM_IRQ_BYPASS
>  	---help---
>  	  Provides support for KVM on Intel processors equipped with the VT
>  	  extensions.
> diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
> index d81ac02..a59f7e3 100644
> --- a/arch/x86/kvm/x86.c
> +++ b/arch/x86/kvm/x86.c
> @@ -49,6 +49,8 @@
>  #include <linux/pci.h>
>  #include <linux/timekeeper_internal.h>
>  #include <linux/pvclock_gtod.h>
> +#include <linux/kvm_irqfd.h>
> +#include <linux/irqbypass.h>
>  #include <trace/events/kvm.h>
>  
>  #define CREATE_TRACE_POINTS
> @@ -8023,6 +8025,59 @@ out:
>  	return ret;
>  }
>  
> +void kvm_arch_irq_bypass_add_producer(struct irq_bypass_consumer *cons,
> +				      struct irq_bypass_producer *prod)
> +{
> +	int ret;
> +	struct kvm_kernel_irqfd *irqfd =
> +		container_of(cons, struct kvm_kernel_irqfd, consumer);
> +
> +	irqfd->producer = prod;
> +
> +	ret = kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 1);
> +	WARN_ON(ret);
> +}
> +
> +void kvm_arch_irq_bypass_del_producer(struct irq_bypass_consumer *cons,
> +				      struct irq_bypass_producer *prod)
> +{
> +	int ret;
> +	struct kvm_kernel_irqfd *irqfd =
> +		container_of(cons, struct kvm_kernel_irqfd, consumer);
> +
> +	irqfd->producer = NULL;
> +
> +	/*
> +	 * When producer of consumer is unregistered, we change back to
> +	 * remapped mode, so we can re-use the current implementation
> +	 * when the irq is masked/disabed or the consumer side (KVM
> +	 * int this case doesn't want to receive the interrupts.
> +	 */
> +	ret = kvm_arch_update_pi_irte(irqfd->kvm, prod->irq, irqfd->gsi, 0);
> +	WARN_ON(ret);
> +}
> +
> +void kvm_arch_irq_bypass_stop(struct irq_bypass_consumer *cons)
> +{
> +}
> +
> +void kvm_arch_irq_bypass_resume(struct irq_bypass_consumer *cons)
> +{
> +}

No need for dummy functions, these callbacks will be optional.  Thanks,

Alex

> +
> +void kvm_arch_irq_bypass_update(struct irq_bypass_consumer *cons)
> +{
> +	int ret;
> +	struct kvm_kernel_irqfd *irqfd =
> +		container_of(cons, struct kvm_kernel_irqfd, consumer);
> +
> +	BUG_ON(!irqfd->producer);
> +
> +	ret = kvm_arch_update_pi_irte(irqfd->kvm, irqfd->producer->irq,
> +				      irqfd->gsi, 1);
> +	WARN_ON(ret);
> +}
> +
>  EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_exit);
>  EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_inj_virq);
>  EXPORT_TRACEPOINT_SYMBOL_GPL(kvm_page_fault);




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

* RE: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10  3:26   ` Alex Williamson
@ 2015-07-10  4:12     ` Wu, Feng
  2015-07-10  8:28       ` Wu, Feng
  0 siblings, 1 reply; 12+ messages in thread
From: Wu, Feng @ 2015-07-10  4:12 UTC (permalink / raw)
  To: Alex Williamson
  Cc: kvm@vger.kernel.org, pbonzini@redhat.com, joro@8bytes.org,
	avi.kivity@gmail.com, eric.auger@linaro.org, Wu, Feng



> -----Original Message-----
> From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On
> Behalf Of Alex Williamson
> Sent: Friday, July 10, 2015 11:26 AM
> To: Wu, Feng
> Cc: kvm@vger.kernel.org; pbonzini@redhat.com; joro@8bytes.org;
> avi.kivity@gmail.com; eric.auger@linaro.org
> Subject: Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
> 
> On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:
> > Call update routine when updating irqfd, this can update the
> > IRTE for Intel posted-interrupts.
> >
> > Signed-off-by: Feng Wu <feng.wu@intel.com>
> > ---
> >  virt/kvm/eventfd.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> > index a32cf6c..1226835 100644
> > --- a/virt/kvm/eventfd.c
> > +++ b/virt/kvm/eventfd.c
> > @@ -570,8 +570,10 @@ 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);
> > +		irqfd->consumer.update(&irqfd->consumer);
> > +	}
> >
> >  	spin_unlock_irq(&kvm->irqfds.lock);
> >  }
> 
> I don't understand why the irq bypass manager needs to know about this
> update callback.  We could just as easily make it be a function pointer
> on the irqfd structure or maybe just open code it.  It's defined by the
> consumer and called by the consumer, the irq bypass manager shouldn't
> know about it.  Thanks,

Yes, you are right. All we need is the producer information which has been
passed in the register routine. And we can easily make this update logic
inside the consumer. Thanks for your comments!

Thanks,
Feng

> 
> Alex
> 
> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* RE: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10  4:12     ` Wu, Feng
@ 2015-07-10  8:28       ` Wu, Feng
  2015-07-10 12:47         ` Paolo Bonzini
  0 siblings, 1 reply; 12+ messages in thread
From: Wu, Feng @ 2015-07-10  8:28 UTC (permalink / raw)
  To: Alex Williamson
  Cc: kvm@vger.kernel.org, pbonzini@redhat.com, joro@8bytes.org,
	avi.kivity@gmail.com, eric.auger@linaro.org, Wu, Feng



> -----Original Message-----
> From: Wu, Feng
> Sent: Friday, July 10, 2015 12:13 PM
> To: Alex Williamson
> Cc: kvm@vger.kernel.org; pbonzini@redhat.com; joro@8bytes.org;
> avi.kivity@gmail.com; eric.auger@linaro.org; Wu, Feng
> Subject: RE: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
> 
> 
> 
> > -----Original Message-----
> > From: kvm-owner@vger.kernel.org [mailto:kvm-owner@vger.kernel.org] On
> > Behalf Of Alex Williamson
> > Sent: Friday, July 10, 2015 11:26 AM
> > To: Wu, Feng
> > Cc: kvm@vger.kernel.org; pbonzini@redhat.com; joro@8bytes.org;
> > avi.kivity@gmail.com; eric.auger@linaro.org
> > Subject: Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
> >
> > On Fri, 2015-07-10 at 11:00 +0800, Feng Wu wrote:
> > > Call update routine when updating irqfd, this can update the
> > > IRTE for Intel posted-interrupts.
> > >
> > > Signed-off-by: Feng Wu <feng.wu@intel.com>
> > > ---
> > >  virt/kvm/eventfd.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c
> > > index a32cf6c..1226835 100644
> > > --- a/virt/kvm/eventfd.c
> > > +++ b/virt/kvm/eventfd.c
> > > @@ -570,8 +570,10 @@ 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);
> > > +		irqfd->consumer.update(&irqfd->consumer);
> > > +	}
> > >
> > >  	spin_unlock_irq(&kvm->irqfds.lock);
> > >  }
> >
> > I don't understand why the irq bypass manager needs to know about this
> > update callback.  We could just as easily make it be a function pointer
> > on the irqfd structure or maybe just open code it.  It's defined by the
> > consumer and called by the consumer, the irq bypass manager shouldn't
> > know about it.  Thanks,
> 
> Yes, you are right. All we need is the producer information which has been
> passed in the register routine. And we can easily make this update logic
> inside the consumer. Thanks for your comments!
> 
> Thanks,
> Feng

BTW, Paolo & Alex, in VFIO framework, how can we know a vCPU or a guest
has assigned devices to it?

Thanks,
Feng

> 
> >
> > Alex
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe kvm" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html

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

* Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10  8:28       ` Wu, Feng
@ 2015-07-10 12:47         ` Paolo Bonzini
  2015-07-10 14:11           ` Alex Williamson
  0 siblings, 1 reply; 12+ messages in thread
From: Paolo Bonzini @ 2015-07-10 12:47 UTC (permalink / raw)
  To: Wu, Feng, Alex Williamson
  Cc: kvm@vger.kernel.org, joro@8bytes.org, avi.kivity@gmail.com,
	eric.auger@linaro.org



On 10/07/2015 10:28, Wu, Feng wrote:
> > Yes, you are right. All we need is the producer information which has been
> > passed in the register routine. And we can easily make this update logic
> > inside the consumer. Thanks for your comments!
> 
> BTW, Paolo & Alex, in VFIO framework, how can we know a vCPU or a guest
> has assigned devices to it?

See here:
http://article.gmane.org/gmane.comp.emulators.kvm.devel/137930/raw

Paolo

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

* Re: [RFC v1 5/5] Call irqbypass update routine when updating irqfd
  2015-07-10 12:47         ` Paolo Bonzini
@ 2015-07-10 14:11           ` Alex Williamson
  0 siblings, 0 replies; 12+ messages in thread
From: Alex Williamson @ 2015-07-10 14:11 UTC (permalink / raw)
  To: Paolo Bonzini
  Cc: Wu, Feng, kvm@vger.kernel.org, joro@8bytes.org,
	avi.kivity@gmail.com, eric.auger@linaro.org

On Fri, 2015-07-10 at 14:47 +0200, Paolo Bonzini wrote:
> 
> On 10/07/2015 10:28, Wu, Feng wrote:
> > > Yes, you are right. All we need is the producer information which has been
> > > passed in the register routine. And we can easily make this update logic
> > > inside the consumer. Thanks for your comments!
> > 
> > BTW, Paolo & Alex, in VFIO framework, how can we know a vCPU or a guest
> > has assigned devices to it?
> 
> See here:
> http://article.gmane.org/gmane.comp.emulators.kvm.devel/137930/raw


In general, VFIO has zero visibility into KVM.  VFIO doesn't know or
care what the userspace driver is, whether it's QEMU/KVM, a set of ruby
bindings for VFIO, a DPDK library, etc.  As Paolo points out, KVM does
have ways to be told about assigned devices from userspace and probe
some properties, like whether the IOMMU allows non-coherent DMA.  These
are handled by the KVM-VFIO pseudo device (virt/kvm/vfio.c).  Thanks,

Alex


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

end of thread, other threads:[~2015-07-10 14:11 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-07-10  3:00 [RFC v1 0/5] irq bypass interface implementation for VT-d Posted-interrupts Feng Wu
2015-07-10  3:00 ` [RFC v1 1/5] vfio: Register/unregister irq_bypass_producer Feng Wu
2015-07-10  3:00 ` [RFC v1 2/5] KVM: x86: Update IRTE for posted-interrupts Feng Wu
2015-07-10  3:00 ` [RFC v1 3/5] KVM: Add pointer to 'struct irq_bypass_produce' in 'kvm_kernel_irqfd' Feng Wu
2015-07-10  3:00 ` [RFC v1 4/5] KVM: x86: Add arch specific routines for irqbypass manager Feng Wu
2015-07-10  3:27   ` Alex Williamson
2015-07-10  3:00 ` [RFC v1 5/5] Call irqbypass update routine when updating irqfd Feng Wu
2015-07-10  3:26   ` Alex Williamson
2015-07-10  4:12     ` Wu, Feng
2015-07-10  8:28       ` Wu, Feng
2015-07-10 12:47         ` Paolo Bonzini
2015-07-10 14:11           ` Alex Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).