Blame SOURCES/0001-vhost-remove-pending-IOTLB-entry-if-miss-request-fai.patch

c7ffa4
From 82b9c1540348b6be7996203065e10421e953cea9 Mon Sep 17 00:00:00 2001
c7ffa4
From: Maxime Coquelin <maxime.coquelin@redhat.com>
c7ffa4
Date: Mon, 5 Feb 2018 16:04:57 +0100
c7ffa4
Subject: [PATCH] vhost: remove pending IOTLB entry if miss request failed
c7ffa4
c7ffa4
In case vhost_user_iotlb_miss returns an error, the pending IOTLB
c7ffa4
entry has to be removed from the list as no IOTLB update will be
c7ffa4
received.
c7ffa4
c7ffa4
Fixes: fed67a20ac94 ("vhost: introduce guest IOVA to backend VA helper")
c7ffa4
Cc: stable@dpdk.org
c7ffa4
c7ffa4
Suggested-by: Tiwei Bie <tiwei.bie@intel.com>
c7ffa4
Signed-off-by: Maxime Coquelin <maxime.coquelin@redhat.com>
c7ffa4
---
c7ffa4
 lib/librte_vhost/iotlb.c |  2 +-
c7ffa4
 lib/librte_vhost/iotlb.h |  3 +++
c7ffa4
 lib/librte_vhost/vhost.c | 13 ++++++++++---
c7ffa4
 3 files changed, 14 insertions(+), 4 deletions(-)
c7ffa4
c7ffa4
diff --git a/lib/librte_vhost/iotlb.c b/lib/librte_vhost/iotlb.c
c7ffa4
index 72cd27df8..c11ebcaac 100644
c7ffa4
--- a/lib/librte_vhost/iotlb.c
c7ffa4
+++ b/lib/librte_vhost/iotlb.c
c7ffa4
@@ -120,7 +120,7 @@ vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq,
c7ffa4
 	rte_rwlock_write_unlock(&vq->iotlb_pending_lock);
c7ffa4
 }
c7ffa4
 
c7ffa4
-static void
c7ffa4
+void
c7ffa4
 vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq,
c7ffa4
 				uint64_t iova, uint64_t size, uint8_t perm)
c7ffa4
 {
c7ffa4
diff --git a/lib/librte_vhost/iotlb.h b/lib/librte_vhost/iotlb.h
c7ffa4
index f1a050e44..e7083e37b 100644
c7ffa4
--- a/lib/librte_vhost/iotlb.h
c7ffa4
+++ b/lib/librte_vhost/iotlb.h
c7ffa4
@@ -71,6 +71,9 @@ bool vhost_user_iotlb_pending_miss(struct vhost_virtqueue *vq, uint64_t iova,
c7ffa4
 						uint8_t perm);
c7ffa4
 void vhost_user_iotlb_pending_insert(struct vhost_virtqueue *vq, uint64_t iova,
c7ffa4
 						uint8_t perm);
c7ffa4
+void vhost_user_iotlb_pending_remove(struct vhost_virtqueue *vq, uint64_t iova,
c7ffa4
+						uint64_t size, uint8_t perm);
c7ffa4
+
c7ffa4
 int vhost_user_iotlb_init(struct virtio_net *dev, int vq_index);
c7ffa4
 
c7ffa4
 #endif /* _VHOST_IOTLB_H_ */
c7ffa4
diff --git a/lib/librte_vhost/vhost.c b/lib/librte_vhost/vhost.c
c7ffa4
index a31ca5002..a407067e2 100644
c7ffa4
--- a/lib/librte_vhost/vhost.c
c7ffa4
+++ b/lib/librte_vhost/vhost.c
c7ffa4
@@ -42,7 +42,9 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
c7ffa4
 	if (tmp_size == size)
c7ffa4
 		return vva;
c7ffa4
 
c7ffa4
-	if (!vhost_user_iotlb_pending_miss(vq, iova + tmp_size, perm)) {
c7ffa4
+	iova += tmp_size;
c7ffa4
+
c7ffa4
+	if (!vhost_user_iotlb_pending_miss(vq, iova, perm)) {
c7ffa4
 		/*
c7ffa4
 		 * iotlb_lock is read-locked for a full burst,
c7ffa4
 		 * but it only protects the iotlb cache.
c7ffa4
@@ -52,8 +54,13 @@ __vhost_iova_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
c7ffa4
 		 */
c7ffa4
 		vhost_user_iotlb_rd_unlock(vq);
c7ffa4
 
c7ffa4
-		vhost_user_iotlb_pending_insert(vq, iova + tmp_size, perm);
c7ffa4
-		vhost_user_iotlb_miss(dev, iova + tmp_size, perm);
c7ffa4
+		vhost_user_iotlb_pending_insert(vq, iova, perm);
c7ffa4
+		if (vhost_user_iotlb_miss(dev, iova, perm)) {
c7ffa4
+			RTE_LOG(ERR, VHOST_CONFIG,
c7ffa4
+				"IOTLB miss req failed for IOVA 0x%" PRIx64 "\n",
c7ffa4
+				iova);
c7ffa4
+			vhost_user_iotlb_pending_remove(vq, iova, 1, perm);
c7ffa4
+		}
c7ffa4
 
c7ffa4
 		vhost_user_iotlb_rd_lock(vq);
c7ffa4
 	}
c7ffa4
-- 
c7ffa4
2.14.3
c7ffa4