From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753209AbbBCJHV (ORCPT ); Tue, 3 Feb 2015 04:07:21 -0500 Received: from mx1.redhat.com ([209.132.183.28]:60424 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751133AbbBCJHS (ORCPT ); Tue, 3 Feb 2015 04:07:18 -0500 Date: Tue, 3 Feb 2015 11:07:06 +0200 From: "Michael S. Tsirkin" To: linux-kernel@vger.kernel.org Cc: kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org, viro@ZenIV.linux.org.uk, David Miller , cornelia.huck@de.ibm.com, rusty@rustcorp.com.au Subject: [PATCH for-3.19] vhost/net: fix up num_buffers endian-ness Message-ID: <1422896842-19186-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Mutt-Fcc: =sent Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In virtio 1.0 mode, when mergeable buffers are enabled on a big-endian host, num_buffers wasn't byte-swapped correctly, so large incoming packets got corrupted. To fix, fill it in within hdr - this also makes sure it gets the correct type. Signed-off-by: Michael S. Tsirkin --- It seems important to get this into 3.19, otherwise VIRTIO_1 feature bit is unreliable. Dave, do you plan another pull request for 3.19? If yes pls merge this, if not pls let me know and I'll try to send it to Linus directly. drivers/vhost/net.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index d415d69..9484d56 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -650,8 +650,10 @@ static void handle_rx(struct vhost_net *net) break; } /* TODO: Should check and handle checksum. */ + + hdr.num_buffers = cpu_to_vhost16(vq, headcount); if (likely(mergeable) && - memcpy_toiovecend(nvq->hdr, (unsigned char *)&headcount, + memcpy_toiovecend(nvq->hdr, (void *)&hdr.num_buffers, offsetof(typeof(hdr), num_buffers), sizeof hdr.num_buffers)) { vq_err(vq, "Failed num_buffers write"); -- MST