[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[RFC v3 18/29] vhost: Use vhost_enable_custom_iommu to unmap everything
From: |
Eugenio Pérez |
Subject: |
[RFC v3 18/29] vhost: Use vhost_enable_custom_iommu to unmap everything if available |
Date: |
Wed, 19 May 2021 18:28:52 +0200 |
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(-)
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 5b5001a08a..c8fa9df9b3 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -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";
}
--
2.27.0
- [RFC v3 12/29] vhost: add vhost_kernel_vring_pause, (continued)
- [RFC v3 14/29] vhost: add vhost_has_limited_iova_range, Eugenio Pérez, 2021/05/19
- [RFC v3 15/29] vhost: Add enable_custom_iommu to VhostOps, Eugenio Pérez, 2021/05/19
- [RFC v3 16/29] vhost-vdpa: Add vhost_vdpa_enable_custom_iommu, Eugenio Pérez, 2021/05/19
- [RFC v3 17/29] vhost: Shadow virtqueue buffers forwarding, Eugenio Pérez, 2021/05/19
- [RFC v3 18/29] vhost: Use vhost_enable_custom_iommu to unmap everything if available,
Eugenio Pérez <=
- [RFC v3 19/29] vhost: Check for device VRING_USED_F_NO_NOTIFY at shadow virtqueue kick, Eugenio Pérez, 2021/05/19
- [RFC v3 20/29] vhost: Use VRING_AVAIL_F_NO_INTERRUPT at device call on shadow virtqueue, Eugenio Pérez, 2021/05/19
- [RFC v3 21/29] vhost: Add VhostIOVATree, Eugenio Pérez, 2021/05/19
- [RFC v3 22/29] vhost: Add iova_rev_maps_find_iova to IOVAReverseMaps, Eugenio Pérez, 2021/05/19
- [RFC v3 23/29] vhost: Use a tree to store memory mappings, Eugenio Pérez, 2021/05/19
- [RFC v3 24/29] vhost: Add iova_rev_maps_alloc, Eugenio Pérez, 2021/05/19
- [RFC v3 25/29] vhost: Add custom IOTLB translations to SVQ, Eugenio Pérez, 2021/05/19
- [RFC v3 26/29] vhost: Map in vdpa-dev, Eugenio Pérez, 2021/05/19
- [RFC v3 27/29] vhost-vdpa: Implement vhost_vdpa_vring_pause operation, Eugenio Pérez, 2021/05/19