patches for DPDK stable branches
 help / color / Atom feed
* [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially
@ 2020-01-09 17:58 Adrian Moreno
  2020-01-09 17:58 ` [dpdk-stable] [PATCH 17.11 1/1] vhost: fix vring memory partially mapped Adrian Moreno
  2020-01-09 19:40 ` [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Luca Boccassi
  0 siblings, 2 replies; 3+ messages in thread
From: Adrian Moreno @ 2020-01-09 17:58 UTC (permalink / raw)
  To: stable; +Cc: luca.boccassi, maxime.coquelin, Adrian Moreno

Slightly modified the patch with respect to upstream to remove the packed
ring support.

Adrian Moreno (1):
  vhost: fix vring memory partially mapped

 lib/librte_vhost/vhost_user.c | 54 +++++++++++------------------------
 1 file changed, 17 insertions(+), 37 deletions(-)

-- 
2.21.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [dpdk-stable] [PATCH 17.11 1/1] vhost: fix vring memory partially mapped
  2020-01-09 17:58 [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Adrian Moreno
@ 2020-01-09 17:58 ` Adrian Moreno
  2020-01-09 19:40 ` [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Luca Boccassi
  1 sibling, 0 replies; 3+ messages in thread
From: Adrian Moreno @ 2020-01-09 17:58 UTC (permalink / raw)
  To: stable; +Cc: luca.boccassi, maxime.coquelin, Adrian Moreno

[ upstream commit 5d9dc18e1bccfe74c6fc962042d01147b49a5bed ]

Only the mapping of the vring addresses is being ensured. This causes
errors when the vring size is larger than the IOTLB page size. E.g:
queue sizes > 256 for 4K IOTLB pages

Ensure the entire vring memory range gets mapped. Refactor duplicated
code for for IOTLB UPDATE and IOTLB INVALIDATE and add packed virtqueue
support.

Fixes: 09927b524969 ("vhost: translate ring addresses when IOMMU enabled")
Cc: stable@dpdk.org

Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
---
 lib/librte_vhost/vhost_user.c | 54 +++++++++++------------------------
 1 file changed, 17 insertions(+), 37 deletions(-)

diff --git a/lib/librte_vhost/vhost_user.c b/lib/librte_vhost/vhost_user.c
index 7bb286801..4390132a6 100644
--- a/lib/librte_vhost/vhost_user.c
+++ b/lib/librte_vhost/vhost_user.c
@@ -450,11 +450,13 @@ ring_addr_to_vva(struct virtio_net *dev, struct vhost_virtqueue *vq,
 {
 	if (dev->features & (1ULL << VIRTIO_F_IOMMU_PLATFORM)) {
 		uint64_t vva;
+		uint64_t req_size = *size;
 
 		vva = vhost_user_iotlb_cache_find(vq, ra,
 					size, VHOST_ACCESS_RW);
-		if (!vva)
-			vhost_user_iotlb_miss(dev, ra, VHOST_ACCESS_RW);
+		if (req_size != *size)
+			vhost_user_iotlb_miss(dev, (ra + *size),
+					      VHOST_ACCESS_RW);
 
 		return vva;
 	}
@@ -1238,50 +1240,28 @@ vhost_user_set_req_fd(struct virtio_net *dev, struct VhostUserMsg *msg)
 	return 0;
 }
 
-static int
-is_vring_iotlb_update(struct vhost_virtqueue *vq, struct vhost_iotlb_msg *imsg)
+
+static int is_vring_iotlb(struct vhost_virtqueue *vq,
+			  struct vhost_iotlb_msg *imsg)
 {
 	struct vhost_vring_addr *ra;
-	uint64_t start, end;
+	uint64_t start, end, len;
 
 	start = imsg->iova;
 	end = start + imsg->size;
 
 	ra = &vq->ring_addrs;
-	if (ra->desc_user_addr >= start && ra->desc_user_addr < end)
-		return 1;
-	if (ra->avail_user_addr >= start && ra->avail_user_addr < end)
-		return 1;
-	if (ra->used_user_addr >= start && ra->used_user_addr < end)
-		return 1;
-
-	return 0;
-}
-
-static int
-is_vring_iotlb_invalidate(struct vhost_virtqueue *vq,
-				struct vhost_iotlb_msg *imsg)
-{
-	uint64_t istart, iend, vstart, vend;
-
-	istart = imsg->iova;
-	iend = istart + imsg->size - 1;
-
-	vstart = (uintptr_t)vq->desc;
-	vend = vstart + sizeof(struct vring_desc) * vq->size - 1;
-	if (vstart <= iend && istart <= vend)
+	len = sizeof(struct vring_desc) * vq->size;
+	if (ra->desc_user_addr < end && (ra->desc_user_addr + len) > start)
 		return 1;
 
-	vstart = (uintptr_t)vq->avail;
-	vend = vstart + sizeof(struct vring_avail);
-	vend += sizeof(uint16_t) * vq->size - 1;
-	if (vstart <= iend && istart <= vend)
+	len = sizeof(struct vring_avail) + sizeof(uint16_t) * vq->size;
+	if (ra->avail_user_addr < end && (ra->avail_user_addr + len) > start)
 		return 1;
 
-	vstart = (uintptr_t)vq->used;
-	vend = vstart + sizeof(struct vring_used);
-	vend += sizeof(struct vring_used_elem) * vq->size - 1;
-	if (vstart <= iend && istart <= vend)
+	len = sizeof(struct vring_used) +
+	       sizeof(struct vring_used_elem) * vq->size;
+	if (ra->used_user_addr < end && (ra->used_user_addr + len) > start)
 		return 1;
 
 	return 0;
@@ -1308,7 +1288,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg)
 			vhost_user_iotlb_cache_insert(vq, imsg->iova, vva,
 					len, imsg->perm);
 
-			if (is_vring_iotlb_update(vq, imsg))
+			if (is_vring_iotlb(vq, imsg))
 				*pdev = dev = translate_ring_addresses(dev, i);
 		}
 		break;
@@ -1319,7 +1299,7 @@ vhost_user_iotlb_msg(struct virtio_net **pdev, struct VhostUserMsg *msg)
 			vhost_user_iotlb_cache_remove(vq, imsg->iova,
 					imsg->size);
 
-			if (is_vring_iotlb_invalidate(vq, imsg))
+			if (is_vring_iotlb(vq, imsg))
 				vring_invalidate(dev, vq);
 		}
 		break;
-- 
2.21.1


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially
  2020-01-09 17:58 [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Adrian Moreno
  2020-01-09 17:58 ` [dpdk-stable] [PATCH 17.11 1/1] vhost: fix vring memory partially mapped Adrian Moreno
@ 2020-01-09 19:40 ` Luca Boccassi
  1 sibling, 0 replies; 3+ messages in thread
From: Luca Boccassi @ 2020-01-09 19:40 UTC (permalink / raw)
  To: Adrian Moreno, stable; +Cc: maxime.coquelin

On Thu, 2020-01-09 at 18:58 +0100, Adrian Moreno wrote:
> Slightly modified the patch with respect to upstream to remove the
> packed
> ring support.
> 
> Adrian Moreno (1):
>   vhost: fix vring memory partially mapped
> 
>  lib/librte_vhost/vhost_user.c | 54 +++++++++++--------------------
> ----
>  1 file changed, 17 insertions(+), 37 deletions(-)

Thanks, applied

-- 
Kind regards,
Luca Boccassi

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, back to index

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-09 17:58 [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Adrian Moreno
2020-01-09 17:58 ` [dpdk-stable] [PATCH 17.11 1/1] vhost: fix vring memory partially mapped Adrian Moreno
2020-01-09 19:40 ` [dpdk-stable] [PATCH 17.11 0/1] Backport: vhost fix vring memory partially Luca Boccassi

patches for DPDK stable branches

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/stable/0 stable/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 stable stable/ http://inbox.dpdk.org/stable \
		stable@dpdk.org
	public-inbox-index stable


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.stable


AGPL code for this site: git clone https://public-inbox.org/ public-inbox