From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39069) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZCSAT-0004uY-M5 for qemu-devel@nongnu.org; Tue, 07 Jul 2015 08:40:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZCSAS-00038D-T1 for qemu-devel@nongnu.org; Tue, 07 Jul 2015 08:40:09 -0400 Date: Tue, 7 Jul 2015 15:40:03 +0300 From: "Michael S. Tsirkin" Message-ID: <1436272760-29611-2-git-send-email-mst@redhat.com> References: <1436272760-29611-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1436272760-29611-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 01/13] dataplane: fix cross-endian issues List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Cornelia Huck , Peter Maydell , qemu-block@nongnu.org, Stefan Hajnoczi , Greg Kurz From: Greg Kurz 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 3589185..bed9b11 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; -- MST