summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorCédric Le Goater <clg@redhat.com>2024-05-16 14:46:55 +0200
committerCédric Le Goater <clg@redhat.com>2024-05-16 16:59:19 +0200
commit94d12088409b9544dd4e191e2971c47ecec4c315 (patch)
treeeda5fb0a400973da9e7c4ef4a26497b8cc38ef17
parent3783f814e7e2e11cbd4e18e51e710db37900a1b8 (diff)
downloadfocaccia-qemu-94d12088409b9544dd4e191e2971c47ecec4c315.tar.gz
focaccia-qemu-94d12088409b9544dd4e191e2971c47ecec4c315.zip
vfio: Reverse test on vfio_get_xlat_addr()
It will simplify the changes coming after.

Reviewed-by: Avihai Horon <avihaih@nvidia.com>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
-rw-r--r--hw/vfio/common.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index 2c97de6c73..c7f274fb5c 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1224,16 +1224,20 @@ static void vfio_iommu_map_dirty_notify(IOMMUNotifier *n, IOMMUTLBEntry *iotlb)
     }
 
     rcu_read_lock();
-    if (vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL)) {
-        ret = vfio_get_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1,
-                                    translated_addr);
-        if (ret) {
-            error_report("vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
-                         "0x%"HWADDR_PRIx") = %d (%s)",
-                         bcontainer, iova, iotlb->addr_mask + 1, ret,
-                         strerror(-ret));
-        }
+    if (!vfio_get_xlat_addr(iotlb, NULL, &translated_addr, NULL)) {
+        goto out_unlock;
     }
+
+    ret = vfio_get_dirty_bitmap(bcontainer, iova, iotlb->addr_mask + 1,
+                                translated_addr);
+    if (ret) {
+        error_report("vfio_iommu_map_dirty_notify(%p, 0x%"HWADDR_PRIx", "
+                     "0x%"HWADDR_PRIx") = %d (%s)",
+                     bcontainer, iova, iotlb->addr_mask + 1, ret,
+                     strerror(-ret));
+    }
+
+out_unlock:
     rcu_read_unlock();
 
 out: