[v1] vhost: add vq status check in async enqueue poll
Checks
Commit Message
From: Patrick Fu <patrick.fu@intel.com>
Vring should not be touched if vq is disabled. This patch adds the vq
status check in async enqueue polling to avoid accessing to a disabled
queue.
Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
Signed-off-by: Patrick Fu <patrick.fu@intel.com>
---
lib/librte_vhost/virtio_net.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
Comments
> -----Original Message-----
> From: Fu, Patrick <patrick.fu@intel.com>
> Sent: Thursday, July 16, 2020 11:30 PM
> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
> <chenbo.xia@intel.com>
> Cc: Fu, Patrick <patrick.fu@intel.com>
> Subject: [PATCH v1] vhost: add vq status check in async enqueue poll
>
> From: Patrick Fu <patrick.fu@intel.com>
>
> Vring should not be touched if vq is disabled. This patch adds the vq status check
> in async enqueue polling to avoid accessing to a disabled queue.
>
> Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
>
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
> lib/librte_vhost/virtio_net.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index
> 1d0be3dd4..b197d76d3 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -1686,9 +1686,11 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid,
> uint16_t queue_id,
>
> if (n_pkts_put) {
> vq->async_pkts_inflight_n -= n_pkts_put;
> - __atomic_add_fetch(&vq->used->idx, n_descs,
> __ATOMIC_RELEASE);
> -
> - vhost_vring_call_split(dev, vq);
> + if (likely(vq->enabled && vq->access_ok)) {
> + __atomic_add_fetch(&vq->used->idx,
> + n_descs, __ATOMIC_RELEASE);
> + vhost_vring_call_split(dev, vq);
> + }
> }
>
> if (start_idx + n_pkts_put <= vq_size) {
> --
> 2.18.4
Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
On 7/17/2020 9:09 AM, Xia, Chenbo wrote:
>
>> -----Original Message-----
>> From: Fu, Patrick <patrick.fu@intel.com>
>> Sent: Thursday, July 16, 2020 11:30 PM
>> To: dev@dpdk.org; maxime.coquelin@redhat.com; Xia, Chenbo
>> <chenbo.xia@intel.com>
>> Cc: Fu, Patrick <patrick.fu@intel.com>
>> Subject: [PATCH v1] vhost: add vq status check in async enqueue poll
>>
>> From: Patrick Fu <patrick.fu@intel.com>
>
> Reviewed-by: Chenbo Xia <chenbo.xia@intel.com>
>
Applied to dpdk-next-net/master, thanks.
What about this commit title?
vhost: fix missing virtqueue status check in async path
On 7/16/20 5:30 PM, patrick.fu@intel.com wrote:
> From: Patrick Fu <patrick.fu@intel.com>
>
> Vring should not be touched if vq is disabled. This patch adds the vq
> status check in async enqueue polling to avoid accessing to a disabled
> queue.
>
> Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
>
> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> ---
> lib/librte_vhost/virtio_net.c | 8 +++++---
> 1 file changed, 5 insertions(+), 3 deletions(-)
>
> diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c
> index 1d0be3dd4..b197d76d3 100644
> --- a/lib/librte_vhost/virtio_net.c
> +++ b/lib/librte_vhost/virtio_net.c
> @@ -1686,9 +1686,11 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
>
> if (n_pkts_put) {
> vq->async_pkts_inflight_n -= n_pkts_put;
> - __atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE);
> -
> - vhost_vring_call_split(dev, vq);
> + if (likely(vq->enabled && vq->access_ok)) {
> + __atomic_add_fetch(&vq->used->idx,
> + n_descs, __ATOMIC_RELEASE);
> + vhost_vring_call_split(dev, vq);
> + }
> }
>
> if (start_idx + n_pkts_put <= vq_size) {
>
On 7/20/2020 4:57 PM, Maxime Coquelin wrote:
> What about this commit title?
> vhost: fix missing virtqueue status check in async path
Existing commit dropped from next-net and patchwork status updated.
>
> On 7/16/20 5:30 PM, patrick.fu@intel.com wrote:
>> From: Patrick Fu <patrick.fu@intel.com>
>>
>> Vring should not be touched if vq is disabled. This patch adds the vq
>> status check in async enqueue polling to avoid accessing to a disabled
>> queue.
>>
>> Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
>>
>> Signed-off-by: Patrick Fu <patrick.fu@intel.com>
<...>
V2 patch sent with revised title
> -----Original Message-----
> From: Maxime Coquelin <maxime.coquelin@redhat.com>
> Sent: Monday, July 20, 2020 11:58 PM
> To: Fu, Patrick <patrick.fu@intel.com>; dev@dpdk.org; Xia, Chenbo
> <chenbo.xia@intel.com>
> Subject: Re: [PATCH v1] vhost: add vq status check in async enqueue poll
>
> What about this commit title?
> vhost: fix missing virtqueue status check in async path
>
> On 7/16/20 5:30 PM, patrick.fu@intel.com wrote:
> > From: Patrick Fu <patrick.fu@intel.com>
> >
> > Vring should not be touched if vq is disabled. This patch adds the vq
> > status check in async enqueue polling to avoid accessing to a disabled
> > queue.
> >
> > Fixes: cd6760da1076 ("vhost: introduce async enqueue for split ring")
> >
> > Signed-off-by: Patrick Fu <patrick.fu@intel.com>
> > ---
> > lib/librte_vhost/virtio_net.c | 8 +++++---
> > 1 file changed, 5 insertions(+), 3 deletions(-)
> >
> > diff --git a/lib/librte_vhost/virtio_net.c
> > b/lib/librte_vhost/virtio_net.c index 1d0be3dd4..b197d76d3 100644
> > --- a/lib/librte_vhost/virtio_net.c
> > +++ b/lib/librte_vhost/virtio_net.c
> > @@ -1686,9 +1686,11 @@ uint16_t
> rte_vhost_poll_enqueue_completed(int
> > vid, uint16_t queue_id,
> >
> > if (n_pkts_put) {
> > vq->async_pkts_inflight_n -= n_pkts_put;
> > - __atomic_add_fetch(&vq->used->idx, n_descs,
> __ATOMIC_RELEASE);
> > -
> > - vhost_vring_call_split(dev, vq);
> > + if (likely(vq->enabled && vq->access_ok)) {
> > + __atomic_add_fetch(&vq->used->idx,
> > + n_descs, __ATOMIC_RELEASE);
> > + vhost_vring_call_split(dev, vq);
> > + }
> > }
> >
> > if (start_idx + n_pkts_put <= vq_size) {
> >
@@ -1686,9 +1686,11 @@ uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,
if (n_pkts_put) {
vq->async_pkts_inflight_n -= n_pkts_put;
- __atomic_add_fetch(&vq->used->idx, n_descs, __ATOMIC_RELEASE);
-
- vhost_vring_call_split(dev, vq);
+ if (likely(vq->enabled && vq->access_ok)) {
+ __atomic_add_fetch(&vq->used->idx,
+ n_descs, __ATOMIC_RELEASE);
+ vhost_vring_call_split(dev, vq);
+ }
}
if (start_idx + n_pkts_put <= vq_size) {