]> git.proxmox.com Git - mirror_qemu.git/commitdiff
virtio-iommu: Add an assert check in translate routine
authorZhenzhong Duan <zhenzhong.duan@intel.com>
Mon, 13 Jun 2022 06:10:10 +0000 (14:10 +0800)
committerMichael S. Tsirkin <mst@redhat.com>
Thu, 16 Jun 2022 16:54:58 +0000 (12:54 -0400)
With address space switch supported, dma access translation only
happen after endpoint is attached to a non-bypass domain.

Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Message-Id: <20220613061010.2674054-4-zhenzhong.duan@intel.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
hw/virtio/virtio-iommu.c

index 73d5bde9d1223d98c5ba2b7608ac9f573f78130c..7c122ab9578073ee1b30c20e6309712fabbeea65 100644 (file)
@@ -865,6 +865,10 @@ static IOMMUTLBEntry virtio_iommu_translate(IOMMUMemoryRegion *mr, hwaddr addr,
     qemu_rec_mutex_lock(&s->mutex);
 
     ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(sid));
+
+    if (bypass_allowed)
+        assert(ep && ep->domain && !ep->domain->bypass);
+
     if (!ep) {
         if (!bypass_allowed) {
             error_report_once("%s sid=%d is not known!!", __func__, sid);