* [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring
@ 2018-07-26 1:37 Tiwei Bie
2018-07-26 1:37 ` [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet Tiwei Bie
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Tiwei Bie @ 2018-07-26 1:37 UTC (permalink / raw)
To: maxime.coquelin, zhihong.wang, dev; +Cc: lei.a.yao
The shadow used ring's size is the same as the vq's size,
so we shouldn't try more than "vq size" times. Besides,
the element pointed by avail->idx isn't available to the
device, so we will return error when try "vq size" times.
Fixes: 24e4844048e1 ("vhost: unify Rx mergeable and non-mergeable paths")
Fixes: a922401f35cc ("vhost: add Rx support for packed ring")
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
lib/librte_vhost/virtio_net.c | 37 ++++++++++++++++-------------------
1 file changed, 17 insertions(+), 20 deletions(-)
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 5d4b97587..3b11b353c 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -415,13 +415,20 @@ reserve_avail_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
cur_idx = vq->last_avail_idx;
if (rxvq_is_mergeable(dev))
- max_tries = vq->size;
+ max_tries = vq->size - 1;
else
max_tries = 1;
while (size > 0) {
if (unlikely(cur_idx == avail_head))
return -1;
+ /*
+ * if we tried all available ring items, and still
+ * can't get enough buf, it means something abnormal
+ * happened.
+ */
+ if (unlikely(++tries > max_tries))
+ return -1;
if (unlikely(fill_vec_buf_split(dev, vq, cur_idx,
&vec_idx, buf_vec,
@@ -433,16 +440,7 @@ reserve_avail_buf_split(struct virtio_net *dev, struct vhost_virtqueue *vq,
size -= len;
cur_idx++;
- tries++;
*num_buffers += 1;
-
- /*
- * if we tried all available ring items, and still
- * can't get enough buf, it means something abnormal
- * happened.
- */
- if (unlikely(tries > max_tries))
- return -1;
}
*nr_vec = vec_idx;
@@ -582,11 +580,19 @@ reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
avail_idx = vq->last_avail_idx;
if (rxvq_is_mergeable(dev))
- max_tries = vq->size;
+ max_tries = vq->size - 1;
else
max_tries = 1;
while (size > 0) {
+ /*
+ * if we tried all available ring items, and still
+ * can't get enough buf, it means something abnormal
+ * happened.
+ */
+ if (unlikely(++tries > max_tries))
+ return -1;
+
if (unlikely(fill_vec_buf_packed(dev, vq,
avail_idx, &desc_count,
buf_vec, &vec_idx,
@@ -603,16 +609,7 @@ reserve_avail_buf_packed(struct virtio_net *dev, struct vhost_virtqueue *vq,
avail_idx -= vq->size;
*nr_descs += desc_count;
- tries++;
*num_buffers += 1;
-
- /*
- * if we tried all available ring items, and still
- * can't get enough buf, it means something abnormal
- * happened.
- */
- if (unlikely(tries > max_tries))
- return -1;
}
*nr_vec = vec_idx;
--
2.18.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet
2018-07-26 1:37 [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Tiwei Bie
@ 2018-07-26 1:37 ` Tiwei Bie
2018-07-26 7:22 ` Jens Freimann
2018-07-26 7:33 ` [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Jens Freimann
2018-07-26 9:00 ` Tiwei Bie
2 siblings, 1 reply; 5+ messages in thread
From: Tiwei Bie @ 2018-07-26 1:37 UTC (permalink / raw)
To: maxime.coquelin, zhihong.wang, dev; +Cc: lei.a.yao, stable
Fixes: eefac9536a90 ("vhost: postpone device creation until rings are mapped")
Cc: stable@dpdk.org
Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
---
lib/librte_vhost/virtio_net.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
index 3b11b353c..b02651275 100644
--- a/lib/librte_vhost/virtio_net.c
+++ b/lib/librte_vhost/virtio_net.c
@@ -1626,7 +1626,8 @@ rte_vhost_dequeue_burst(int vid, uint16_t queue_id,
if (rarp_mbuf == NULL) {
RTE_LOG(ERR, VHOST_DATA,
"Failed to make RARP packet.\n");
- return 0;
+ count = 0;
+ goto out;
}
count -= 1;
}
--
2.18.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet
2018-07-26 1:37 ` [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet Tiwei Bie
@ 2018-07-26 7:22 ` Jens Freimann
0 siblings, 0 replies; 5+ messages in thread
From: Jens Freimann @ 2018-07-26 7:22 UTC (permalink / raw)
To: Tiwei Bie; +Cc: maxime.coquelin, zhihong.wang, dev, lei.a.yao, stable
On Thu, Jul 26, 2018 at 09:37:21AM +0800, Tiwei Bie wrote:
>Fixes: eefac9536a90 ("vhost: postpone device creation until rings are mapped")
>Cc: stable@dpdk.org
>
>Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
>---
> lib/librte_vhost/virtio_net.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
Reviewed-by: Jens Freimann <jfreimann@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring
2018-07-26 1:37 [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Tiwei Bie
2018-07-26 1:37 ` [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet Tiwei Bie
@ 2018-07-26 7:33 ` Jens Freimann
2018-07-26 9:00 ` Tiwei Bie
2 siblings, 0 replies; 5+ messages in thread
From: Jens Freimann @ 2018-07-26 7:33 UTC (permalink / raw)
To: Tiwei Bie; +Cc: maxime.coquelin, zhihong.wang, dev, lei.a.yao
On Thu, Jul 26, 2018 at 09:37:20AM +0800, Tiwei Bie wrote:
>The shadow used ring's size is the same as the vq's size,
>so we shouldn't try more than "vq size" times. Besides,
>the element pointed by avail->idx isn't available to the
>device, so we will return error when try "vq size" times.
>
>Fixes: 24e4844048e1 ("vhost: unify Rx mergeable and non-mergeable paths")
>Fixes: a922401f35cc ("vhost: add Rx support for packed ring")
>
>Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
>---
> lib/librte_vhost/virtio_net.c | 37 ++++++++++++++++-------------------
> 1 file changed, 17 insertions(+), 20 deletions(-)
>
Reviewed-by: Jens Freimann <jfreiman@redhat.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring
2018-07-26 1:37 [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Tiwei Bie
2018-07-26 1:37 ` [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet Tiwei Bie
2018-07-26 7:33 ` [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Jens Freimann
@ 2018-07-26 9:00 ` Tiwei Bie
2 siblings, 0 replies; 5+ messages in thread
From: Tiwei Bie @ 2018-07-26 9:00 UTC (permalink / raw)
To: maxime.coquelin, zhihong.wang, dev; +Cc: lei.a.yao
On Thu, Jul 26, 2018 at 09:37:20AM +0800, Tiwei Bie wrote:
> The shadow used ring's size is the same as the vq's size,
> so we shouldn't try more than "vq size" times. Besides,
> the element pointed by avail->idx isn't available to the
> device, so we will return error when try "vq size" times.
>
> Fixes: 24e4844048e1 ("vhost: unify Rx mergeable and non-mergeable paths")
> Fixes: a922401f35cc ("vhost: add Rx support for packed ring")
>
> Signed-off-by: Tiwei Bie <tiwei.bie@intel.com>
Series applied to dpdk-next-virtio/master.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2018-07-26 9:00 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-26 1:37 [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Tiwei Bie
2018-07-26 1:37 ` [dpdk-dev] [PATCH 2/2] vhost: release the locks when failed to make RARP packet Tiwei Bie
2018-07-26 7:22 ` Jens Freimann
2018-07-26 7:33 ` [dpdk-dev] [PATCH 1/2] vhost: fix overflow on shadow used ring Jens Freimann
2018-07-26 9:00 ` Tiwei Bie
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).