diff options
author | Alex Williamson <alex.williamson@redhat.com> | 2013-10-04 12:50:51 -0600 |
---|---|---|
committer | Alex Williamson <alex.williamson@redhat.com> | 2013-10-04 12:50:51 -0600 |
commit | b1c50c5f248805be747e96e89efbe784ee99f764 (patch) | |
tree | c154ea54ab178690e7953955577eb6be699e5239 /hw/misc/vfio.c | |
parent | 64fa25a0efcadda6e8197e8ea578f6117d01bb4b (diff) |
vfio-pci: Fix endian issues in vfio_pci_size_rom()
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.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Diffstat (limited to 'hw/misc/vfio.c')
-rw-r--r-- | hw/misc/vfio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 1fbc40b960..a2d5283ff9 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -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; |