218e99
From 4bb91ae660a2b4aa64c12b9f92227881edf13609 Mon Sep 17 00:00:00 2001
218e99
From: Alex Williamson <alex.williamson@redhat.com>
218e99
Date: Tue, 5 Nov 2013 15:37:52 +0100
218e99
Subject: [PATCH 17/25] vfio-pci: Fix endian issues in vfio_pci_size_rom()
218e99
218e99
RH-Author: Alex Williamson <alex.williamson@redhat.com>
218e99
Message-id: <20131105153752.16057.43832.stgit@bling.home>
218e99
Patchwork-id: 55426
218e99
O-Subject: [RHEL7 qemu-kvm PATCH 5/5] vfio-pci: Fix endian issues in vfio_pci_size_rom()
218e99
Bugzilla: 1026550
218e99
RH-Acked-by: Bandan Das <bsd@redhat.com>
218e99
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
218e99
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
218e99
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
218e99
218e99
Bugzilla: 1026550
218e99
Upstream commit: b1c50c5f248805be747e96e89efbe784ee99f764
218e99
218e99
VFIO is always little endian so do byte swapping of our mask on the
218e99
way in and byte swapping of the size on the way out.
218e99
218e99
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
218e99
Reported-by: Alexey Kardashevskiy <aik@ozlabs.ru>
218e99
---
218e99
 hw/misc/vfio.c |    4 ++--
218e99
 1 file changed, 2 insertions(+), 2 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 hw/misc/vfio.c |    4 ++--
218e99
 1 files changed, 2 insertions(+), 2 deletions(-)
218e99
218e99
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
218e99
index d327b40..6178221 100644
218e99
--- a/hw/misc/vfio.c
218e99
+++ b/hw/misc/vfio.c
218e99
@@ -1140,7 +1140,7 @@ static const MemoryRegionOps vfio_rom_ops = {
218e99
 
218e99
 static void vfio_pci_size_rom(VFIODevice *vdev)
218e99
 {
218e99
-    uint32_t orig, size = (uint32_t)PCI_ROM_ADDRESS_MASK;
218e99
+    uint32_t orig, size = cpu_to_le32((uint32_t)PCI_ROM_ADDRESS_MASK);
218e99
     off_t offset = vdev->config_offset + PCI_ROM_ADDRESS;
218e99
     char name[32];
218e99
 
218e99
@@ -1162,7 +1162,7 @@ static void vfio_pci_size_rom(VFIODevice *vdev)
218e99
         return;
218e99
     }
218e99
 
218e99
-    size = ~(size & PCI_ROM_ADDRESS_MASK) + 1;
218e99
+    size = ~(le32_to_cpu(size) & PCI_ROM_ADDRESS_MASK) + 1;
218e99
 
218e99
     if (!size) {
218e99
         return;
218e99
-- 
218e99
1.7.1
218e99