9ae3a8
From ef5458e0c626a035c0de4b0b44e5fc0a38ab352c Mon Sep 17 00:00:00 2001
9ae3a8
From: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Date: Thu, 7 Aug 2014 21:02:51 +0200
9ae3a8
Subject: [PATCH 2/7] vfio-pci: Add debug config options to disable MSI/X KVM
9ae3a8
 support
9ae3a8
9ae3a8
Message-id: <20140807210251.11689.35960.stgit@gimli.home>
9ae3a8
Patchwork-id: 60478
9ae3a8
O-Subject: [RHEL7.0/z qemu-kvm PATCH v2 1/6] vfio-pci: Add debug config options to disable MSI/X KVM support
9ae3a8
Bugzilla: 1098976
9ae3a8
RH-Acked-by: Bandan Das <bsd@redhat.com>
9ae3a8
RH-Acked-by: Amos Kong <akong@redhat.com>
9ae3a8
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
9ae3a8
9ae3a8
It's sometimes useful to be able to verify interrupts are passing
9ae3a8
through correctly.
9ae3a8
9ae3a8
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 hw/misc/vfio.c | 24 ++++++++++++++++++++----
9ae3a8
 1 file changed, 20 insertions(+), 4 deletions(-)
9ae3a8
9ae3a8
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
9ae3a8
index b04170e..b5387ca 100644
9ae3a8
--- a/hw/misc/vfio.c
9ae3a8
+++ b/hw/misc/vfio.c
9ae3a8
@@ -52,6 +52,8 @@
9ae3a8
 /* Extra debugging, trap acceleration paths for more logging */
9ae3a8
 #define VFIO_ALLOW_MMAP 1
9ae3a8
 #define VFIO_ALLOW_KVM_INTX 1
9ae3a8
+#define VFIO_ALLOW_KVM_MSI 1
9ae3a8
+#define VFIO_ALLOW_KVM_MSIX 1
9ae3a8
 
9ae3a8
 struct VFIODevice;
9ae3a8
 
9ae3a8
@@ -617,9 +619,21 @@ static void vfio_msi_interrupt(void *opaque)
9ae3a8
         return;
9ae3a8
     }
9ae3a8
 
9ae3a8
-    DPRINTF("%s(%04x:%02x:%02x.%x) vector %d\n", __func__,
9ae3a8
+#ifdef VFIO_DEBUG
9ae3a8
+    MSIMessage msg;
9ae3a8
+
9ae3a8
+    if (vdev->interrupt == VFIO_INT_MSIX) {
9ae3a8
+        msg = msi_get_message(&vdev->pdev, nr);
9ae3a8
+    } else if (vdev->interrupt == VFIO_INT_MSI) {
9ae3a8
+        msg = msix_get_message(&vdev->pdev, nr);
9ae3a8
+    } else {
9ae3a8
+        abort();
9ae3a8
+    }
9ae3a8
+
9ae3a8
+    DPRINTF("%s(%04x:%02x:%02x.%x) vector %d 0x%"PRIx64"/0x%x\n", __func__,
9ae3a8
             vdev->host.domain, vdev->host.bus, vdev->host.slot,
9ae3a8
-            vdev->host.function, nr);
9ae3a8
+            vdev->host.function, nr, msg.address, msg.data);
9ae3a8
+#endif
9ae3a8
 
9ae3a8
     if (vdev->interrupt == VFIO_INT_MSIX) {
9ae3a8
         msix_notify(&vdev->pdev, nr);
9ae3a8
@@ -687,7 +701,8 @@ static int vfio_msix_vector_do_use(PCIDevice *pdev, unsigned int nr,
9ae3a8
      * Attempt to enable route through KVM irqchip,
9ae3a8
      * default to userspace handling if unavailable.
9ae3a8
      */
9ae3a8
-    vector->virq = msg ? kvm_irqchip_add_msi_route(kvm_state, *msg) : -1;
9ae3a8
+    vector->virq = msg && VFIO_ALLOW_KVM_MSIX ?
9ae3a8
+                   kvm_irqchip_add_msi_route(kvm_state, *msg) : -1;
9ae3a8
     if (vector->virq < 0 ||
9ae3a8
         kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
9ae3a8
                                        vector->virq) < 0) {
9ae3a8
@@ -854,7 +869,8 @@ retry:
9ae3a8
          * Attempt to enable route through KVM irqchip,
9ae3a8
          * default to userspace handling if unavailable.
9ae3a8
          */
9ae3a8
-        vector->virq = kvm_irqchip_add_msi_route(kvm_state, vector->msg);
9ae3a8
+        vector->virq = VFIO_ALLOW_KVM_MSI ?
9ae3a8
+                       kvm_irqchip_add_msi_route(kvm_state, vector->msg) : -1;
9ae3a8
         if (vector->virq < 0 ||
9ae3a8
             kvm_irqchip_add_irqfd_notifier(kvm_state, &vector->interrupt,
9ae3a8
                                            vector->virq) < 0) {
9ae3a8
-- 
9ae3a8
1.8.3.1
9ae3a8