Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/awilliam/tags/vfio-pci-for-qemu…
Browse files Browse the repository at this point in the history
…-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 <[email protected]>
  • Loading branch information
pm215 committed Sep 24, 2014
2 parents 01f7cec + 75bd0c7 commit ca976d1
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions hw/misc/vfio.c
Original file line number Diff line number Diff line change
Expand Up @@ -1098,10 +1098,10 @@ static void vfio_bar_write(void *opaque, hwaddr addr,
buf.byte = data;
break;
case 2:
buf.word = data;
buf.word = cpu_to_le16(data);
break;
case 4:
buf.dword = data;
buf.dword = cpu_to_le32(data);
break;
default:
hw_error("vfio: unsupported write size, %d bytes", size);
Expand Down Expand Up @@ -1158,10 +1158,10 @@ static uint64_t vfio_bar_read(void *opaque,
data = buf.byte;
break;
case 2:
data = buf.word;
data = le16_to_cpu(buf.word);
break;
case 4:
data = buf.dword;
data = le32_to_cpu(buf.dword);
break;
default:
hw_error("vfio: unsupported read size, %d bytes", size);
Expand All @@ -1188,7 +1188,7 @@ static uint64_t vfio_bar_read(void *opaque,
static const MemoryRegionOps vfio_bar_ops = {
.read = vfio_bar_read,
.write = vfio_bar_write,
.endianness = DEVICE_NATIVE_ENDIAN,
.endianness = DEVICE_LITTLE_ENDIAN,
};

static void vfio_pci_load_rom(VFIODevice *vdev)
Expand Down Expand Up @@ -1255,29 +1255,29 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size)
uint16_t word;
uint32_t dword;
uint64_t qword;
} buf;
} val;
uint64_t data = 0;

/* Load the ROM lazily when the guest tries to read it */
if (unlikely(!vdev->rom && !vdev->rom_read_failed)) {
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);

switch (size) {
case 1:
data = buf.byte;
data = val.byte;
break;
case 2:
data = buf.word;
data = le16_to_cpu(val.word);
break;
case 4:
data = buf.dword;
data = le32_to_cpu(val.dword);
break;
default:
hw_error("vfio: unsupported read size, %d bytes", size);
hw_error("vfio: unsupported read size, %d bytes\n", size);
break;
}

Expand All @@ -1296,7 +1296,7 @@ static void vfio_rom_write(void *opaque, hwaddr addr,
static const MemoryRegionOps vfio_rom_ops = {
.read = vfio_rom_read,
.write = vfio_rom_write,
.endianness = DEVICE_NATIVE_ENDIAN,
.endianness = DEVICE_LITTLE_ENDIAN,
};

static bool vfio_blacklist_opt_rom(VFIODevice *vdev)
Expand Down

0 comments on commit ca976d1

Please sign in to comment.