From be1e50a27d5b6845729ae0854f57f3816cf47edb Mon Sep 17 00:00:00 2001 From: Greg Kurz Date: Fri, 26 Jun 2015 09:32:28 +0200 Subject: [PATCH] dataplane: fix cross-endian issues Accesses to vring_avail_event and vring_used_event must honor the queue endianness. This patch allows cross-endian setups to use dataplane (tested with ppc64 on ppc64le, and vice-versa). Suggested-by: Cornelia Huck Signed-off-by: Greg Kurz Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Cornelia Huck --- hw/virtio/dataplane/vring.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c index 35891856ee..bed9b11c31 100644 --- a/hw/virtio/dataplane/vring.c +++ b/hw/virtio/dataplane/vring.c @@ -153,7 +153,8 @@ bool vring_should_notify(VirtIODevice *vdev, Vring *vring) return true; } - return vring_need_event(vring_used_event(&vring->vr), new, old); + return vring_need_event(virtio_tswap16(vdev, vring_used_event(&vring->vr)), + new, old); } @@ -407,7 +408,8 @@ int vring_pop(VirtIODevice *vdev, Vring *vring, /* On success, increment avail index. */ vring->last_avail_idx++; if (virtio_has_feature(vdev, VIRTIO_RING_F_EVENT_IDX)) { - vring_avail_event(&vring->vr) = vring->last_avail_idx; + vring_avail_event(&vring->vr) = + virtio_tswap16(vdev, vring->last_avail_idx); } return head;