Skip to contentSkip to conversation

Search the split vq desc and avail in RO areas

PATCH Applied Eugenio Pérez 3 participants 11 messages Jun 5, 2025 – Jun 13, 2025

lore
Share & tools
lore
#0 lore raw

cover Search the split vq desc and avail in RO areas

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

 lib/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Signature · 1 line
2.49.0
#1 lore raw

PATCH 1/2 vhost: search the split vq desc and avail in RO areas

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Fixes eefac9536a90 ("vhost: postpone device creation until rings are mapped")
---
 lib/vhost/vhost.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +2 -2
index 0353a04dc8..95a99bace6 100644
@@ -497,7 +497,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
 	size = req_size;
 	vq->desc = (struct vring_desc *)(uintptr_t)vhost_iova_to_vva(dev, vq,
 						vq->ring_addrs.desc_user_addr,
-						&size, VHOST_ACCESS_RW);
+						&size, VHOST_ACCESS_RO);
 	if (!vq->desc || size != req_size)
 		return -1;
 
@@ -508,7 +508,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
 	size = req_size;
 	vq->avail = (struct vring_avail *)(uintptr_t)vhost_iova_to_vva(dev, vq,
 						vq->ring_addrs.avail_user_addr,
-						&size, VHOST_ACCESS_RW);
+						&size, VHOST_ACCESS_RO);
 	if (!vq->avail || size != req_size)
 		return -1;
 
Signature · 1 line
2.49.0
Reviewed-by on v1 1/2
#2 lore raw

Re: [PATCH 1/2] vhost: search the split vq desc and avail in RO areas

Quoted 26 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Fixes eefac9536a90 ("vhost: postpone device creation until rings are mapped")
---
  lib/vhost/vhost.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 0353a04dc8..95a99bace6 100644
@@ -497,7 +497,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
  	size = req_size;
  	vq->desc = (struct vring_desc *)(uintptr_t)vhost_iova_to_vva(dev, vq,
  						vq->ring_addrs.desc_user_addr,
-						&size, VHOST_ACCESS_RW);
+						&size, VHOST_ACCESS_RO);
  	if (!vq->desc || size != req_size)
  		return -1;
 

lib/vhost/vhost.c vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 514

Quoted 8 lines
lib/vhost/vhost.c +1 -1
@@ -508,7 +508,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
  	size = req_size;
  	vq->avail = (struct vring_avail *)(uintptr_t)vhost_iova_to_vva(dev, vq,
  						vq->ring_addrs.avail_user_addr,
-						&size, VHOST_ACCESS_RW);
+						&size, VHOST_ACCESS_RO);
  	if (!vq->avail || size != req_size)
  		return -1;
 

I propose below text for the commit message:

"
The virtqueues driver areas are read-only for the device. While they are exposed as Read/Write to Vhost-user and regular VDUSE backends, they are only exposed as Read-only when the control Virtqueue is shadowed by QEMU with VDUSE backend.

This patch makes the backend to request these areas as Read-only, so that it can be accessed in all the configurations. "

Also, as requested by David, patch 2 will be squashed into this one.

Eugenio, is that Ok for you?

With above suggested changes:

Thanks,
Maxime

#3 lore raw

Re: [PATCH 1/2] vhost: search the split vq desc and avail in RO areas

Quoted 47 lines · Maxime Coquelin
Quoted 26 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Fixes eefac9536a90 ("vhost: postpone device creation until rings are mapped")
---
  lib/vhost/vhost.c | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
lib/vhost/vhost.c +1 -1
index 0353a04dc8..95a99bace6 100644
@@ -497,7 +497,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
      size = req_size;
      vq->desc = (struct vring_desc *)(uintptr_t)vhost_iova_to_vva(dev, vq,
                                              vq->ring_addrs.desc_user_addr,
-                                             &size, VHOST_ACCESS_RW);
+                                             &size, VHOST_ACCESS_RO);
      if (!vq->desc || size != req_size)
              return -1;
 

lib/vhost/vhost.c vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 514

Quoted 8 lines
lib/vhost/vhost.c +1 -1
@@ -508,7 +508,7 @@ vring_translate_split(struct virtio_net *dev, struct vhost_virtqueue *vq)
      size = req_size;
      vq->avail = (struct vring_avail *)(uintptr_t)vhost_iova_to_vva(dev, vq,
                                              vq->ring_addrs.avail_user_addr,
-                                             &size, VHOST_ACCESS_RW);
+                                             &size, VHOST_ACCESS_RO);
      if (!vq->avail || size != req_size)
              return -1;
 

I propose below text for the commit message:

"
The virtqueues driver areas are read-only for the device. While they are exposed as Read/Write to Vhost-user and regular VDUSE backends, they are only exposed as Read-only when the control Virtqueue is shadowed by QEMU with VDUSE backend.

Quoted 8 lines

This patch makes the backend to request these areas as Read-only, so that it can be accessed in all the configurations.
"

Also, as requested by David, patch 2 will be squashed into this one.

Eugenio, is that Ok for you?

Sure, I'm ok with that.

Thanks!

Quoted 6 lines

With above suggested changes:

Thanks,
Maxime

#4 lore raw

PATCH 2/2 vhost: search the packed vq driver area in RO areas

In reply to Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes this as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Fixes 2d1541e2b6b3 ("vhost: add vring address setup for packed queues")
---
 lib/vhost/vhost.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost.c +1 -1
