From: Qing He Subject: [PATCH 1/2] passthrough: allow pt_bind_irq for msi update Date: Wed, 15 Apr 2009 21:41:16 +0800 Message-ID: <1239802877-8510-2-git-send-email-qing.he@intel.com> References: <> <1239802877-8510-1-git-send-email-qing.he@intel.com> Return-path: In-Reply-To: <1239802877-8510-1-git-send-email-qing.he@intel.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org This patch extends pt_bind_irq to handle the update of msi guest vector and flag. Unbind and rebind using separate hypercalls may not be viable sometime. For example, the guest may update MSI address/data on fly without disabling it first (e.g. change delivery/destination), implement these updates in such a way may result in interrupt loss. Signed-off-by: Qing He --- diff -r accf139b2eb9 xen/drivers/passthrough/io.c --- a/xen/drivers/passthrough/io.c Mon Apr 06 21:12:33 2009 +0100 +++ b/xen/drivers/passthrough/io.c Wed Apr 15 17:22:11 2009 +0800 @@ -148,12 +148,23 @@ return rc; } } - else if (hvm_irq_dpci->mirq[pirq].gmsi.gvec != pt_irq_bind->u.msi.gvec - ||hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] != pirq) + else + { + uint32_t mask = HVM_IRQ_DPCI_MACH_MSI | HVM_IRQ_DPCI_GUEST_MSI; + uint32_t old_gvec; - { - spin_unlock(&d->event_lock); - return -EBUSY; + if ( (hvm_irq_dpci->mirq[pirq].flags & mask) != mask) + { + spin_unlock(&d->event_lock); + return -EBUSY; + } + + /* if pirq is already mapped as vmsi, update the guest data/addr */ + old_gvec = hvm_irq_dpci->mirq[pirq].gmsi.gvec; + hvm_irq_dpci->msi_gvec_pirq[old_gvec] = 0; + hvm_irq_dpci->mirq[pirq].gmsi.gvec = pt_irq_bind->u.msi.gvec; + hvm_irq_dpci->mirq[pirq].gmsi.gflags = pt_irq_bind->u.msi.gflags; + hvm_irq_dpci->msi_gvec_pirq[pt_irq_bind->u.msi.gvec] = pirq; } } else