summaryrefslogtreecommitdiffstats
path: root/hw/virtio
diff options
context:
space:
mode:
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/vhost.c13
-rw-r--r--hw/virtio/virtio-iommu.c5
2 files changed, 16 insertions, 2 deletions
diff --git a/hw/virtio/vhost.c b/hw/virtio/vhost.c
index 28c7d78172..6e17d631f7 100644
--- a/hw/virtio/vhost.c
+++ b/hw/virtio/vhost.c
@@ -704,6 +704,7 @@ static void vhost_iommu_region_add(MemoryListener *listener,
Int128 end;
int iommu_idx;
IOMMUMemoryRegion *iommu_mr;
+ int ret;
if (!memory_region_is_iommu(section->mr)) {
return;
@@ -726,8 +727,16 @@ static void vhost_iommu_region_add(MemoryListener *listener,
iommu->iommu_offset = section->offset_within_address_space -
section->offset_within_region;
iommu->hdev = dev;
- memory_region_register_iommu_notifier(section->mr, &iommu->n,
- &error_fatal);
+ ret = memory_region_register_iommu_notifier(section->mr, &iommu->n, NULL);
+ if (ret) {
+ /*
+ * Some vIOMMUs do not support dev-iotlb yet. If so, try to use the
+ * UNMAP legacy message
+ */
+ iommu->n.notifier_flags = IOMMU_NOTIFIER_UNMAP;
+ memory_region_register_iommu_notifier(section->mr, &iommu->n,
+ &error_fatal);
+ }
QLIST_INSERT_HEAD(&dev->iommu_list, iommu, iommu_next);
/* TODO: can replay help performance here? */
}
diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c
index 6b9ef7f6b2..c2883a2f6c 100644
--- a/hw/virtio/virtio-iommu.c
+++ b/hw/virtio/virtio-iommu.c
@@ -893,6 +893,11 @@ static int virtio_iommu_notify_flag_changed(IOMMUMemoryRegion *iommu_mr,
IOMMUNotifierFlag new,
Error **errp)
{
+ if (new & IOMMU_NOTIFIER_DEVIOTLB_UNMAP) {
+ error_setg(errp, "Virtio-iommu does not support dev-iotlb yet");
+ return -EINVAL;
+ }
+
if (old == IOMMU_NOTIFIER_NONE) {
trace_virtio_iommu_notify_flag_add(iommu_mr->parent_obj.name);
} else if (new == IOMMU_NOTIFIER_NONE) {