Skip to contentSkip to conversation

VFIO pull request fixes

PATCH New Alex Williamson 1 participant 3 messages Oct 4, 2013 KVM

lore
Share & tools
lore
#0 lore raw

cover VFIO pull request fixes

Bugs found by Paolo and Alexey. I'll include these in my next pull request. Thanks,

Alex

---

Alex Williamson (2):
vfio-pci: Add dummy PCI ROM write accessor
vfio-pci: Fix endian issues in vfio_pci_size_rom()

 hw/misc/vfio.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
#1 lore raw

PATCH 1/2 vfio-pci: Add dummy PCI ROM write accessor

Just to be sure we don't jump off any NULL pointer cliffs.

---
 hw/misc/vfio.c |    6 ++++++
 1 file changed, 6 insertions(+)
hw/misc/vfio.c +6 -0
index 68e25bd..1fbc40b 100644
@@ -1128,8 +1128,14 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
     return val;
 }
 
+static void vfio_rom_write(void *opaque, hwaddr addr,
+                           uint64_t data, unsigned size)
+{
+}
+
 static const MemoryRegionOps vfio_rom_ops = {
     .read = vfio_rom_read,
+    .write = vfio_rom_write,
     .endianness = DEVICE_LITTLE_ENDIAN,
 };
 
#2 lore raw

PATCH 2/2 vfio-pci: Fix endian issues in vfio_pci_size_rom()

In reply to Alex Williamson

VFIO is always little endian so do byte swapping of our mask on the way in and byte swapping of the size on the way out.

---
 hw/misc/vfio.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/misc/vfio.c +2 -2
index 1fbc40b..a2d5283 100644
@@ -1141,7 +1141,7 @@ static const MemoryRegionOps vfio_rom_ops = {
 
 static void vfio_pci_size_rom(VFIODevice *vdev)
 {
-    uint32_t orig, size = (uint32_t)PCI_ROM_ADDRESS_MASK;
+    uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
     off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
     char name[32];
 
@@ -1163,7 +1163,7 @@ static void vfio_pci_size_rom(VFIODevice *vdev)
         return;
     }
 
-    size = ~(size & PCI_ROM_ADDRESS_MASK) + 1;
+    size = ~(le32_to_cpu(size) & PCI_ROM_ADDRESS_MASK) + 1;
 
     if (!size) {
         return;