diff mbox

[seabios,2/3] kvmtool: allow mmio for legacy bar 0

Message ID 20171102155031.17454-3-kraxel@redhat.com (mailing list archive)
State New, archived
Headers show

Commit Message

Gerd Hoffmann Nov. 2, 2017, 3:50 p.m. UTC
kvmtool uses MMIO not IO bar for legacy virtio.  Doesn't match spec.
But easy to handle given we have the code anyway for virtio 1.0 which
allows both MMIO and IO.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 src/hw/virtio-pci.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)
diff mbox

Patch

diff --git a/src/hw/virtio-pci.c b/src/hw/virtio-pci.c
index 96f9c6b012..1a3acc9962 100644
--- a/src/hw/virtio-pci.c
+++ b/src/hw/virtio-pci.c
@@ -488,10 +488,18 @@  void vp_init_simple(struct vp_device *vp, struct pci_device *pci)
     } else {
         dprintf(1, "pci dev %pP using legacy (0.9.5) virtio mode\n", pci);
         vp->legacy.bar = 0;
-        vp->legacy.ioaddr = pci_enable_iobar(pci, PCI_BASE_ADDRESS_0);
-        if (!vp->legacy.ioaddr)
-            return;
-        vp->legacy.mode = VP_ACCESS_IO;
+        addr = pci_config_readl(pci->bdf, PCI_BASE_ADDRESS_0);
+        if (addr & PCI_BASE_ADDRESS_SPACE_IO) {
+            vp->legacy.ioaddr = addr & PCI_BASE_ADDRESS_IO_MASK;
+            if (!vp->legacy.ioaddr)
+                return;
+            vp->legacy.mode = VP_ACCESS_IO;
+        } else {
+            vp->legacy.ioaddr = addr & PCI_BASE_ADDRESS_MEM_MASK;
+            if (!vp->legacy.ioaddr)
+                return;
+            vp->legacy.mode = VP_ACCESS_MMIO;
+        }
     }
 
     vp_reset(vp);