Skip to contentSkip to conversation

vhost: add vq status check in async enqueue poll

PATCH Applied [email protected] 4 participants 9 messages Jul 16, 2020 – Jul 21, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 vhost: add vq status check in async enqueue poll

From: Patrick Fu <[email protected]>

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")
---
 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/librte_vhost/virtio_net.c +5 -3
index 1d0be3dd4..b197d76d3 100644
@@ -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) {
Signature · 1 line
2.18.4
Reviewed-by on v1 1/1
#1 lore raw
Quoted 41 lines

-----Original Message-----
From: Fu, Patrick <[email protected]>
Sent: Thursday, July 16, 2020 11:30 PM
To: [email protected]; [email protected]; Xia, Chenbo <[email protected]>
Cc: Fu, Patrick <[email protected]>
Subject: [PATCH v1] vhost: add vq status check in async enqueue poll

From: Patrick Fu <[email protected]>

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")
---
 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/librte_vhost/virtio_net.c index renamed from lib/librte_vhost/virtio_net.c +0 -0

1d0be3dd4..b197d76d3 100644

lib/librte_vhost/virtio_net.c +5 -3
@@ -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);
+		}
 	}
Quoted 3 lines

if (start_idx + n_pkts_put <= vq_size) {
--
2.18.4

Applied
#2 lore raw
Quoted 9 lines · Chenbo
Quoted 9 lines

-----Original Message-----
From: Fu, Patrick <[email protected]>
Sent: Thursday, July 16, 2020 11:30 PM
To: [email protected]; [email protected]; Xia, Chenbo <[email protected]>
Cc: Fu, Patrick <[email protected]>
Subject: [PATCH v1] vhost: add vq status check in async enqueue poll

Quoted 4 lines
Quoted 1 line

From: Patrick Fu <[email protected]>

Applied to dpdk-next-net/master, thanks.

#3 lore raw
In reply to [email protected]

What about this commit title?
vhost: fix missing virtqueue status check in async path

Quoted 33 lines · On 7/16/20 5:30 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

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")
---
 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/librte_vhost/virtio_net.c +5 -3
index 1d0be3dd4..b197d76d3 100644
@@ -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) {
#4 lore raw
Quoted 2 lines · Maxime Coquelin

What about this commit title?
vhost: fix missing virtqueue status check in async path

Existing commit dropped from next-net and patchwork status updated.

Quoted 11 lines · On 7/16/20 5:30 PM, [email protected] wrote:
Quoted 9 lines

From: Patrick Fu <[email protected]>

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")

<...>

#5 lore raw
In reply to Maxime Coquelin

V2 patch sent with revised title

Quoted 47 lines

-----Original Message-----
From: Maxime Coquelin <[email protected]>
Sent: Monday, July 20, 2020 11:58 PM
To: Fu, Patrick <[email protected]>; [email protected]; Xia, Chenbo <[email protected]>
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

lib/librte_vhost/virtio_net.c uint16_t

Quoted 18 lines · On 7/16/20 5:30 PM, [email protected] wrote:

From: Patrick Fu <[email protected]>

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")
---
 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
(quoted diff) +0 -0

b/lib/librte_vhost/virtio_net.c index 1d0be3dd4..b197d76d3 100644

lib/librte_vhost/virtio_net.c +0 -0
@@ -1686,9 +1686,11 @@ uint16_t

rte_vhost_poll_enqueue_completed(int

lib/librte_vhost/virtio_net.c uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id,

Quoted 5 lines
lib/librte_vhost/virtio_net.c +0 -1
 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);

Quoted 11 lines
lib/librte_vhost/virtio_net.c +5 -2
-
-		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) {

#6 lore raw

PATCH v2 1/1 vhost: fix missing virtqueue status check in async path

In reply to [email protected]

From: Patrick Fu <[email protected]>

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")

---
v2:
revise commit title

 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/librte_vhost/virtio_net.c +5 -3
index 1d0be3dd4..b197d76d3 100644
@@ -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) {
Signature · 1 line
2.18.4
Reviewed-by on v2 1/1
#7 lore raw

Re: [dpdk-dev] [PATCH v2] vhost: fix missing virtqueue status check in async path

Quoted 26 lines · On 7/21/20 5:35 AM, [email protected] wrote:

From: Patrick Fu <[email protected]>

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")

---
v2:
revise commit title

 lib/librte_vhost/virtio_net.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
lib/librte_vhost/virtio_net.c +0 -1
index 1d0be3dd4..b197d76d3 100644
@@ -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);

lib/librte_vhost/virtio_net.c uint16_t rte_vhost_poll_enqueue_completed(int vid, uint16_t queue_id, · line 1696

Quoted 10 lines
lib/librte_vhost/virtio_net.c +5 -2
-
-		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) {

Thanks,
Maxime

Applied
#8 lore raw

Re: [dpdk-dev] [PATCH v2] vhost: fix missing virtqueue status check in async path

Quoted 9 lines · Maxime Coquelin
Quoted 6 lines · On 7/21/20 5:35 AM, [email protected] wrote:

From: Patrick Fu <[email protected]>

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.

Quoted 6 lines
Quoted 3 lines
Fixes cd6760da1076 ("vhost: introduce async enqueue for split ring")

Applied to dpdk-next-net/master, thanks.