From: "Michael S. Tsirkin" <mst@redhat.com> To: linux-kernel@vger.kernel.org Cc: David Miller <davem@davemloft.net>, cornelia.huck@de.ibm.com, rusty@au1.ibm.com, nab@linux-iscsi.org, pbonzini@redhat.com, thuth@linux.vnet.ibm.com, dahi@linux.vnet.ibm.com, kvm@vger.kernel.org, virtualization@lists.linux-foundation.org, netdev@vger.kernel.org Subject: [PATCH v8 34/50] vhost/net: virtio 1.0 byte swap Date: Mon, 1 Dec 2014 18:05:34 +0200 [thread overview] Message-ID: <1417449619-24896-35-git-send-email-mst@redhat.com> (raw) In-Reply-To: <1417449619-24896-1-git-send-email-mst@redhat.com> I had to add an explicit tag to suppress compiler warning: gcc isn't smart enough to notice that len is always initialized since function is called with size > 0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> --- drivers/vhost/net.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index dce5c58..c218188 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -416,7 +416,7 @@ static void handle_tx(struct vhost_net *net) struct ubuf_info *ubuf; ubuf = nvq->ubuf_info + nvq->upend_idx; - vq->heads[nvq->upend_idx].id = head; + vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head); vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS; ubuf->callback = vhost_zerocopy_callback; ubuf->ctx = nvq->ubufs; @@ -500,6 +500,10 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, int headcount = 0; unsigned d; int r, nlogs = 0; + /* len is always initialized before use since we are always called with + * datalen > 0. + */ + u32 uninitialized_var(len); while (datalen > 0 && headcount < quota) { if (unlikely(seg >= UIO_MAXIOV)) { @@ -527,13 +531,14 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, nlogs += *log_num; log += *log_num; } - heads[headcount].id = d; - heads[headcount].len = iov_length(vq->iov + seg, in); - datalen -= heads[headcount].len; + heads[headcount].id = cpu_to_vhost32(vq, d); + len = iov_length(vq->iov + seg, in); + heads[headcount].len = cpu_to_vhost32(vq, len); + datalen -= len; ++headcount; seg += in; } - heads[headcount - 1].len += datalen; + heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen); *iovcount = seg; if (unlikely(log)) *log_num = nlogs; -- MST
WARNING: multiple messages have this Message-ID (diff)
From: "Michael S. Tsirkin" <mst@redhat.com> To: linux-kernel@vger.kernel.org Cc: thuth@linux.vnet.ibm.com, kvm@vger.kernel.org, rusty@au1.ibm.com, netdev@vger.kernel.org, virtualization@lists.linux-foundation.org, dahi@linux.vnet.ibm.com, pbonzini@redhat.com, David Miller <davem@davemloft.net> Subject: [PATCH v8 34/50] vhost/net: virtio 1.0 byte swap Date: Mon, 1 Dec 2014 18:05:34 +0200 [thread overview] Message-ID: <1417449619-24896-35-git-send-email-mst@redhat.com> (raw) In-Reply-To: <1417449619-24896-1-git-send-email-mst@redhat.com> I had to add an explicit tag to suppress compiler warning: gcc isn't smart enough to notice that len is always initialized since function is called with size > 0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> --- drivers/vhost/net.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index dce5c58..c218188 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c @@ -416,7 +416,7 @@ static void handle_tx(struct vhost_net *net) struct ubuf_info *ubuf; ubuf = nvq->ubuf_info + nvq->upend_idx; - vq->heads[nvq->upend_idx].id = head; + vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head); vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS; ubuf->callback = vhost_zerocopy_callback; ubuf->ctx = nvq->ubufs; @@ -500,6 +500,10 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, int headcount = 0; unsigned d; int r, nlogs = 0; + /* len is always initialized before use since we are always called with + * datalen > 0. + */ + u32 uninitialized_var(len); while (datalen > 0 && headcount < quota) { if (unlikely(seg >= UIO_MAXIOV)) { @@ -527,13 +531,14 @@ static int get_rx_bufs(struct vhost_virtqueue *vq, nlogs += *log_num; log += *log_num; } - heads[headcount].id = d; - heads[headcount].len = iov_length(vq->iov + seg, in); - datalen -= heads[headcount].len; + heads[headcount].id = cpu_to_vhost32(vq, d); + len = iov_length(vq->iov + seg, in); + heads[headcount].len = cpu_to_vhost32(vq, len); + datalen -= len; ++headcount; seg += in; } - heads[headcount - 1].len += datalen; + heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen); *iovcount = seg; if (unlikely(log)) *log_num = nlogs; -- MST
next prev parent reply other threads:[~2014-12-01 16:46 UTC|newest] Thread overview: 105+ messages / expand[flat|nested] mbox.gz Atom feed top 2014-12-01 16:02 [PATCH v8 00/50] linux: towards virtio-1 guest support Michael S. Tsirkin 2014-12-01 16:02 ` [PATCH v8 01/50] virtio: add low-level APIs for feature bits Michael S. Tsirkin 2014-12-01 16:02 ` Michael S. Tsirkin 2014-12-01 16:02 ` [PATCH v8 02/50] virtio: use u32, not bitmap for features Michael S. Tsirkin 2014-12-01 16:02 ` Michael S. Tsirkin 2014-12-01 16:02 ` [PATCH v8 03/50] mic_virtio: robust feature array size calculation Michael S. Tsirkin 2014-12-02 10:13 ` Thomas Huth 2014-12-01 16:03 ` [PATCH v8 04/50] virtio: add support for 64 bit features Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 05/50] virtio: assert 32 bit features in transports Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 06/50] virtio_ccw: add support for 64 bit features Michael S. Tsirkin 2014-12-02 11:14 ` Thomas Huth 2014-12-01 16:03 ` [PATCH v8 07/50] virtio: add virtio 1.0 feature bit Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 08/50] virtio: memory access APIs Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-03 0:48 ` Prabhakar Lad 2014-12-03 0:48 ` Prabhakar Lad 2014-12-01 16:03 ` [PATCH v8 09/50] virtio_ring: switch to new " Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 10/50] virtio_config: endian conversion for v1.0 Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 11/50] virtio: allow transports to get avail/used addresses Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 12/50] virtio: set FEATURES_OK Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 13/50] virtio: simplify feature bit handling Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:03 ` [PATCH v8 14/50] virtio: add legacy feature table support Michael S. Tsirkin 2014-12-01 16:03 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 15/50] virtio_net: v1.0 endianness Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 16/50] virtio_blk: v1.0 support Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 17/50] KVM: s390: Set virtio-ccw transport revision Michael S. Tsirkin 2014-12-04 16:10 ` Michael S. Tsirkin 2014-12-04 16:19 ` Cornelia Huck 2014-12-01 16:04 ` [PATCH v8 18/50] KVM: s390: virtio-ccw revision 1 SET_VQ Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 19/50] KVM: s390 allow virtio_ccw status writes to fail Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 20/50] KVM: s390: enable virtio-ccw revision 1 Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 21/50] virtio_blk: make serial attribute static Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 22/50] virtio_blk: fix race at module removal Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 23/50] virtio_net: pass vi around Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 24/50] virtio_net: get rid of virtio_net_hdr/skb_vnet_hdr Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 25/50] virtio_net: stricter short buffer length checks Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:04 ` [PATCH v8 26/50] virtio_net: bigger header when VERSION_1 is set Michael S. Tsirkin 2014-12-01 16:04 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 27/50] virtio_net: disable mac write for virtio 1.0 Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 28/50] virtio_net: enable v1.0 support Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 29/50] vhost: make features 64 bit Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 30/50] vhost: add memory access wrappers Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 31/50] vhost/net: force len for TX to host endian Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 32/50] vhost: switch to __get/__put_user exclusively Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 33/50] vhost: virtio 1.0 endian-ness support Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin [this message] 2014-12-01 16:05 ` [PATCH v8 34/50] vhost/net: virtio 1.0 byte swap Michael S. Tsirkin 2015-01-06 23:55 ` Alex Williamson 2015-01-06 23:55 ` Alex Williamson 2015-01-07 8:31 ` Greg Kurz 2015-01-07 8:31 ` Greg Kurz 2015-01-07 8:57 ` Michael S. Tsirkin 2015-01-07 8:57 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 35/50] vhost/net: larger header for virtio 1.0 Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 36/50] vhost/net: enable " Michael S. Tsirkin 2014-12-01 16:05 ` Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 37/50] tun: move internal flag defines out of uapi Michael S. Tsirkin 2014-12-01 16:05 ` [PATCH v8 38/50] tun: drop most type defines Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 39/50] tun: add VNET_LE flag Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 40/50] tun: TUN_VNET_LE support, fix sparse warnings for virtio headers Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 41/50] macvtap: TUN_VNET_LE support Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 42/50] virtio_scsi: v1.0 support Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 43/50] virtio_scsi: move to uapi Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 44/50] virtio_scsi: export to userspace Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 45/50] vhost/scsi: partial virtio 1.0 support Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 46/50] af_packet: virtio 1.0 stubs Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 47/50] virtio_console: virtio 1.0 support Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 48/50] virtio_balloon: add legacy_only flag Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 49/50] virtio: make VIRTIO_F_VERSION_1 a transport bit Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-01 16:06 ` [PATCH v8 50/50] virtio: drop VIRTIO_F_VERSION_1 from drivers Michael S. Tsirkin 2014-12-01 16:06 ` Michael S. Tsirkin 2014-12-08 8:58 ` [PATCH v8 00/50] linux: towards virtio-1 guest support Michael S. Tsirkin 2014-12-09 0:33 ` David Miller 2014-12-10 23:09 ` Rusty Russell 2014-12-10 19:14 ` Michael S. Tsirkin 2014-12-12 23:48 ` Nicholas A. Bellinger
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1417449619-24896-35-git-send-email-mst@redhat.com \ --to=mst@redhat.com \ --cc=cornelia.huck@de.ibm.com \ --cc=dahi@linux.vnet.ibm.com \ --cc=davem@davemloft.net \ --cc=kvm@vger.kernel.org \ --cc=linux-kernel@vger.kernel.org \ --cc=nab@linux-iscsi.org \ --cc=netdev@vger.kernel.org \ --cc=pbonzini@redhat.com \ --cc=rusty@au1.ibm.com \ --cc=thuth@linux.vnet.ibm.com \ --cc=virtualization@lists.linux-foundation.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.