diff options
| -rw-r--r-- | hw/misc/vfio.c | 24 | ||||
| -rw-r--r-- | include/hw/virtio/virtio_ring.h | 4 | ||||
| -rw-r--r-- | slirp/udp.c | 2 |
3 files changed, 15 insertions, 15 deletions
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c index 40dcaa6558..d66f3d2425 100644 --- a/hw/misc/vfio.c +++ b/hw/misc/vfio.c @@ -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); @@ -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); @@ -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) @@ -1255,7 +1255,7 @@ 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 */ @@ -1263,21 +1263,21 @@ static uint64_t vfio_rom_read(void *opaque, hwaddr addr, unsigned size) 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; } @@ -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) diff --git a/include/hw/virtio/virtio_ring.h b/include/hw/virtio/virtio_ring.h index 8f58bc975e..0b42e6eae5 100644 --- a/include/hw/virtio/virtio_ring.h +++ b/include/hw/virtio/virtio_ring.h @@ -139,8 +139,8 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p, vr->num = num; vr->desc = p; vr->avail = p + num*sizeof(struct vring_desc); - vr->used = (void *)(((unsigned long)&vr->avail->ring[num] + sizeof(uint16_t) - + align-1) & ~(align - 1)); + vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(uint16_t) + + align - 1) & ~(align - 1)); } static inline unsigned vring_size(unsigned int num, unsigned long align) diff --git a/slirp/udp.c b/slirp/udp.c index 8cc6cb66da..f77e00f5a0 100644 --- a/slirp/udp.c +++ b/slirp/udp.c @@ -152,7 +152,7 @@ udp_input(register struct mbuf *m, int iphlen) * Locate pcb for datagram. */ so = slirp->udp_last_so; - if (so->so_lport != uh->uh_sport || + if (so == &slirp->udb || so->so_lport != uh->uh_sport || so->so_laddr.s_addr != ip->ip_src.s_addr) { struct socket *tmp; |