[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v1 21/21] hw/i386/kvm/xen_evtchn: Allow unmapping an emulated MSI PIRQ



From: David Woodhouse <dwmw@xxxxxxxxxxxx>

The "unmap GSI PIRQs only" check rejected every negative gsi, which
includes IRQ_MSI_EMU, so the later IRQ_MSI_EMU branch that flushes the
KVM MSI routes was unreachable and guests could never unmap an MSI
PIRQ. Xen permits it: physdev_unmap_pirq() on a domain with HVM pirqs
routes emulated-IRQ pirqs through unmap_domain_pirq_emuirq(), which
succeeds for MSI emuirqs. Let IRQ_MSI_EMU through; the existing
unreachable branch then does the route flush as originally intended.

Resolves: Coverity CID 1507603
Fixes: 6096cf7877bc ("hw/xen: Support MSI mapping to PIRQ")
Reported-by: Peter Maydell <peter.maydell@xxxxxxxxxx>
Signed-off-by: David Woodhouse <dwmw@xxxxxxxxxxxx>
---
 hw/i386/kvm/xen_evtchn.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/i386/kvm/xen_evtchn.c b/hw/i386/kvm/xen_evtchn.c
index cfe735219bf..5a986c1e2a4 100644
--- a/hw/i386/kvm/xen_evtchn.c
+++ b/hw/i386/kvm/xen_evtchn.c
@@ -1925,13 +1925,15 @@ int xen_physdev_unmap_pirq(struct physdev_unmap_pirq 
*unmap)
 
     gsi = s->pirq[pirq].gsi;
 
-    /* We can only unmap GSI PIRQs */
-    if (gsi < 0) {
+    /* We can only unmap GSI PIRQs and emulated MSIs */
+    if (gsi < 0 && gsi != IRQ_MSI_EMU) {
         qemu_mutex_unlock(&s->port_lock);
         return -EINVAL;
     }
 
-    s->gsi_pirq[gsi] = 0;
+    if (gsi >= 0) {
+        s->gsi_pirq[gsi] = 0;
+    }
     s->pirq[pirq].gsi = IRQ_UNBOUND; /* Doesn't actually matter because: */
     pirq_inuse_word(s, pirq) &= ~pirq_inuse_bit(pirq);
 
-- 
2.43.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.