[dpdk-stable] patch 'vhost: fix vring address handling during live migration' has been queued to LTS release 18.11.6

Kevin Traynor ktraynor at redhat.com
Tue Dec 3 19:26:16 CET 2019


Hi,

FYI, your patch has been queued to LTS release 18.11.6

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/10/19. 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://github.com/kevintraynor/dpdk-stable-queue

This queued commit can be viewed at:
https://github.com/kevintraynor/dpdk-stable-queue/commit/9e564f00737fd16e042c1a68a8ddd5b3d4eb88fa

Thanks.

Kevin.

---
>From 9e564f00737fd16e042c1a68a8ddd5b3d4eb88fa Mon Sep 17 00:00:00 2001
From: Tiwei Bie <tiwei.bie at intel.com>
Date: Mon, 19 Aug 2019 19:34:56 +0800
Subject: [PATCH] vhost: fix vring address handling during live migration

[ upstream commit 72d002b3ebda4686306cc5124b7a8bdf627dba0a ]

When live migration starts, QEMU will set ring addrs again for
each virtqueue. In this case, we should try to translate ring
addrs after we invalidating the ring, otherwise virtqueues can
be enabled with the addrs untranslated. Besides, also leverage
the access_ok flag in non-IOMMU case to prevent the data path
accessing invalidated virtqueues.

Fixes: 5a4933e56be4 ("vhost: postpone ring address translations at kick time only")

Reported-by: Yilong Lv <lvyilong.lyl at alibaba-inc.com>
Signed-off-by: Tiwei Bie <tiwei.bie at intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin at redhat.com>
---
 lib/librte_vhost/vhost.c      |  3 +--
 lib/librte_vhost/vhost_user.c | 12 ++++++++++--
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
index 488cf1694..0b5ee0307 100644
--- a/lib/librte_vhost/vhost.c
+++ b/lib/librte_vhost/vhost.c
@@ -195,5 +195,5 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
 
 	if (!(dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)))
-		goto out;
+		return -1;
 
 	if (vq_is_packed(dev)) {
@@ -204,5 +204,4 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
 			return -1;
 	}
-out:
 	vq->access_ok = 1;
 
diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 15688ded5..bb74d0b93 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -678,4 +678,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
 		}
 
+		vq->access_ok = 1;
 		return dev;
 	}
@@ -736,4 +737,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
 
 	vq->log_guest_addr = addr->log_guest_addr;
+	vq->access_ok = 1;
 
 	VHOST_LOG_DEBUG(VHOST_CONFIG, "(%d) mapped address desc: %p\n",
@@ -760,4 +762,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
 	struct vhost_virtqueue *vq;
 	struct vhost_vring_addr *addr = &msg->payload.addr;
+	bool access_ok;
 
 	if (validate_msg_fds(msg, 0) != 0)
@@ -770,4 +773,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
 	vq = dev->virtqueue[msg->payload.addr.index];
 
+	access_ok = vq->access_ok;
+
 	/*
 	 * Rings addresses should not be interpreted as long as the ring is not
@@ -778,6 +783,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
 	vring_invalidate(dev, vq);
 
-	if (vq->enabled && (dev->features &
-				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) {
+	if ((vq->enabled && (dev->features &
+				(1ULL << VHOST_USER_F_PROTOCOL_FEATURES))) ||
+			access_ok) {
 		dev = translate_ring_addresses(dev, msg->payload.addr.index);
 		if (!dev)
@@ -1412,4 +1418,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
 	msg->fd_num = 0;
 
+	vring_invalidate(dev, vq);
+
 	return VH_RESULT_REPLY;
 }
-- 
2.21.0

---
  Diff of the applied patch vs upstream commit (please double-check if non-empty:
---
--- -	2019-12-03 17:29:52.229861657 +0000
+++ 0007-vhost-fix-vring-address-handling-during-live-migrati.patch	2019-12-03 17:29:51.701750973 +0000
@@ -1 +1 @@
-From 72d002b3ebda4686306cc5124b7a8bdf627dba0a Mon Sep 17 00:00:00 2001
+From 9e564f00737fd16e042c1a68a8ddd5b3d4eb88fa Mon Sep 17 00:00:00 2001
@@ -5,0 +6,2 @@
+[ upstream commit 72d002b3ebda4686306cc5124b7a8bdf627dba0a ]
+
@@ -14 +15,0 @@
-Cc: stable at dpdk.org
@@ -25 +26 @@
-index 981837b5d..77be16069 100644
+index 488cf1694..0b5ee0307 100644
@@ -28 +29 @@
-@@ -359,5 +359,5 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
+@@ -195,5 +195,5 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
@@ -35 +36 @@
-@@ -368,5 +368,4 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
+@@ -204,5 +204,4 @@ vring_translate(struct virtio_net *dev, struct vhost_virtqueue *vq)
@@ -42 +43 @@
-index e4ae027a0..3d2db6edf 100644
+index 15688ded5..bb74d0b93 100644
@@ -45 +46 @@
-@@ -623,4 +623,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
+@@ -678,4 +678,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
@@ -51 +52 @@
-@@ -681,4 +682,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
+@@ -736,4 +737,5 @@ translate_ring_addresses(struct virtio_net *dev, int vq_index)
@@ -57 +58 @@
-@@ -705,4 +707,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
+@@ -760,4 +762,5 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
@@ -62,2 +63,2 @@
- 	if (dev->mem == NULL)
-@@ -712,4 +715,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
+ 	if (validate_msg_fds(msg, 0) != 0)
+@@ -770,4 +773,6 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
@@ -70 +71 @@
-@@ -720,6 +725,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
+@@ -778,6 +783,7 @@ vhost_user_set_vring_addr(struct virtio_net **pdev, struct VhostUserMsg *msg,
@@ -80 +81 @@
-@@ -1326,4 +1332,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
+@@ -1412,4 +1418,6 @@ vhost_user_get_vring_base(struct virtio_net **pdev,
@@ -85 +86 @@
- 	return RTE_VHOST_MSG_RESULT_REPLY;
+ 	return VH_RESULT_REPLY;



More information about the stable mailing list