lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <299dd94a-2cc8-4e5b-984a-4ffef0f05e8b@linux.intel.com>
Date: Thu, 4 Dec 2025 13:46:53 +0800
From: Baolu Lu <baolu.lu@...ux.intel.com>
To: Samiullah Khawaja <skhawaja@...gle.com>,
 David Woodhouse <dwmw2@...radead.org>, Joerg Roedel <joro@...tes.org>,
 Will Deacon <will@...nel.org>, Pasha Tatashin <pasha.tatashin@...een.com>,
 Jason Gunthorpe <jgg@...pe.ca>, iommu@...ts.linux.dev
Cc: Robin Murphy <robin.murphy@....com>, Pratyush Yadav
 <pratyush@...nel.org>, Kevin Tian <kevin.tian@...el.com>,
 Alex Williamson <alex@...zbot.org>, linux-kernel@...r.kernel.org,
 Saeed Mahameed <saeedm@...dia.com>,
 Adithya Jayachandran <ajayachandra@...dia.com>,
 Parav Pandit <parav@...dia.com>, Leon Romanovsky <leonro@...dia.com>,
 William Tu <witu@...dia.com>, Vipin Sharma <vipinsh@...gle.com>,
 dmatlack@...gle.com, YiFei Zhu <zhuyifei@...gle.com>,
 Chris Li <chrisl@...nel.org>, praan@...gle.com
Subject: Re: [RFC PATCH v2 16/32] iommu: Add API to preserve/unpreserve a
 device

On 12/3/25 07:02, Samiullah Khawaja wrote:
> iommu_preserve_device/iommu_unpreserve_device can be used to
> preserve/unpreserve a device for liveupdate. During device preservation
> the state of the associated IOMMU is also preserved. The device can only
> be preseved if the attached iommu domain is preserved and the assocated
> iommu supports preservation.

If the device supports PASID, multiple domains might be attached to it.

...

> 
> Signed-off-by: Samiullah Khawaja<skhawaja@...gle.com>
> ---
>   drivers/iommu/iommu.c      |   3 +
>   drivers/iommu/liveupdate.c | 115 +++++++++++++++++++++++++++++++++++++
>   include/linux/iommu-lu.h   |   2 +
>   include/linux/iommu.h      |  18 ++++++
>   4 files changed, 138 insertions(+)
> 
> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
> index a70898d11959..3feb440de40a 100644
> --- a/drivers/iommu/iommu.c
> +++ b/drivers/iommu/iommu.c
> @@ -382,6 +382,9 @@ static struct dev_iommu *dev_iommu_get(struct device *dev)
>   
>   	mutex_init(&param->lock);
>   	dev->iommu = param;
> +#ifdef CONFIG_LIVEUPDATE
> +	dev->iommu->device_ser = NULL;
> +#endif
>   	return param;
>   }
>   
> diff --git a/drivers/iommu/liveupdate.c b/drivers/iommu/liveupdate.c
> index 25a943e5e1e3..5780761a7024 100644
> --- a/drivers/iommu/liveupdate.c
> +++ b/drivers/iommu/liveupdate.c
> @@ -11,6 +11,7 @@
>   #include <linux/liveupdate.h>
>   #include <linux/iommu-lu.h>
>   #include <linux/iommu.h>
> +#include <linux/pci.h>
>   #include <linux/errno.h>
>   
>   static void iommu_liveupdate_free_objs(u64 next, bool incoming)
> @@ -209,3 +210,117 @@ int iommu_domain_unpreserve(struct iommu_domain *domain)
>   	return 0;
>   }
>   EXPORT_SYMBOL_GPL(iommu_domain_unpreserve);
> +
> +static int iommu_preserve_locked(struct iommu_device *iommu)
> +{
> +	struct iommu_lu_flb_obj *flb_obj;
> +	struct iommu_ser *iommu_ser;
> +	int idx, ret;
> +
> +	if (!iommu->ops->preserve)
> +		return -EOPNOTSUPP;
> +
> +	if (iommu->outgoing_preserved_state) {
> +		iommu->outgoing_preserved_state->obj.ref_count++;
> +		return 0;
> +	}
> +
> +	ret = liveupdate_flb_get_outgoing(&iommu_flb, (void **)&flb_obj);
> +	if (ret)
> +		return ret;
> +
> +	idx = reserve_obj_ser((struct iommu_objs_ser **)&flb_obj->iommus, MAX_IOMMU_SERS);
> +	if (idx < 0)
> +		return idx;
> +
> +	iommu_ser = &flb_obj->iommus->iommus[idx];
> +	idx = flb_obj->ser->nr_iommus++;
> +	iommu_ser->obj.idx = idx;
> +	iommu_ser->obj.ref_count = 1;
> +
> +	ret = iommu->ops->preserve(iommu, iommu_ser);
> +	if (ret)
> +		iommu_ser->obj.deleted = true;
> +
> +	iommu->outgoing_preserved_state = iommu_ser;
> +	return ret;
> +}
> +
> +static void iommu_unpreserve_locked(struct iommu_device *iommu)
> +{
> +	struct iommu_ser *iommu_ser = iommu->outgoing_preserved_state;
> +
> +	iommu_ser->obj.ref_count--;
> +	if (iommu_ser->obj.ref_count)
> +		return;
> +
> +	iommu->outgoing_preserved_state = NULL;
> +	iommu->ops->unpreserve(iommu, iommu_ser);
> +	iommu_ser->obj.deleted = true;
> +}
> +
> +int iommu_preserve_device(struct iommu_domain *domain, struct device *dev)
> +{

... but this helper only cares about a single domain.

> +	struct iommu_lu_flb_obj *flb_obj;
> +	struct device_ser *device_ser;
> +	struct dev_iommu *iommu;
> +	struct pci_dev *pdev;
> +	int ret, idx;

Thanks,
baolu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