Skip to content

Commit c82729e

Browse files
Cindy Lumstsirkin
authored andcommitted
vhost_vdpa: fix unmap process in no-batch mode
While using the vdpa device with vIOMMU enabled in the guest VM, when the vdpa device bind to vfio-pci and run testpmd then system will fail to unmap. The test process is Load guest VM --> attach to virtio driver--> bind to vfio-pci driver So the mapping process is 1)batched mode map to normal MR 2)batched mode unmapped the normal MR 3)unmapped all the memory 4)mapped to iommu MR This error happened in step 3). The iotlb was freed in step 2) and the function vhost_vdpa_process_iotlb_msg 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 Cc: stable@vger.kernel.org Fixes: aaca837 ("vhost-vdpa: support ASID based IOTLB API") Signed-off-by: Cindy Lu <lulu@redhat.com> Message-Id: <20230420151734.860168-1-lulu@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
1 parent 11841c5 commit c82729e

1 file changed

Lines changed: 1 addition & 7 deletions

File tree

drivers/vhost/vdpa.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -886,11 +886,7 @@ static void vhost_vdpa_unmap(struct vhost_vdpa *v,
886886
if (!v->in_batch)
887887
ops->set_map(vdpa, asid, iotlb);
888888
}
889-
/* If we are in the middle of batch processing, delay the free
890-
* of AS until BATCH_END.
891-
*/
892-
if (!v->in_batch && !iotlb->nmaps)
893-
vhost_vdpa_remove_as(v, asid);
889+
894890
}
895891

896892
static int vhost_vdpa_va_map(struct vhost_vdpa *v,
@@ -1147,8 +1143,6 @@ static int vhost_vdpa_process_iotlb_msg(struct vhost_dev *dev, u32 asid,
11471143
if (v->in_batch && ops->set_map)
11481144
ops->set_map(vdpa, asid, iotlb);
11491145
v->in_batch = false;
1150-
if (!iotlb->nmaps)
1151-
vhost_vdpa_remove_as(v, asid);
11521146
break;
11531147
default:
11541148
r = -EINVAL;

0 commit comments

Comments
 (0)