From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) by dpdk.org (Postfix) with ESMTP id 3D78723C for ; Wed, 18 Jul 2018 12:47:43 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 18 Jul 2018 03:47:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,370,1526367600"; d="scan'208";a="65566260" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by FMSMGA003.fm.intel.com with ESMTP; 18 Jul 2018 03:47:41 -0700 Received: from fmsmsx102.amr.corp.intel.com (10.18.124.200) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Jul 2018 03:47:41 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX102.amr.corp.intel.com (10.18.124.200) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 18 Jul 2018 03:47:41 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.100]) by SHSMSX104.ccr.corp.intel.com ([169.254.5.81]) with mapi id 14.03.0319.002; Wed, 18 Jul 2018 18:47:39 +0800 From: "Wang, Zhihong" To: "Bie, Tiwei" , "maxime.coquelin@redhat.com" , "dev@dpdk.org" CC: "Wang, Yinan" , "Yao, Lei A" Thread-Topic: [PATCH] vhost: fix buffer length calculation Thread-Index: AQHUHc+w2ysx8ONDXky4eDSbaj8pEKSUzYFw Date: Wed, 18 Jul 2018 10:47:39 +0000 Message-ID: <8F6C2BD409508844A0EFC19955BE094151566EEE@SHSMSX103.ccr.corp.intel.com> References: <20180717131035.15635-1-tiwei.bie@intel.com> In-Reply-To: <20180717131035.15635-1-tiwei.bie@intel.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Subject: Re: [dpdk-dev] [PATCH] vhost: fix buffer length calculation X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 18 Jul 2018 10:47:44 -0000 > -----Original Message----- > From: Bie, Tiwei > Sent: Tuesday, July 17, 2018 9:11 PM > To: maxime.coquelin@redhat.com; Wang, Zhihong > ; dev@dpdk.org > Cc: Wang, Yinan ; Yao, Lei A > Subject: [PATCH] vhost: fix buffer length calculation >=20 > Fixes: fd68b4739d2c ("vhost: use buffer vectors in dequeue path") >=20 > Reported-by: Yinan Wang > Signed-off-by: Tiwei Bie > --- > lib/librte_vhost/virtio_net.c | 8 +++++--- > 1 file changed, 5 insertions(+), 3 deletions(-) >=20 > diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.= c > index 2b7ffcf92..07cc0c845 100644 > --- a/lib/librte_vhost/virtio_net.c > +++ b/lib/librte_vhost/virtio_net.c > @@ -720,7 +720,8 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct > vhost_virtqueue *vq, > uint16_t hdr_vec_idx =3D 0; >=20 > while (remain) { > - len =3D remain; > + len =3D RTE_MIN(remain, > + > buf_vec[hdr_vec_idx].buf_len); > dst =3D buf_vec[hdr_vec_idx].buf_addr; > rte_memcpy((void *)(uintptr_t)dst, > (void *)(uintptr_t)src, > @@ -747,7 +748,7 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct > vhost_virtqueue *vq, > hdr_addr =3D 0; > } >=20 > - cpy_len =3D RTE_MIN(buf_len, mbuf_avail); > + cpy_len =3D RTE_MIN(buf_avail, mbuf_avail); >=20 > if (likely(cpy_len > MAX_BATCH_LEN || > vq->batch_copy_nb_elems >=3D vq- > >size)) { > @@ -1112,7 +1113,8 @@ copy_desc_to_mbuf(struct virtio_net *dev, struct > vhost_virtqueue *vq, > * in a contiguous virtual area. > */ > while (remain) { > - len =3D remain; > + len =3D RTE_MIN(remain, > + buf_vec[hdr_vec_idx].buf_len); > src =3D buf_vec[hdr_vec_idx].buf_addr; > rte_memcpy((void *)(uintptr_t)dst, > (void *)(uintptr_t)src, len); > -- > 2.18.0 Acked-by: Zhihong Wang Thanks