Skip to contentSkip to conversation

vhost_vdpa: fix unmap process in no-batch mode

PATCH Superseded Cindy Lu 2 participants 2 messages Apr 15, 2023 – Apr 17, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Cindy Lu

author
#0 lore raw

PATCH v2 1/1 vhost_vdpa: fix unmap process in no-batch mode

While using the no-batch mode with vIOMMU enabled
Qemu will call a large memory to unmap. Much larger than the memory mapped to the kernel. The iotlb is NULL in the kernel and will return fail. Which causes failure.
To fix this, we will not remove the AS while the iotlb->nmaps is 0. This will free in the vhost_vdpa_clean

---
 drivers/vhost/vdpa.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/vhost/vdpa.c +1 -7
index 7be9d9d8f01c..74c7d1f978b7 100644
@@ -851,11 +851,7 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v,
 		if (!v->in_batch)
 			ops->set_map(vdpa, asid, iotlb);
 	}
-	/* If we are in the middle of batch processing, delay the free
-	 * of AS until BATCH_END.
-	 */
-	if (!v->in_batch && !iotlb->nmaps)
-		vhost_vdpa_remove_as(v, asid);
+
 }
 
 static int vhost_vdpa_va_map(struct vhost_vdpa *v,
@@ -1112,8 +1108,6 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid,
 		if (v->in_batch && ops->set_map)
 			ops->set_map(vdpa, asid, iotlb);
 		v->in_batch = false;
-		if (!iotlb->nmaps)
-			vhost_vdpa_remove_as(v, asid);
 		break;
 	default:
 		r = -EINVAL;
Signature · 1 line
2.34.3
#1 lore raw
Quoted 4 lines · Cindy Lu

While using the no-batch mode with vIOMMU enabled
Qemu will call a large memory to unmap. Much larger than the memory mapped to the kernel. The iotlb is NULL in the kernel and will return fail.

This patch looks good but I don't understand the above. I think it's better to explain why such large unmap will lead to this error:

Is it a batched unmap or a [0, ULONG_MAX] map? How could we end up the NULL?

Quoted 5 lines

Which causes failure.
To fix this, we will not remove the AS while the iotlb->nmaps is 0. This will free in the vhost_vdpa_clean

Do we need a fix tag and does it need to go for -stable?

Thanks

Quoted 31 lines
---
 drivers/vhost/vdpa.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/vhost/vdpa.c +1 -8
index 7be9d9d8f01c..74c7d1f978b7 100644
@@ -851,11 +851,7 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v,
                if (!v->in_batch)
                        ops->set_map(vdpa, asid, iotlb);
        }
-       /* If we are in the middle of batch processing, delay the free
-        * of AS until BATCH_END.
-        */
-       if (!v->in_batch && !iotlb->nmaps)
-               vhost_vdpa_remove_as(v, asid);
+
 }
 
 static int vhost_vdpa_va_map(struct vhost_vdpa *v,
@@ -1112,8 +1108,6 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid,
                if (v->in_batch && ops->set_map)
                        ops->set_map(vdpa, asid, iotlb);
                v->in_batch = false;
-               if (!iotlb->nmaps)
-                       vhost_vdpa_remove_as(v, asid);
                break;
        default:
                r = -EINVAL;
--
Quoted 2 lines

2.34.3

_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization