From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58139) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VULEf-0003CA-4L for qemu-devel@nongnu.org; Thu, 10 Oct 2013 14:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VULEZ-0007q2-5U for qemu-devel@nongnu.org; Thu, 10 Oct 2013 14:45:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14468) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VULEY-0007pr-NE for qemu-devel@nongnu.org; Thu, 10 Oct 2013 14:45:15 -0400 From: Alex Williamson Date: Thu, 10 Oct 2013 12:45:12 -0600 Message-ID: <20131010184504.31667.53614.stgit@bling.home> In-Reply-To: <20131010184122.31667.28382.stgit@bling.home> References: <20131010184122.31667.28382.stgit@bling.home> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PULL v2 8/8] vfio-pci: Fix endian issues in vfio_pci_size_rom() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: Alexey Kardashevskiy , qemu-devel@nongnu.org, kvm@vger.kernel.org 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 Reported-by: Alexey Kardashevskiy --- hw/misc/vfio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 1fbc40b..a2d5283 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;