Message ID | 1434657848.3700.83.camel@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Thu, Jun 18, 2015 at 02:04:08PM -0600, Alex Williamson wrote:
> There are plenty of details to be filled in,
I also need to fill plenty of details in my head first, so here are some
suggestions based on my current understanding. Please don't hesitate to
correct me if where I got something wrong.
So first I totally agree that the handling of PI/non-PI configurations
should be transparent to user-space.
I read a bit through the VT-d spec, and my understanding of posted
interrupts so far is that:
1) Each VCPU gets a PI-Descriptor with its pending Posted
Interrupts. This descriptor needs to be updated when a VCPU
is migrated to another PCPU and should thus be under control
of KVM.
This is similar to the vAPIC backing page in the AMD version
of this, except that the PCPU routing information is stored
somewhere else on AMD.
2) As long as the VCPU runs the IRTEs are configured for
posting, when the VCPU goes to sleep the old remapped entry is
established again. So when the VCPU sleeps the interrupt
would get routed to VFIO and forwarded through the eventfd.
This would be different to the AMD version, where we have a
running bit. When this is clear the IOMMU will trigger an event
in its event-log. This might need special handling in VFIO
('might' because VFIO does not need to forward the interrupt,
it just needs to make sure the VCPU wakes up).
Please correct me if my understanding of the Intel version is
wrong.
So most of the data structures the IOMMU reads for this need to be
updated from KVM code (either x86-generic or AMD/Intel specific code),
as KVM has the information about VCPU load/unload and the IRQ routing.
What KVM needs from VFIO are the informations about the physical
interrupts, and it makes total sense to attach them as metadata to the
eventfd.
But the problems start at how this metadata should look like. It would
be good to have some generic description, but not sure if this is
possible. Otherwise this metadata would need to be requested by VFIO
from the IOMMU driver and passed on to KVM, which it then passes back to
the IOMMU driver. Or something like that.
Joerg
--
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
> -----Original Message----- > From: Joerg Roedel [mailto:joro@8bytes.org] > Sent: Wednesday, June 24, 2015 11:46 PM > To: Alex Williamson > Cc: Wu, Feng; Eric Auger; Avi Kivity; kvm@vger.kernel.org; > linux-kernel@vger.kernel.org; pbonzini@redhat.com; mtosatti@redhat.com > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > On Thu, Jun 18, 2015 at 02:04:08PM -0600, Alex Williamson wrote: > > There are plenty of details to be filled in, > > I also need to fill plenty of details in my head first, so here are some > suggestions based on my current understanding. Please don't hesitate to > correct me if where I got something wrong. > > So first I totally agree that the handling of PI/non-PI configurations > should be transparent to user-space. > > I read a bit through the VT-d spec, and my understanding of posted > interrupts so far is that: > > 1) Each VCPU gets a PI-Descriptor with its pending Posted > Interrupts. This descriptor needs to be updated when a VCPU > is migrated to another PCPU and should thus be under control > of KVM. > > This is similar to the vAPIC backing page in the AMD version > of this, except that the PCPU routing information is stored > somewhere else on AMD. > > 2) As long as the VCPU runs the IRTEs are configured for > posting, when the VCPU goes to sleep the old remapped entry is > established again. So when the VCPU sleeps the interrupt > would get routed to VFIO and forwarded through the eventfd. When the vCPU sleeps, says, blocked when guest is running HLT, the interrupt is still in posted mode. The solution is when the vCPU is blocked, we use another notification vector (named wakeup notification vector) to wakeup the blocked vCPU when interrupts happens. And in the wakeup event handler, we unblock the vCPU. Thanks, Feng > > This would be different to the AMD version, where we have a > running bit. When this is clear the IOMMU will trigger an event > in its event-log. This might need special handling in VFIO > ('might' because VFIO does not need to forward the interrupt, > it just needs to make sure the VCPU wakes up). > > Please correct me if my understanding of the Intel version is > wrong. > > So most of the data structures the IOMMU reads for this need to be > updated from KVM code (either x86-generic or AMD/Intel specific code), > as KVM has the information about VCPU load/unload and the IRQ routing. Yes, this part has nothing to do with VFIO, KVM itself can handle it well. > > What KVM needs from VFIO are the informations about the physical > interrupts, and it makes total sense to attach them as metadata to the > eventfd. When guest set the irq affinity, QEMU first gets the MSI/MSIx configuration, then it passes these information to kernel space via VFIO infrastructure, we need these MSI/MSIx configuration to update the associated posted-format IRTE according. This is the key point for PI in term of VFIO. Thanks, Feng > > But the problems start at how this metadata should look like. It would > be good to have some generic description, but not sure if this is > possible. Otherwise this metadata would need to be requested by VFIO > from the IOMMU driver and passed on to KVM, which it then passes back to > the IOMMU driver. Or something like that. > > > > Joerg -- 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
> -----Original Message----- > From: Joerg Roedel [mailto:joro@8bytes.org] > Sent: Wednesday, June 24, 2015 11:46 PM > To: Alex Williamson > Cc: Wu, Feng; Eric Auger; Avi Kivity; kvm@vger.kernel.org; > linux-kernel@vger.kernel.org; pbonzini@redhat.com; mtosatti@redhat.com > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > On Thu, Jun 18, 2015 at 02:04:08PM -0600, Alex Williamson wrote: > > There are plenty of details to be filled in, > > I also need to fill plenty of details in my head first, so here are some > suggestions based on my current understanding. Please don't hesitate to > correct me if where I got something wrong. > > So first I totally agree that the handling of PI/non-PI configurations > should be transparent to user-space. After thinking about this a bit more, I recall that why I used user-space to trigger the IRTE update for posted-interrupts, here is the reason: Let's take MSI for an example: When guest updates the MSI configuration, here is the code path in QEMU and KVM: vfio_update_msi() --> vfio_update_kvm_msi_virq() --> kvm_irqchip_update_msi_route() --> kvm_update_routing_entry() --> kvm_irqchip_commit_routes() --> kvm_irqchip_commit_routes() --> KVM_SET_GSI_ROUTING --> kvm_set_irq_routing() It will finally go to kvm_set_irq_routing() in KVM, there are two problem: 1. It use RCU in this function, it is hard to find which entry in the irq routing table is being updated. 2. Even we find the updated entry, it is hard to find the associated assigned device with this irq routing entry. So I used a VFIO API to notify KVM the updated MSI/MSIx configuration and the associated assigned devices. I think we need to find a way to address the above two issues before going forward. Alex, what is your opinion? Thanks a lot! Thanks, Feng > > I read a bit through the VT-d spec, and my understanding of posted > interrupts so far is that: > > 1) Each VCPU gets a PI-Descriptor with its pending Posted > Interrupts. This descriptor needs to be updated when a VCPU > is migrated to another PCPU and should thus be under control > of KVM. > > This is similar to the vAPIC backing page in the AMD version > of this, except that the PCPU routing information is stored > somewhere else on AMD. > > 2) As long as the VCPU runs the IRTEs are configured for > posting, when the VCPU goes to sleep the old remapped entry is > established again. So when the VCPU sleeps the interrupt > would get routed to VFIO and forwarded through the eventfd. > > This would be different to the AMD version, where we have a > running bit. When this is clear the IOMMU will trigger an event > in its event-log. This might need special handling in VFIO > ('might' because VFIO does not need to forward the interrupt, > it just needs to make sure the VCPU wakes up). > > Please correct me if my understanding of the Intel version is > wrong. > > So most of the data structures the IOMMU reads for this need to be > updated from KVM code (either x86-generic or AMD/Intel specific code), > as KVM has the information about VCPU load/unload and the IRQ routing. > > What KVM needs from VFIO are the informations about the physical > interrupts, and it makes total sense to attach them as metadata to the > eventfd. > > But the problems start at how this metadata should look like. It would > be good to have some generic description, but not sure if this is > possible. Otherwise this metadata would need to be requested by VFIO > from the IOMMU driver and passed on to KVM, which it then passes back to > the IOMMU driver. Or something like that. > > > > Joerg -- 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
On Thu, 2015-06-25 at 09:37 +0000, Wu, Feng wrote: > > > -----Original Message----- > > From: Joerg Roedel [mailto:joro@8bytes.org] > > Sent: Wednesday, June 24, 2015 11:46 PM > > To: Alex Williamson > > Cc: Wu, Feng; Eric Auger; Avi Kivity; kvm@vger.kernel.org; > > linux-kernel@vger.kernel.org; pbonzini@redhat.com; mtosatti@redhat.com > > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > > > On Thu, Jun 18, 2015 at 02:04:08PM -0600, Alex Williamson wrote: > > > There are plenty of details to be filled in, > > > > I also need to fill plenty of details in my head first, so here are some > > suggestions based on my current understanding. Please don't hesitate to > > correct me if where I got something wrong. > > > > So first I totally agree that the handling of PI/non-PI configurations > > should be transparent to user-space. > > After thinking about this a bit more, I recall that why I used user-space > to trigger the IRTE update for posted-interrupts, here is the reason: > > Let's take MSI for an example: > When guest updates the MSI configuration, here is the code path in > QEMU and KVM: > > vfio_update_msi() --> vfio_update_kvm_msi_virq() --> > kvm_irqchip_update_msi_route() --> kvm_update_routing_entry() --> > kvm_irqchip_commit_routes() --> kvm_irqchip_commit_routes() --> > KVM_SET_GSI_ROUTING --> kvm_set_irq_routing() > > It will finally go to kvm_set_irq_routing() in KVM, there are two problem: > 1. It use RCU in this function, it is hard to find which entry in the irq routing > table is being updated. > 2. Even we find the updated entry, it is hard to find the associated assigned > device with this irq routing entry. > > So I used a VFIO API to notify KVM the updated MSI/MSIx configuration and > the associated assigned devices. I think we need to find a way to address > the above two issues before going forward. Alex, what is your opinion? So the trouble is that QEMU vfio updates a single MSI vector, but that just updates a single entry within a whole table of routes, then the whole table is pushed to KVM. But in kvm_set_irq_routing() we have access to both the new and the old tables, so we do have the ability to detect the change. We can therefore detect which GSI changed and cross-reference that to KVMs irqfds. If we have an irqfd that matches the GSI then we have all the information we need, right? We can use the eventfd_ctx of the irqfd to call into the IRQ bypass manager if we need to. If it's an irqfd that's already enabled for bypass then we may already have the data we need to tweak the PI config. Yes, I agree it's more difficult, but it doesn't appear to be impossible, right? Thanks, 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
Hi Feng, On Thu, Jun 25, 2015 at 09:11:52AM -0600, Alex Williamson wrote: > So the trouble is that QEMU vfio updates a single MSI vector, but that > just updates a single entry within a whole table of routes, then the > whole table is pushed to KVM. But in kvm_set_irq_routing() we have > access to both the new and the old tables, so we do have the ability to > detect the change. We can therefore detect which GSI changed and > cross-reference that to KVMs irqfds. If we have an irqfd that matches > the GSI then we have all the information we need, right? We can use the > eventfd_ctx of the irqfd to call into the IRQ bypass manager if we need > to. If it's an irqfd that's already enabled for bypass then we may > already have the data we need to tweak the PI config. > > Yes, I agree it's more difficult, but it doesn't appear to be > impossible, right? Since this also doesn't happen very often, you could also just update _all_ PI data-structures from kvm_set_irq_routing, no? This would just resemble the way the API works anyway. You just need to be careful to update the data structures only when the function can't fail anymore, so that you don't have to roll back anything. Joerg -- 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
> -----Original Message----- > From: Joerg Roedel [mailto:joro@8bytes.org] > Sent: Monday, June 29, 2015 5:06 PM > To: Wu, Feng > Cc: Alex Williamson; Eric Auger; Avi Kivity; kvm@vger.kernel.org; > linux-kernel@vger.kernel.org; pbonzini@redhat.com; mtosatti@redhat.com > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > Hi Feng, > > On Thu, Jun 25, 2015 at 09:11:52AM -0600, Alex Williamson wrote: > > So the trouble is that QEMU vfio updates a single MSI vector, but that > > just updates a single entry within a whole table of routes, then the > > whole table is pushed to KVM. But in kvm_set_irq_routing() we have > > access to both the new and the old tables, so we do have the ability to > > detect the change. We can therefore detect which GSI changed and > > cross-reference that to KVMs irqfds. If we have an irqfd that matches > > the GSI then we have all the information we need, right? We can use the > > eventfd_ctx of the irqfd to call into the IRQ bypass manager if we need > > to. If it's an irqfd that's already enabled for bypass then we may > > already have the data we need to tweak the PI config. > > > > Yes, I agree it's more difficult, but it doesn't appear to be > > impossible, right? > > Since this also doesn't happen very often, you could also just update _all_ > PI data-structures from kvm_set_irq_routing, no? This would just > resemble the way the API works anyway. Thanks a lot for your suggestion, Joerg! Do you mean updating the hardware IRTEs for all the entries in the irq routing table, no matter whether it is the updated one? Thanks, Feng > > You just need to be careful to update the data structures only when the > function can't fail anymore, so that you don't have to roll back > anything. > > > Joerg -- 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
On Mon, Jun 29, 2015 at 09:14:54AM +0000, Wu, Feng wrote: > Do you mean updating the hardware IRTEs for all the entries in the irq > routing table, no matter whether it is the updated one? Right, that's what I mean. It seems wrong to me to work around the API interface by creating a diff between the old and the new routing table. It is much simpler (and easier to maintain) to just update the IRTE and PI structures for all IRQs in the routing table, especially since this is not a hot-path. Joerg -- 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
> -----Original Message----- > From: Joerg Roedel [mailto:joro@8bytes.org] > Sent: Monday, June 29, 2015 5:23 PM > To: Wu, Feng > Cc: Alex Williamson; Eric Auger; Avi Kivity; kvm@vger.kernel.org; > linux-kernel@vger.kernel.org; pbonzini@redhat.com; mtosatti@redhat.com > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > On Mon, Jun 29, 2015 at 09:14:54AM +0000, Wu, Feng wrote: > > Do you mean updating the hardware IRTEs for all the entries in the irq > > routing table, no matter whether it is the updated one? > > Right, that's what I mean. It seems wrong to me to work around the API > interface by creating a diff between the old and the new routing table. Yes the original usage model here doesn't care about the diff between the old and new, it is a little intrusive to add the comparison code here. > It is much simpler (and easier to maintain) to just update the IRTE > and PI structures for all IRQs in the routing table, especially since > this is not a hot-path. Agree. Thanks, Feng > > > Joerg -- 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
DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogQWxleCBXaWxsaWFtc29u IFttYWlsdG86YWxleC53aWxsaWFtc29uQHJlZGhhdC5jb21dDQo+IFNlbnQ6IEZyaWRheSwgSnVu ZSAxOSwgMjAxNSA0OjA0IEFNDQo+IFRvOiBXdSwgRmVuZw0KPiBDYzogRXJpYyBBdWdlcjsgQXZp IEtpdml0eTsga3ZtQHZnZXIua2VybmVsLm9yZzsgbGludXgta2VybmVsQHZnZXIua2VybmVsLm9y ZzsNCj4gcGJvbnppbmlAcmVkaGF0LmNvbTsgbXRvc2F0dGlAcmVkaGF0LmNvbTsgSm9lcmcgUm9l ZGVsDQo+IFN1YmplY3Q6IFJlOiBbdjQgMDgvMTZdIEtWTToga3ZtLXZmaW86IFVzZXIgQVBJIGZv ciBJUlEgZm9yd2FyZGluZw0KPiANCj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o+ICsJLyogaXJxX2J5cGFzc19yZWdpc3Rlcl9jb25zdW1lcigpOyAqLw0KPiArDQo+ICAJ cmV0dXJuIDA7DQo+IA0KPiAgZmFpbDoNCj4gQEAgLTUyOCw2ICs1MzAsOCBAQCBrdm1faXJxZmRf ZGVhc3NpZ24oc3RydWN0IGt2bSAqa3ZtLCBzdHJ1Y3Qga3ZtX2lycWZkDQo+ICphcmdzKQ0KPiAg CXN0cnVjdCBfaXJxZmQgKmlycWZkLCAqdG1wOw0KPiAgCXN0cnVjdCBldmVudGZkX2N0eCAqZXZl bnRmZDsNCj4gDQo+ICsJLyogaXJxX2J5cGFzc191bnJlZ2lzdGVyX2NvbnN1bWVyKCkgKi8NCj4g Kw0KPiAgCWV2ZW50ZmQgPSBldmVudGZkX2N0eF9mZGdldChhcmdzLT5mZCk7DQo+ICAJaWYgKElT X0VSUihldmVudGZkKSkNCj4gIAkJcmV0dXJuIFBUUl9FUlIoZXZlbnRmZCk7DQo+IA0KPiANCg0K -- 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
On Mon, 2015-06-29 at 13:27 +0000, Wu, Feng wrote: > > > > -----Original Message----- > > From: Alex Williamson [mailto:alex.williamson@redhat.com] > > Sent: Friday, June 19, 2015 4:04 AM > > To: Wu, Feng > > Cc: Eric Auger; Avi Kivity; kvm@vger.kernel.org; linux-kernel@vger.kernel.org; > > pbonzini@redhat.com; mtosatti@redhat.com; Joerg Roedel > > Subject: Re: [v4 08/16] KVM: kvm-vfio: User API for IRQ forwarding > > > > [Adding Joerg since he was part of this original idea] > > > > > > There are plenty of details to be filled in, but I think the basics > > looks something like the code below. The IRQ bypass manager just > > defines a pair of structures, one for interrupt producers and one for > > interrupt consumers. I'm certain that we'll need more callbacks than > > I've defined below, but figuring out what those should be for the best > > abstraction is the hardest part of this idea. The manager provides both > > registration and de-registration interfaces for both types of objects > > and keeps lists for each, protected by a lock. The manager doesn't even > > really need to know what the match token is, but I assume for our > > purposes it will be an eventfd_ctx. > > > > On the vfio side, the producer struct would be embedded in the > > vfio_pci_irq_ctx struct. KVM would probably embed the consumer struct > > in _irqfd. As I've coded below, the IRQ bypass manager calls the > > consumer callbacks, so the producer struct would need fields or > > callbacks to provide the consumer the info it needs. AIUI the Posted > > Interrupt model, VFIO only needs to provide data to the consumer. For > > IRQ Forwarding, I think the producer needs to be informed when bypass is > > active to model the incoming interrupt as edge vs level. > > > > I've prototyped the base IRQ bypass manager here as static, but I don't > > see any reason it couldn't be a module that's loaded by dependency when > > either vfio-pci or kvm-intel is loaded (or other producer/consumer > > objects). > > > > Is this a reasonable starting point to craft the additional fields and > > callbacks and interaction of who calls who that we need to support > > Posted Interrupts and IRQ Forwarding? Is the AMD version of this still > > alive? Thanks, > > > > Alex > > > > diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig > > index 413a7bf..22f6fcb 100644 > > --- a/arch/x86/kvm/Kconfig > > +++ b/arch/x86/kvm/Kconfig > > @@ -61,6 +61,7 @@ config KVM_INTEL > > depends on KVM > > # for perf_guest_get_msrs(): > > depends on CPU_SUP_INTEL > > + select IRQ_BYPASS_MANAGER > > ---help--- > > Provides support for KVM on Intel processors equipped with the VT > > extensions. > > diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig > > index 579d83b..02912f1 100644 > > --- a/drivers/vfio/pci/Kconfig > > +++ b/drivers/vfio/pci/Kconfig > > @@ -2,6 +2,7 @@ config VFIO_PCI > > tristate "VFIO support for PCI devices" > > depends on VFIO && PCI && EVENTFD > > select VFIO_VIRQFD > > + select IRQ_BYPASS_MANAGER > > help > > Support for the PCI VFIO bus driver. This is required to make > > use of PCI drivers using the VFIO framework. > > diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c > > index 1f577b4..4e053be 100644 > > --- a/drivers/vfio/pci/vfio_pci_intrs.c > > +++ b/drivers/vfio/pci/vfio_pci_intrs.c > > @@ -181,6 +181,7 @@ static int vfio_intx_set_signal(struct vfio_pci_device > > *vdev, int fd) > > > > if (vdev->ctx[0].trigger) { > > free_irq(pdev->irq, vdev); > > + /* irq_bypass_unregister_producer(); */ > > kfree(vdev->ctx[0].name); > > eventfd_ctx_put(vdev->ctx[0].trigger); > > vdev->ctx[0].trigger = NULL; > > @@ -214,6 +215,8 @@ static int vfio_intx_set_signal(struct vfio_pci_device > > *vdev, int fd) > > return ret; > > } > > > > + /* irq_bypass_register_producer(); */ > > + > > /* > > * INTx disable will stick across the new irq setup, > > * disable_irq won't. > > @@ -319,6 +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(); */ > > kfree(vdev->ctx[vector].name); > > eventfd_ctx_put(vdev->ctx[vector].trigger); > > vdev->ctx[vector].trigger = NULL; > > @@ -360,6 +364,8 @@ static int vfio_msi_set_vector_signal(struct > > vfio_pci_device *vdev, > > return ret; > > } > > > > + /* irq_bypass_register_producer(); */ > > + > > vdev->ctx[vector].trigger = trigger; > > > > return 0; > > diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h > > new file mode 100644 > > index 0000000..718508e > > --- /dev/null > > +++ b/include/linux/irqbypass.h > > @@ -0,0 +1,23 @@ > > +#ifndef IRQBYPASS_H > > +#define IRQBYPASS_H > > + > > +#include <linux/list.h> > > + > > +struct irq_bypass_producer { > > + struct list_head node; > > + void *token; > > + /* TBD */ > > +}; > > + > > +struct irq_bypass_consumer { > > + struct list_head node; > > + void *token; > > + void (*add_producer)(struct irq_bypass_producer *); > > + void (*del_producer)(struct irq_bypass_producer *); > > These two callbacks should be common function, for PI, I need to add > something specific to x86, such as, updating the associated IRTE, how > should I do for this? These are function pointers, the consumer (kvm in this case) can populate them with whatever implementation it needs. The details of updating the IRTE should be completely hidden from this interface. This interface only handles identifying matches between producer and consumer and providing an API for the handshake. Feel free to use more appropriate callbacks and structure fields, these are only meant as a rough sketch of the idea and possible interaction, but please keep layering in mind to make a generic interface. > > +}; > > + > > +int irq_bypass_register_producer(struct irq_bypass_producer *); > > +void irq_bypass_unregister_producer(struct irq_bypass_producer *); > > +int irq_bypass_register_consumer(struct irq_bypass_consumer *); > > +void irq_bypass_unregister_consumer(struct irq_bypass_consumer *); > > +#endif /* IRQBYPASS_H */ > > diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig > > index 9a76e3b..4502cdc 100644 > > --- a/kernel/irq/Kconfig > > +++ b/kernel/irq/Kconfig > > @@ -100,4 +100,7 @@ config SPARSE_IRQ > > > > If you don't know what to do here, say N. > > > > +config IRQ_BYPASS_MANAGER > > + bool > > + > > endmenu > > diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile > > index d121235..a30ed77 100644 > > --- a/kernel/irq/Makefile > > +++ b/kernel/irq/Makefile > > @@ -7,3 +7,4 @@ obj-$(CONFIG_PROC_FS) += proc.o > > obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o > > obj-$(CONFIG_PM_SLEEP) += pm.o > > obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o > > +obj-$(CONFIG_IRQ_BYPASS_MANAGER) += bypass.o > > diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c > > new file mode 100644 > > index 0000000..5d0f92b > > --- /dev/null > > +++ b/kernel/irq/bypass.c > > Is it better to put this code here or in vfio folder? What about it is specific to vfio? Both vfio and kvm are clients to the interface, but I don't think we want to add any barriers that restrict it to that pair. I think we originally thought of this as an IOMMU service, so drivers/iommu might be another possible home for it. Thanks, 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
diff --git a/arch/x86/kvm/Kconfig b/arch/x86/kvm/Kconfig index 413a7bf..22f6fcb 100644 --- a/arch/x86/kvm/Kconfig +++ b/arch/x86/kvm/Kconfig @@ -61,6 +61,7 @@ config KVM_INTEL depends on KVM # for perf_guest_get_msrs(): depends on CPU_SUP_INTEL + select IRQ_BYPASS_MANAGER ---help--- Provides support for KVM on Intel processors equipped with the VT extensions. diff --git a/drivers/vfio/pci/Kconfig b/drivers/vfio/pci/Kconfig index 579d83b..02912f1 100644 --- a/drivers/vfio/pci/Kconfig +++ b/drivers/vfio/pci/Kconfig @@ -2,6 +2,7 @@ config VFIO_PCI tristate "VFIO support for PCI devices" depends on VFIO && PCI && EVENTFD select VFIO_VIRQFD + select IRQ_BYPASS_MANAGER help Support for the PCI VFIO bus driver. This is required to make use of PCI drivers using the VFIO framework. diff --git a/drivers/vfio/pci/vfio_pci_intrs.c b/drivers/vfio/pci/vfio_pci_intrs.c index 1f577b4..4e053be 100644 --- a/drivers/vfio/pci/vfio_pci_intrs.c +++ b/drivers/vfio/pci/vfio_pci_intrs.c @@ -181,6 +181,7 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd) if (vdev->ctx[0].trigger) { free_irq(pdev->irq, vdev); + /* irq_bypass_unregister_producer(); */ kfree(vdev->ctx[0].name); eventfd_ctx_put(vdev->ctx[0].trigger); vdev->ctx[0].trigger = NULL; @@ -214,6 +215,8 @@ static int vfio_intx_set_signal(struct vfio_pci_device *vdev, int fd) return ret; } + /* irq_bypass_register_producer(); */ + /* * INTx disable will stick across the new irq setup, * disable_irq won't. @@ -319,6 +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(); */ kfree(vdev->ctx[vector].name); eventfd_ctx_put(vdev->ctx[vector].trigger); vdev->ctx[vector].trigger = NULL; @@ -360,6 +364,8 @@ static int vfio_msi_set_vector_signal(struct vfio_pci_device *vdev, return ret; } + /* irq_bypass_register_producer(); */ + vdev->ctx[vector].trigger = trigger; return 0; diff --git a/include/linux/irqbypass.h b/include/linux/irqbypass.h new file mode 100644 index 0000000..718508e --- /dev/null +++ b/include/linux/irqbypass.h @@ -0,0 +1,23 @@ +#ifndef IRQBYPASS_H +#define IRQBYPASS_H + +#include <linux/list.h> + +struct irq_bypass_producer { + struct list_head node; + void *token; + /* TBD */ +}; + +struct irq_bypass_consumer { + struct list_head node; + void *token; + void (*add_producer)(struct irq_bypass_producer *); + void (*del_producer)(struct irq_bypass_producer *); +}; + +int irq_bypass_register_producer(struct irq_bypass_producer *); +void irq_bypass_unregister_producer(struct irq_bypass_producer *); +int irq_bypass_register_consumer(struct irq_bypass_consumer *); +void irq_bypass_unregister_consumer(struct irq_bypass_consumer *); +#endif /* IRQBYPASS_H */ diff --git a/kernel/irq/Kconfig b/kernel/irq/Kconfig index 9a76e3b..4502cdc 100644 --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -100,4 +100,7 @@ config SPARSE_IRQ If you don't know what to do here, say N. +config IRQ_BYPASS_MANAGER + bool + endmenu diff --git a/kernel/irq/Makefile b/kernel/irq/Makefile index d121235..a30ed77 100644 --- a/kernel/irq/Makefile +++ b/kernel/irq/Makefile @@ -7,3 +7,4 @@ obj-$(CONFIG_PROC_FS) += proc.o obj-$(CONFIG_GENERIC_PENDING_IRQ) += migration.o obj-$(CONFIG_PM_SLEEP) += pm.o obj-$(CONFIG_GENERIC_MSI_IRQ) += msi.o +obj-$(CONFIG_IRQ_BYPASS_MANAGER) += bypass.o diff --git a/kernel/irq/bypass.c b/kernel/irq/bypass.c new file mode 100644 index 0000000..5d0f92b --- /dev/null +++ b/kernel/irq/bypass.c @@ -0,0 +1,116 @@ +/* + * IRQ offload/bypass manager + * + * Various virtualization hardware acceleration techniques allow bypassing + * or offloading interrupts receieved from devices around the host kernel. + * Posted Interrupts on Intel VT-d systems can allow interrupts to be + * recieved directly by a virtual machine. ARM IRQ Forwarding can allow + * level triggered device interrupts to be de-asserted directly by the VM. + * This manager allows interrupt producers and consumers to find each other + * to enable this sort of bypass. + */ + +#include <linux/irqbypass.h> +#include <linux/list.h> +#include <linux/module.h> +#include <linux/mutex.h> + +static LIST_HEAD(producers); +static LIST_HEAD(consumers); +static DEFINE_MUTEX(lock); + +int irq_bypass_register_producer(struct irq_bypass_producer *producer) +{ + struct irq_bypass_producer *tmp; + struct irq_bypass_consumer *consumer; + int ret = 0; + + mutex_lock(&lock); + + list_for_each_entry(tmp, &producers, node) { + if (tmp->token == producer->token) { + ret = -EINVAL; + goto unlock; + } + } + + list_add(&producer->node, &producers); + + list_for_each_entry(consumer, &consumers, node) { + if (consumer->token == producer->token) { + consumer->add_producer(producer); + break; + } + } +unlock: + mutex_unlock(&lock); + return ret; +} +EXPORT_SYMBOL_GPL(irq_bypass_register_producer); + +void irq_bypass_unregister_producer(struct irq_bypass_producer *producer) +{ + struct irq_bypass_consumer *consumer; + + mutex_lock(&lock); + + list_for_each_entry(consumer, &consumers, node) { + if (consumer->token == producer->token) { + consumer->del_producer(producer); + break; + } + } + + list_del(&producer->node); + + mutex_unlock(&lock); +} +EXPORT_SYMBOL_GPL(irq_bypass_unregister_producer); + +int irq_bypass_register_consumer(struct irq_bypass_consumer *consumer) +{ + struct irq_bypass_consumer *tmp; + struct irq_bypass_producer *producer; + int ret = 0; + + mutex_lock(&lock); + + list_for_each_entry(tmp, &consumers, node) { + if (tmp->token == consumer->token) { + ret = -EINVAL; + goto unlock; + } + } + + list_add(&consumer->node, &consumers); + + list_for_each_entry(producer, &producers, node) { + if (producer->token == consumer->token) { + consumer->add_producer(producer); + break; + } + } +unlock: + mutex_unlock(&lock); + return ret; +} +EXPORT_SYMBOL_GPL(irq_bypass_register_consumer); + +void irq_bypass_unregister_consumer(struct irq_bypass_consumer *consumer) +{ + struct irq_bypass_producer *producer; + + mutex_lock(&lock); + + list_for_each_entry(producer, &producers, node) { + if (producer->token == consumer->token) { + consumer->del_producer(producer); + break; + } + } + + list_del(&consumer->node); + + mutex_unlock(&lock); +} +EXPORT_SYMBOL_GPL(irq_bypass_unregister_consumer); diff --git a/virt/kvm/eventfd.c b/virt/kvm/eventfd.c index 9ff4193..f3da161 100644 --- a/virt/kvm/eventfd.c +++ b/virt/kvm/eventfd.c @@ -429,6 +429,8 @@ kvm_irqfd_assign(struct kvm *kvm, struct kvm_irqfd *args) */ fdput(f); + /* irq_bypass_register_consumer(); */ + return 0; fail: @@ -528,6 +530,8 @@ kvm_irqfd_deassign(struct kvm *kvm, struct kvm_irqfd *args) struct _irqfd *irqfd, *tmp; struct eventfd_ctx *eventfd; + /* irq_bypass_unregister_consumer() */ + eventfd = eventfd_ctx_fdget(args->fd); if (IS_ERR(eventfd)) return PTR_ERR(eventfd);