patch 'vhost: fix missing lock protection in power monitor API' has been queued to stable release 22.11.4

Xueming Li xuemingl at nvidia.com
Mon Dec 11 11:10:36 CET 2023


Hi,

FYI, your patch has been queued to stable release 22.11.4

Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet.
It will be pushed if I get no objections before 12/13/23. So please
shout if anyone has objections.

Also note that after the patch there's a diff of the upstream commit vs the
patch applied to the branch. This will indicate if there was any rebasing
needed to apply to the stable branch. If there were code changes for rebasing
(ie: not only metadata diffs), please double check that the rebase was
correctly done.

Queued patches are on a temporary branch at:
https://git.dpdk.org/dpdk-stable/log/?h=22.11-staging

This queued commit can be viewed at:
https://git.dpdk.org/dpdk-stable/commit/?h=22.11-staging&id=a07736eb68dab3ea52e189b07a71d77e92abb65f

Thanks.

Xueming Li <xuemingl at nvidia.com>

---
>From a07736eb68dab3ea52e189b07a71d77e92abb65f Mon Sep 17 00:00:00 2001
From: Maxime Coquelin <maxime.coquelin at redhat.com>
Date: Fri, 20 Oct 2023 10:48:03 +0200
Subject: [PATCH] vhost: fix missing lock protection in power monitor API
Cc: Xueming Li <xuemingl at nvidia.com>

[ upstream commit b4c4e5675c85a9b471c252305811d15f6a6d2aa6 ]

The power monitor get API is missing both access lock
protection and access status check.

Fixes: 34fd4373ce76 ("vhost: add power monitor API")

Signed-off-by: Maxime Coquelin <maxime.coquelin at redhat.com>
Acked-by: David Marchand <david.marchand at redhat.com>
---
 lib/vhost/vhost.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c
index 4edb76d0dd..6e1bba4391 100644
--- a/lib/vhost/vhost.c
+++ b/lib/vhost/vhost.c
@@ -2070,6 +2070,12 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
 	if (vq == NULL)
 		return -1;
 
+	if (!rte_spinlock_trylock(&vq->access_lock))
+		return -1;
+
+	if (unlikely(!vq->access_ok))
+		goto out_unlock;
+
 	if (vq_is_packed(dev)) {
 		struct vring_packed_desc *desc;
 		desc = vq->desc_packed;
@@ -2090,6 +2096,11 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
 	}
 
 	return 0;
+
+out_unlock:
+	rte_spinlock_unlock(&vq->access_lock);
+
+	return -1;
 }
 
 
@@ -2157,6 +2168,7 @@ int rte_vhost_vring_stats_reset(int vid, uint16_t queue_id)
 {
 	struct virtio_net *dev = get_device(vid);
 	struct vhost_virtqueue *vq;
+	int ret = 0;
 
 	if (dev == NULL)
 		return -1;
-- 
2.25.1

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2023-12-11 17:56:23.597356200 +0800
+++ 0011-vhost-fix-missing-lock-protection-in-power-monitor-A.patch	2023-12-11 17:56:22.887652300 +0800
@@ -1 +1 @@
-From b4c4e5675c85a9b471c252305811d15f6a6d2aa6 Mon Sep 17 00:00:00 2001
+From a07736eb68dab3ea52e189b07a71d77e92abb65f Mon Sep 17 00:00:00 2001
@@ -4,0 +5,3 @@
+Cc: Xueming Li <xuemingl at nvidia.com>
+
+[ upstream commit b4c4e5675c85a9b471c252305811d15f6a6d2aa6 ]
@@ -10 +12,0 @@
-Cc: stable at dpdk.org
@@ -15,2 +17,2 @@
- lib/vhost/vhost.c | 13 ++++++++++++-
- 1 file changed, 12 insertions(+), 1 deletion(-)
+ lib/vhost/vhost.c | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
@@ -19 +21 @@
-index f86516324b..9a7403c28d 100644
+index 4edb76d0dd..6e1bba4391 100644
@@ -22,9 +24 @@
-@@ -2123,6 +2123,7 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
- {
- 	struct virtio_net *dev = get_device(vid);
- 	struct vhost_virtqueue *vq;
-+	int ret = 0;
- 
- 	if (dev == NULL)
- 		return -1;
-@@ -2133,6 +2134,13 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
+@@ -2070,6 +2070,12 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
@@ -34 +28,2 @@
-+	rte_rwlock_read_lock(&vq->access_lock);
++	if (!rte_spinlock_trylock(&vq->access_lock))
++		return -1;
@@ -36,2 +31 @@
-+	if (unlikely(!vq->access_ok)) {
-+		ret = -1;
++	if (unlikely(!vq->access_ok))
@@ -39 +32,0 @@
-+	}
@@ -44,2 +37 @@
-@@ -2152,7 +2160,10 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
- 		pmc->match = 0;
+@@ -2090,6 +2096,11 @@ rte_vhost_get_monitor_addr(int vid, uint16_t queue_id,
@@ -48 +40,2 @@
--	return 0;
+ 	return 0;
++
@@ -50 +43 @@
-+	rte_rwlock_read_unlock(&vq->access_lock);
++	rte_spinlock_unlock(&vq->access_lock);
@@ -52 +45 @@
-+	return ret;
++	return -1;
@@ -55,0 +49,8 @@
+@@ -2157,6 +2168,7 @@ int rte_vhost_vring_stats_reset(int vid, uint16_t queue_id)
+ {
+ 	struct virtio_net *dev = get_device(vid);
+ 	struct vhost_virtqueue *vq;
++	int ret = 0;
+ 
+ 	if (dev == NULL)
+ 		return -1;


More information about the stable mailing list