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