index 95a99bace6..a2e3e2635d 100644
@@ -544,7 +544,7 @@ vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
 	size = req_size;
 	vq->driver_event = (struct vring_packed_desc_event *)(uintptr_t)
 		vhost_iova_to_vva(dev, vq, vq->ring_addrs.avail_user_addr,
-				&size, VHOST_ACCESS_RW);
+				&size, VHOST_ACCESS_RO);
 	if (!vq->driver_event || size != req_size)
 		return -1;
 
Signature · 1 line
2.49.0
#5 lore raw

Re: [PATCH 2/2] vhost: search the packed vq driver area in RO areas

Quoted 17 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes this as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Fixes 2d1541e2b6b3 ("vhost: add vring address setup for packed queues")
---
  lib/vhost/vhost.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
lib/vhost/vhost.c +0 -0
index 95a99bace6..a2e3e2635d 100644

lib/vhost/vhost.c vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq) · line 550

Quoted 8 lines
lib/vhost/vhost.c +1 -1
@@ -544,7 +544,7 @@ vring_translate_packed(struct virtio_net *dev, struct vhost_virtqueue *vq)
  	size = req_size;
  	vq->driver_event = (struct vring_packed_desc_event *)(uintptr_t)
  		vhost_iova_to_vva(dev, vq, vq->ring_addrs.avail_user_addr,
-				&size, VHOST_ACCESS_RW);
+				&size, VHOST_ACCESS_RO);
  	if (!vq->driver_event || size != req_size)
  		return -1;
 

Squashed into patch 1.

Thanks,
Maxime

#6 lore raw
In reply to Eugenio Pérez
Quoted 11 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

 lib/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

At a quick glance, no need for two patches.

Sorry, the implication of this issue is not clear to me. What is the impact from a user pov?

Signature · 1 line
David Marchand
#7 lore raw
Quoted 7 lines · David Marchand
Quoted 5 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Quoted 9 lines
Quoted 6 lines

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

 lib/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

At a quick glance, no need for two patches.

Sure I can respin with both squashed.

Quoted 3 lines

Sorry, the implication of this issue is not clear to me. What is the impact from a user pov?

QEMU maps the CVQ descriptors and avail vring through as read only maps in the case of vDPA. But DPDK is looking for them with RW permissions, so the vhost_iova_to_vva function never selects the right one as valid.

Looking for them with RO still picks the map if it is mapped as RW, but the reverse is not true.

Let me know if you want me to respin the series with this comment too!

Quoted 4 lines

--
David Marchand

#8 lore raw
Quoted 25 lines · Eugenio Perez Martin
Quoted 7 lines · David Marchand
Quoted 5 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Quoted 9 lines
Quoted 6 lines

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

 lib/vhost/vhost.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

At a quick glance, no need for two patches.

Sure I can respin with both squashed.

Quoted 3 lines

Sorry, the implication of this issue is not clear to me. What is the impact from a user pov?

Quoted 7 lines

QEMU maps the CVQ descriptors and avail vring through as read only maps in the case of vDPA. But DPDK is looking for them with RW permissions, so the vhost_iova_to_vva function never selects the right one as valid.

Looking for them with RO still picks the map if it is mapped as RW, but the reverse is not true.

Ok, thanks.
Well, it's better, but still hard to tell how this impacts existing usecases :-).
After discussing with Maxime, I understand that the shadow CVQ just can't work => blocking multi queue support with vduse for example. This is the type of high level impact I was looking for.

Quoted 1 line

Let me know if you want me to respin the series with this comment too!

Ideally yes, but maybe Maxime can do it when applying.

Signature · 1 line
David Marchand
#9 lore raw
Quoted 41 lines · David Marchand
Quoted 25 lines · Eugenio Perez Martin
Quoted 7 lines · David Marchand
Quoted 5 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Quoted 9 lines
Quoted 6 lines

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

  lib/vhost/vhost.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

At a quick glance, no need for two patches.

Sure I can respin with both squashed.

Quoted 3 lines

Sorry, the implication of this issue is not clear to me. What is the impact from a user pov?

Quoted 7 lines

QEMU maps the CVQ descriptors and avail vring through as read only maps in the case of vDPA. But DPDK is looking for them with RW permissions, so the vhost_iova_to_vva function never selects the right one as valid.

Looking for them with RO still picks the map if it is mapped as RW, but the reverse is not true.

Ok, thanks.
Well, it's better, but still hard to tell how this impacts existing usecases :-).
After discussing with Maxime, I understand that the shadow CVQ just can't work => blocking multi queue support with vduse for example. This is the type of high level impact I was looking for.

Quoted 5 lines
Quoted 1 line

Let me know if you want me to respin the series with this comment too!

Ideally yes, but maybe Maxime can do it when applying.

Yes, I can rework the commit message while applying.

Thanks,
Maxime

#10 lore raw
In reply to Eugenio Pérez
Quoted 11 lines · Eugenio Pérez

QEMU's shadow virtqueue and VDUSE exposes these areas as read-only. If we don't change it, vhost_iova_to_vva do not consider them as valid and returns that they're not found.

Eugenio Pérez (2):
vhost: search the split vq desc and avail in RO areas
vhost: search the packed vq driver area in RO areas

  lib/vhost/vhost.c | 6 +++---
  1 file changed, 3 insertions(+), 3 deletions(-)

Applied to next-virtio/for-net-next with suggested changes.

Thomas, patch 2 has been squashed into patch 1.

Thanks,
Maxime