yeahuh / rpms / qemu-kvm

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