iommufd: Reserve all negative IDs in the iommufd xarray
authorYi Liu <yi.l.liu@intel.com>
Tue, 18 Jul 2023 10:55:35 +0000 (03:55 -0700)
committerAlex Williamson <alex.williamson@redhat.com>
Tue, 25 Jul 2023 16:17:48 +0000 (10:17 -0600)
With this reservation, IOMMUFD users can encode the negative IDs for
specific purposes. e.g. VFIO needs two reserved values to tell userspace
the ID returned is not valid but has other meaning.

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Tested-by: Yanting Jiang <yanting.jiang@intel.com>
Tested-by: Terrence Xu <terrence.xu@intel.com>
Tested-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Link: https://lore.kernel.org/r/20230718105542.4138-4-yi.l.liu@intel.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
drivers/iommu/iommufd/main.c

index 3fbe636..32ce7be 100644 (file)
@@ -50,7 +50,7 @@ struct iommufd_object *_iommufd_object_alloc(struct iommufd_ctx *ictx,
         * before calling iommufd_object_finalize().
         */
        rc = xa_alloc(&ictx->objects, &obj->id, XA_ZERO_ENTRY,
-                     xa_limit_32b, GFP_KERNEL_ACCOUNT);
+                     xa_limit_31b, GFP_KERNEL_ACCOUNT);
        if (rc)
                goto out_free;
        return obj;