dcavalca / rpms / qemu

Forked from rpms/qemu a year ago
Clone

Blame 0006-virtio-pci-enable-bus-master-for-old-guests.patch

46f3a5
From a9862ff2c205aa289b62abcb7ddd03c7630f5c7a Mon Sep 17 00:00:00 2001
e84b90
From: "Michael S. Tsirkin" <mst@redhat.com>
e84b90
Date: Thu, 11 Sep 2014 18:45:33 +0200
e84b90
Subject: [PATCH] virtio-pci: enable bus master for old guests
e84b90
e84b90
commit cc943c36faa192cd4b32af8fe5edb31894017d35
e84b90
    pci: Use bus master address space for delivering MSI/MSI-X messages
e84b90
breaks virtio-net for rhel6.[56] x86 guests because they don't
e84b90
enable bus mastering for virtio PCI devices. For the same reason,
e84b90
rhel6.[56] ppc64 guests cannot boot on a virtio-blk disk anymore.
e84b90
e84b90
Old guests forgot to enable bus mastering, enable it automatically on
e84b90
DRIVER (guests use some devices before DRIVER_OK).
e84b90
e84b90
Reported-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
e84b90
Reviewed-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
e84b90
Tested-by: Greg Kurz <gkurz@linux.vnet.ibm.com>
e84b90
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
e84b90
(cherry picked from commit e43c0b2ea5574efb0bedebf6a7d05916eefeba52)
e84b90
---
e84b90
 hw/virtio/virtio-pci.c | 10 ++++++++++
e84b90
 1 file changed, 10 insertions(+)
e84b90
e84b90
diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c
e84b90
index 3007319..58ebbcf 100644
e84b90
--- a/hw/virtio/virtio-pci.c
e84b90
+++ b/hw/virtio/virtio-pci.c
e84b90
@@ -314,6 +314,16 @@ static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val)
e84b90
             msix_unuse_all_vectors(&proxy->pci_dev);
e84b90
         }
e84b90
 
e84b90
+        /* Linux before 2.6.34 drives the device without enabling
e84b90
+           the PCI device bus master bit. Enable it automatically
e84b90
+           for the guest. This is a PCI spec violation but so is
e84b90
+           initiating DMA with bus master bit clear. */
e84b90
+        if (val == (VIRTIO_CONFIG_S_ACKNOWLEDGE | VIRTIO_CONFIG_S_DRIVER)) {
e84b90
+            pci_default_write_config(&proxy->pci_dev, PCI_COMMAND,
e84b90
+                                     proxy->pci_dev.config[PCI_COMMAND] |
e84b90
+                                     PCI_COMMAND_MASTER, 1);
e84b90
+        }
e84b90
+
e84b90
         /* Linux before 2.6.34 sets the device as OK without enabling
e84b90
            the PCI device bus master bit. In this case we need to disable
e84b90
            some safety checks. */