On 10/1/25 00:04, John Levon wrote:
On Tue, Sep 30, 2025 at 05:26:59PM +0200, Cédric Le Goater wrote:

-        }
+        ret = ioctl(container->fd, VFIO_CHECK_EXTENSION, VFIO_UNMAP_ALL);

Could we introduce an helper to test 'unmap_all' support in the host
kernel ? The result would be something like :

   if (unmap_all) {
         if (vfio_legacy_has_unmap_all(VFIO_IOMMU_LEGACY(bcontainer))) {
             flags = VFIO_DMA_UNMAP_FLAG_ALL;
         } else {
             /* The unmap ioctl doesn't accept a full 64-bit span. */
             Int128 llsize = int128_rshift(int128_2_64(), 1);
             ...
         }
   }

For reference/consideration, the previous approach taken in the vfio-user
series:

https://lore.kernel.org/qemu-devel/[email protected]/

@@ -533,6 +562,11 @@ static bool vfio_legacy_setup(VFIOContainerBase 
*bcontainer, Error **errp)
      vfio_get_info_iova_range(info, bcontainer);
vfio_get_iommu_info_migration(container, info);
+
+    ret = ioctl(container->fd, VFIO_CHECK_EXTENSION, VFIO_UNMAP_ALL);
+
+    container->unmap_all_supported = (ret != 0);

(I dropped this particular change as part of getting merged.)
Yes. I’m reconsidering now.

Should we introduce a VFIOContainerBase attribute/flag 'unmap_all_supported',
set in the vioc->setup handler ?

Thanks,

C.


Reply via email to