Re: [PATCH 12/14] iommufd: Add APIs to preserve/unpreserve a vfio cdev

From: Vipin Sharma

Date: Mon Mar 23 2026 - 17:03:02 EST


On Tue, Feb 03, 2026 at 10:09:46PM +0000, Samiullah Khawaja wrote:
> diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
> +#ifdef CONFIG_IOMMU_LIVEUPDATE
> +int iommufd_device_preserve(struct liveupdate_session *s,
> + struct iommufd_device *idev,
> + u64 *tokenp)
> +{
> + struct iommufd_group *igroup = idev->igroup;
> + struct iommufd_hwpt_paging *hwpt_paging;
> + struct iommufd_hw_pagetable *hwpt;
> + struct iommufd_attach *attach;
> + int ret;
> +
> + mutex_lock(&igroup->lock);
> + attach = xa_load(&igroup->pasid_attach, IOMMU_NO_PASID);
> + if (!attach) {
> + ret = -ENOENT;
> + goto out;
> + }

Should VFIO in its can_preserve() add this check?

> +void iommufd_device_unpreserve(struct liveupdate_session *s,
> + struct iommufd_device *idev,
> + u64 token)

Where is token used in this function?