From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZClrE-0001tA-J5 for qemu-devel@nongnu.org; Wed, 08 Jul 2015 05:41:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZClrA-0003rj-Jv for qemu-devel@nongnu.org; Wed, 08 Jul 2015 05:41:36 -0400 Date: Wed, 8 Jul 2015 12:41:26 +0300 From: "Michael S. Tsirkin" Message-ID: <1436348444-907-2-git-send-email-mst@redhat.com> References: <1436348444-907-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1436348444-907-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL v2 01/16] 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