From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45395) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZISV0-00011o-Ud for qemu-devel@nongnu.org; Thu, 23 Jul 2015 22:14:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZISUw-0004SH-9K for qemu-devel@nongnu.org; Thu, 23 Jul 2015 22:14:10 -0400 Received: from mx1.redhat.com ([209.132.183.28]:38306) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZISUw-0004SD-3X for qemu-devel@nongnu.org; Thu, 23 Jul 2015 22:14:06 -0400 Message-ID: <55B19F6A.8030900@redhat.com> Date: Fri, 24 Jul 2015 10:14:02 +0800 From: Jason Wang MIME-Version: 1.0 References: <1437674374-23285-1-git-send-email-mst@redhat.com> In-Reply-To: <1437674374-23285-1-git-send-email-mst@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH] virtio-9p: fix any_layout List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" , qemu-devel@nongnu.org Cc: "Aneesh Kumar K.V" On 07/24/2015 01:59 AM, Michael S. Tsirkin wrote: > virtio pci allows any device to have a modern interface, > this in turn requires ANY_LAYOUT support. > Fix up ANY_LAYOUT for virtio-9p. > > Reported-by: Jason Wang > Signed-off-by: Michael S. Tsirkin > --- > > Lightly tested. Looks correct. Reviewed-by: Jason Wang > > hw/9pfs/virtio-9p.c | 22 ++++++++++++++++------ > 1 file changed, 16 insertions(+), 6 deletions(-) > > diff --git a/hw/9pfs/virtio-9p.c b/hw/9pfs/virtio-9p.c > index 6ef8af3..7a3171f 100644 > --- a/hw/9pfs/virtio-9p.c > +++ b/hw/9pfs/virtio-9p.c > @@ -3261,16 +3261,26 @@ void handle_9p_output(VirtIODevice *vdev, VirtQueue *vq) > > while ((pdu = alloc_pdu(s)) && > (len = virtqueue_pop(vq, &pdu->elem)) != 0) { > - uint8_t *ptr; > + struct { > + uint32_t size_le; > + uint8_t id; > + uint16_t tag_le; > + } QEMU_PACKED out; > + int len; > + > pdu->s = s; > BUG_ON(pdu->elem.out_num == 0 || pdu->elem.in_num == 0); > - BUG_ON(pdu->elem.out_sg[0].iov_len < 7); > + QEMU_BUILD_BUG_ON(sizeof out != 7); > + > + len = iov_to_buf(pdu->elem.out_sg, pdu->elem.out_num, 0, > + &out, sizeof out); > + BUG_ON(len != sizeof out); > + > + pdu->size = le32_to_cpu(out.size_le); > > - ptr = pdu->elem.out_sg[0].iov_base; > + pdu->id = out.id; > + pdu->tag = le16_to_cpu(out.tag_le); > > - pdu->size = le32_to_cpu(*(uint32_t *)ptr); > - pdu->id = ptr[4]; > - pdu->tag = le16_to_cpu(*(uint16_t *)(ptr + 5)); > qemu_co_queue_init(&pdu->complete); > submit_pdu(s, pdu); > }