Endian updates to re-fix cross endian host and guest and

enable the same for ROM loading (Alexey)
 -----BEGIN PGP SIGNATURE-----
 Version: GnuPG v1
 
 iQIcBAABAgAGBQJUIafHAAoJECObm247sIsihf4P/06fd5TozmQjRMWMq/at9xmG
 CRAetoolT1CfTVuaTHLzpncS+WuWVYRSUWyWY9g6VEJBg9aCBoypgo/4nRAb6AER
 iE2Jeh1SWYtBUZJ9WzsE9RR4Yt+dy8ErzVWSjaUp1RffwL3m0VJK44ExGFFnyvfD
 SMHwfR4m9YJ33/XmmxY2GPUmfFuQI1xMaFYSykvx4Tgo8O9XzVpLjN53o/n2pFFv
 RnsIX7DR4yELj+E4fkYW4Epr1BRwjX2zSuDvzVLqWNt+yNgrplPiEYPHMFP3JFWi
 Vos55XYYxDSVnthtrXHGAbbFJIjES1fzAftW8K7XupqwrMeN4TgebUV7Hkvbf7BW
 VIrBrEntZnShfPzSJrsY+ZXTX3knfd1AUtXAb9VDUSoCBHgYgnegOT3ZnwVzUFwx
 F9/aqEfQLx+44zZIYvFgQkJo73tGHoji5wvDQPT3XESCMuIV1pkfss+LKd/RLzZl
 a629OXw90wiCTCu90OUnjLicLVXp7fpRueKp+/PM+PWz9BeyKIv5X4ZVGpySNLXA
 lwlwxOsASthDMIxmseV80tWiddKJbR0tvOxG2x/+eOuSIBM3raQi8BaNaBVyPfyV
 EC0HmdxtwxNqN8nE+C5n+7Nz0miCviDb1DcDRRmvEYEH69n7zru+HSXTdsJ5WDU4
 XdoxhhvuzgezGmVYj0Pa
 =D4De
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu-20140923.0' into staging

Endian updates to re-fix cross endian host and guest and
enable the same for ROM loading (Alexey)

# gpg: Signature made Tue 23 Sep 2014 18:03:03 BST using RSA key ID 3BB08B22
# gpg: Can't check signature: public key not found

* remotes/awilliam/tags/vfio-pci-for-qemu-20140923.0:
  vfio: make rom read endian sensitive
  Revert "vfio: Make BARs native endian"

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
This commit is contained in:
Peter Maydell 2014-09-24 12:00:08 +01:00
commit ca976d1803

View File

@ -1098,10 +1098,10 @@ static void vfio_bar_write(void *opaque, hwaddr addr,
buf.byte = data; buf.byte = data;
break; break;
case 2: case 2:
buf.word = data; buf.word = cpu_to_le16(data);
break; break;
case 4: case 4:
buf.dword = data; buf.dword = cpu_to_le32(data);
break; break;
default: default:
hw_error("vfio: unsupported write size, %d bytes", size); hw_error("vfio: unsupported write size, %d bytes", size);
@ -1158,10 +1158,10 @@ static uint64_t vfio_bar_read(void *opaque,
data = buf.byte; data = buf.byte;
break; break;
case 2: case 2:
data = buf.word; data = le16_to_cpu(buf.word);
break; break;
case 4: case 4:
data = buf.dword; data = le32_to_cpu(buf.dword);
break; break;
default: default:
hw_error("vfio: unsupported read size, %d bytes", size); hw_error("vfio: unsupported read size, %d bytes", size);
@ -1188,7 +1188,7 @@ static uint64_t vfio_bar_read(void *opaque,
static const MemoryRegionOps vfio_bar_ops = { static const MemoryRegionOps vfio_bar_ops = {
.read = vfio_bar_read, .read = vfio_bar_read,
.write = vfio_bar_write, .write = vfio_bar_write,
.endianness = DEVICE_NATIVE_ENDIAN, .endianness = DEVICE_LITTLE_ENDIAN,
}; };
static void vfio_pci_load_rom(VFIODevice *vdev) static void vfio_pci_load_rom(VFIODevice *vdev)
@ -1255,7 +1255,7 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
uint16_t word; uint16_t word;
uint32_t dword; uint32_t dword;
uint64_t qword; uint64_t qword;
} buf; } val;
uint64_t data = 0; uint64_t data = 0;
/* Load the ROM lazily when the guest tries to read it */ /* Load the ROM lazily when the guest tries to read it */
@ -1263,21 +1263,21 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
vfio_pci_load_rom(vdev); vfio_pci_load_rom(vdev);
} }
memcpy(&buf, vdev->rom + addr, memcpy(&val, vdev->rom + addr,
(addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0); (addr < vdev->rom_size) ? MIN(size, vdev->rom_size - addr) : 0);
switch (size) { switch (size) {
case 1: case 1:
data = buf.byte; data = val.byte;
break; break;
case 2: case 2:
data = buf.word; data = le16_to_cpu(val.word);
break; break;
case 4: case 4:
data = buf.dword; data = le32_to_cpu(val.dword);
break; break;
default: default:
hw_error("vfio: unsupported read size, %d bytes", size); hw_error("vfio: unsupported read size, %d bytes\n", size);
break; break;
} }
@ -1296,7 +1296,7 @@ static void vfio_rom_write(void *opaque, hwaddr addr,
static const MemoryRegionOps vfio_rom_ops = { static const MemoryRegionOps vfio_rom_ops = {
.read = vfio_rom_read, .read = vfio_rom_read,
.write = vfio_rom_write, .write = vfio_rom_write,
.endianness = DEVICE_NATIVE_ENDIAN, .endianness = DEVICE_LITTLE_ENDIAN,
}; };
static bool vfio_blacklist_opt_rom(VFIODevice *vdev) static bool vfio_blacklist_opt_rom(VFIODevice *vdev)