@@ -1241,7 +1241,12 @@ static int vhost_sw_live_migration_stop(struct vhost_dev *dev)
r = dev->vhost_ops->vhost_vring_pause(dev);
assert(r == 0);
- if (vhost_backend_invalidate_device_iotlb(dev, 0, -1ULL)) {
+ if (dev->vhost_ops->vhost_enable_custom_iommu) {
+ r = dev->vhost_ops->vhost_enable_custom_iommu(dev, false);
+ } else {
+ r = vhost_backend_invalidate_device_iotlb(dev, 0, -1ULL);
+ }
+ if (r) {
error_report("Fail to invalidate device iotlb");
}
@@ -1343,7 +1348,12 @@ static int vhost_sw_live_migration_start(struct vhost_dev *dev)
r = dev->vhost_ops->vhost_vring_pause(dev);
assert(r == 0);
- if (vhost_backend_invalidate_device_iotlb(dev, 0, -1ULL)) {
+ if (dev->vhost_ops->vhost_enable_custom_iommu) {
+ r = dev->vhost_ops->vhost_enable_custom_iommu(dev, false);
+ } else {
+ r = vhost_backend_invalidate_device_iotlb(dev, 0, -1ULL);
+ }
+ if (r) {
error_report("Fail to invalidate device iotlb");
}
@@ -2100,8 +2110,6 @@ void qmp_x_vhost_enable_shadow_vq(const char *name, bool enable, Error **errp)
err_cause = "Cannot pause device";
} else if (hdev->vhost_ops->vhost_get_iova_range) {
err_cause = "Device may not support all iova range";
- } else if (hdev->vhost_ops->vhost_enable_custom_iommu) {
- err_cause = "Device does not use regular IOMMU";
} else if (!virtio_vdev_has_feature(hdev->vdev, VIRTIO_F_VERSION_1)) {
err_cause = "Legacy VirtIO device";
}
This call is the right way to unmap every IOTLB in devices with non standard IOMMU (vdpa devices), since regular one would require an IOTLB message they don't support. Another possible solution would be to implement .vhost_send_device_iotlb_msg vhost operation in vhost-vdpa, but it could conflict with expected backend iommu operations. Currently, this method does not work for vp_vdpa. For some reason, intel IOMMU is not able to map anything when vdpa has unmapped everything. However that is on kernel side, this commit code should be as intended in the final version. Signed-off-by: Eugenio PĂ©rez <eperezma@redhat.com> --- hw/virtio/vhost.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-)