Message ID | 1474991845-27962-28-git-send-email-roger.pau@citrix.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
>>> On 27.09.16 at 17:57, <roger.pau@citrix.com> wrote: > The current msixtbl intercepts only partially trap MSI-X accesses, but are > not complete, there's missing logic in order to setup PIRQs and bind them to > domains. Disable them for domains without at least an ioreq server (PVH). So what if a server registers later on? > --- a/xen/arch/x86/hvm/ioreq.c > +++ b/xen/arch/x86/hvm/ioreq.c > @@ -772,6 +772,17 @@ int hvm_destroy_ioreq_server(struct domain *d, ioservid_t id) > return rc; > } > > +int hvm_has_ioreq_server(struct domain *d) bool > +{ > + int empty; bool > --- a/xen/drivers/passthrough/io.c > +++ b/xen/drivers/passthrough/io.c > @@ -24,6 +24,7 @@ > #include <asm/hvm/irq.h> > #include <asm/hvm/support.h> > #include <xen/hvm/irq.h> > +#include <asm/hvm/ioreq.h> > #include <asm/io_apic.h> Please group with the other asm/hvm/ ones. Jan
diff --git a/xen/arch/x86/hvm/ioreq.c b/xen/arch/x86/hvm/ioreq.c index d2245e2..b09fa96 100644 --- a/xen/arch/x86/hvm/ioreq.c +++ b/xen/arch/x86/hvm/ioreq.c @@ -772,6 +772,17 @@ int hvm_destroy_ioreq_server(struct domain *d, ioservid_t id) return rc; } +int hvm_has_ioreq_server(struct domain *d) +{ + int empty; + + spin_lock_recursive(&d->arch.hvm_domain.ioreq_server.lock); + empty = list_empty(&d->arch.hvm_domain.ioreq_server.list); + spin_unlock_recursive(&d->arch.hvm_domain.ioreq_server.lock); + + return !empty; +} + int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id, unsigned long *ioreq_pfn, unsigned long *bufioreq_pfn, diff --git a/xen/drivers/passthrough/io.c b/xen/drivers/passthrough/io.c index edd8dbd..1e5e365 100644 --- a/xen/drivers/passthrough/io.c +++ b/xen/drivers/passthrough/io.c @@ -24,6 +24,7 @@ #include <asm/hvm/irq.h> #include <asm/hvm/support.h> #include <xen/hvm/irq.h> +#include <asm/hvm/ioreq.h> #include <asm/io_apic.h> static DEFINE_PER_CPU(struct list_head, dpci_list); @@ -384,7 +385,8 @@ int pt_irq_create_bind( pirq_dpci->dom = d; /* bind after hvm_irq_dpci is setup to avoid race with irq handler*/ rc = pirq_guest_bind(d->vcpu[0], info, 0); - if ( rc == 0 && pt_irq_bind->u.msi.gtable ) + if ( rc == 0 && pt_irq_bind->u.msi.gtable && + hvm_has_ioreq_server(d) ) { rc = msixtbl_pt_register(d, info, pt_irq_bind->u.msi.gtable); if ( unlikely(rc) ) diff --git a/xen/include/asm-x86/hvm/ioreq.h b/xen/include/asm-x86/hvm/ioreq.h index fbf2c74..6456cd2 100644 --- a/xen/include/asm-x86/hvm/ioreq.h +++ b/xen/include/asm-x86/hvm/ioreq.h @@ -31,6 +31,7 @@ int hvm_get_ioreq_server_info(struct domain *d, ioservid_t id, unsigned long *ioreq_pfn, unsigned long *bufioreq_pfn, evtchn_port_t *bufioreq_port); +int hvm_has_ioreq_server(struct domain *d); int hvm_map_io_range_to_ioreq_server(struct domain *d, ioservid_t id, uint32_t type, uint64_t start, uint64_t end);
The current msixtbl intercepts only partially trap MSI-X accesses, but are not complete, there's missing logic in order to setup PIRQs and bind them to domains. Disable them for domains without at least an ioreq server (PVH). Signed-off-by: Roger Pau Monné <roger.pau@citrix.com> --- Cc: Paul Durrant <paul.durrant@citrix.com> Cc: Jan Beulich <jbeulich@suse.com> Cc: Andrew Cooper <andrew.cooper3@citrix.com> --- NB: this is a preparatory patch for introducing a complete MSI-X emulation layer into Xen. Long term the current msixtbl code should be replaced with the complete MSI-X emulation introduced in later patches. --- xen/arch/x86/hvm/ioreq.c | 11 +++++++++++ xen/drivers/passthrough/io.c | 4 +++- xen/include/asm-x86/hvm/ioreq.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)