From: Samiullah Khawaja <skhawaja@google.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
Jason Gunthorpe <jgg@ziepe.ca>,
David Woodhouse <dwmw2@infradead.org>,
Robin Murphy <robin.murphy@arm.com>,
Kevin Tian <kevin.tian@intel.com>,
Alex Williamson <alex@shazbot.org>,
Shuah Khan <shuah@kernel.org>,
iommu@lists.linux.dev, linux-kernel@vger.kernel.org,
kvm@vger.kernel.org, Pratyush Yadav <pratyush@kernel.org>,
Pasha Tatashin <pasha.tatashin@soleen.com>,
David Matlack <dmatlack@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Pranjal Shrivastava <praan@google.com>,
Vipin Sharma <vipinsh@google.com>,
Ankit Soni <Ankit.Soni@amd.com>,
Nicolin Chen <nicolinc@nvidia.com>,
John Starks <dev@jstarks.net>
Subject: Re: [PATCH v7 12/18] iommu: Restore and reattach preserved domains to devices
Date: Tue, 17 Nov 2026 03:55:45 +0000 [thread overview]
Message-ID: <avvK73lUs9RXdl0-@google.com> (raw)
In-Reply-To: <0a38ae25-3eac-42f6-862e-3dc1d644ab97@linux.intel.com>
On Tue, Nov 17, 2026 at 10:29:37AM +0800, Baolu Lu wrote:
>On 11/10/2026 12:08 PM, Samiullah Khawaja wrote:
>>During default domain setup, restore the preserved domains by restoring
>>the page tables using restore() iommupt op. Associated the restored
>>domain with the iommu group of the preserved device, and reattach the
>>domain to the device.
>>
>>Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
>>---
>> drivers/iommu/iommu.c | 115 +++++++++++++++++++++++++++++--
>> drivers/iommu/liveupdate.c | 106 ++++++++++++++++++++++++++++
>> include/linux/iommu-liveupdate.h | 39 +++++++++++
>> 3 files changed, 253 insertions(+), 7 deletions(-)
>
>[...]
>
>>+
>>+/**
>>+ * iommu_restore_domain() - Restore a preserved domain for a device
>>+ * @dev: Target device
>>+ * @ser: Serialized device state
>>+ *
>>+ * Restores or reuses a restored preserved domain for @dev from serialized state
>>+ * @ser.
>>+ *
>>+ * Return: Restored iommu_domain pointer, or ERR_PTR.
>>+ */
>>+struct iommu_domain *iommu_restore_domain(struct device *dev,
>>+ struct iommu_device_ser *ser)
>>+{
>>+ struct iommu_domain_ser *domain_ser;
>>+ struct iommu_flb_obj *flb_obj;
>>+ struct iommu_domain *domain;
>>+ struct pt_iommu *pt;
>>+ int ret;
>>+
>>+ ret = iommu_liveupdate_flb_get_incoming(&flb_obj);
>>+ if (ret)
>>+ return ERR_PTR(ret);
>>+
>>+ mutex_lock(&flb_obj->lock);
>>+
>>+ /* Preserved device should have a preserved domain */
>>+ if (!ser->attachment.domain_phys) {
>>+ domain = ERR_PTR(-EINVAL);
>>+ goto out;
>>+ }
>>+
>>+ domain_ser = phys_to_virt(ser->attachment.domain_phys);
>>+ if (domain_ser->restored_domain) {
>>+ domain = domain_ser->restored_domain;
>>+ goto out;
>>+ }
>>+
>>+ domain_ser->hdr.flags |= IOMMU_SER_FLAG_INCOMING;
>>+ domain = iommu_paging_domain_alloc(dev);
>
>Ah, here it is.
>
>This allocation uses the driver's default. For VT-d, it prefers first-
>stage translation when supported. But the preserved domain may be
>second-stage, for example if it was allocated for dirty tracking or
>nested parent. Would the restore callback then walk the preserved page
>table using the wrong format-specific operations?
Yes, that is a valid case. We can store the allocation flags in the
serialized state of the domain so it picks the right domain format
during restore. Note that in case of dirty tracking, we do not
preserve/restore the dirty tracking state, as the restored domain is
immutable and will be replaced with a new one.
>
>>+ if (IS_ERR(domain))
>>+ goto out;
>>+
>>+ pt = iommupt_from_domain(domain);
>>+ if (!pt) {
>>+ iommu_domain_free(domain);
>>+ domain = ERR_PTR(-EOPNOTSUPP);
>>+ goto out;
>>+ }
>>+
>>+ ret = pt->ops->restore(pt, domain_ser);
>>+ if (ret) {
>>+ iommu_domain_free(domain);
>>+ domain = ERR_PTR(ret);
>>+ goto out;
>>+ }
>>+
>>+ domain->domain_ser = domain_ser;
>>+ domain_ser->restored_domain = domain;
>>+
>>+out:
>>+ mutex_unlock(&flb_obj->lock);
>>+ liveupdate_flb_put_incoming(&iommu_flb);
>>+ return domain;
>>+}
>>diff --git a/include/linux/iommu-liveupdate.h b/include/linux/iommu-liveupdate.h
>>index fb1e8efac8ec..68c7ebca25f6 100644
>>--- a/include/linux/iommu-liveupdate.h
>>+++ b/include/linux/iommu-liveupdate.h
>>@@ -99,8 +99,31 @@ static inline void *dev_iommu_restored_state(struct device *dev)
>> return NULL;
>> }
>Thanks,
>baolu
>
Thanks,
Sami
next prev parent reply other threads:[~2026-11-17 3:55 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 4:08 [PATCH v7 00/18] iommu: Add live update state preservation Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 01/18] iommu: Implement IOMMU Live update FLB callbacks Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 02/18] iommu/pages: Add APIs to preserve/unpreserve/restore iommu pages Samiullah Khawaja
2026-11-12 16:31 ` Ankit Soni
2026-11-13 1:31 ` Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 03/18] iommupt: Implement preserve/unpreserve/restore callbacks Samiullah Khawaja
2026-11-16 15:22 ` Ankit Soni
2026-11-10 4:08 ` [PATCH v7 04/18] iommu: Implement IOMMU domain preservation Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 05/18] iommu: Implement device and IOMMU HW preservation Samiullah Khawaja
2026-11-16 10:19 ` Baolu Lu
2026-11-16 18:42 ` Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 06/18] iommu/vt-d: Implement device and iommu preserve/unpreserve ops Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 07/18] iommu/vt-d: Clear unpreserved context entries during shutdown Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 08/18] iommu: Add APIs to get iommu and device preserved state Samiullah Khawaja
2026-11-17 1:46 ` Baolu Lu
2026-11-10 4:08 ` [PATCH v7 09/18] iommu/vt-d: Combine disable_dmar_iommu() and free_dmar_iommu() Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 10/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids Samiullah Khawaja
2026-11-16 3:31 ` Baolu Lu
2026-11-16 20:34 ` Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 11/18] iommu/vt-d: Preserve PASID table of preserved device Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 12/18] iommu: Restore and reattach preserved domains to devices Samiullah Khawaja
2026-11-17 2:29 ` Baolu Lu
2026-11-17 3:55 ` Samiullah Khawaja [this message]
2026-11-10 4:08 ` [PATCH v7 13/18] iommu/vt-d: Handle reattach of the restored domain Samiullah Khawaja
2026-11-16 7:38 ` Baolu Lu
2026-11-16 20:04 ` Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 14/18] iommufd: Implement ioctl to mark HWPT for preservation Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 15/18] iommufd: Persist iommu hardware pagetables for live update Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 16/18] iommufd: Add APIs to preserve/unpreserve a vfio cdev Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 17/18] vfio/pci: Preserve the iommufd state of the " Samiullah Khawaja
2026-11-10 4:08 ` [PATCH v7 18/18] iommufd/selftest: Add test to verify iommufd preservation Samiullah Khawaja
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=avvK73lUs9RXdl0-@google.com \
--to=skhawaja@google.com \
--cc=Ankit.Soni@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--cc=baolu.lu@linux.intel.com \
--cc=dev@jstarks.net \
--cc=dmatlack@google.com \
--cc=dwmw2@infradead.org \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=pasha.tatashin@soleen.com \
--cc=praan@google.com \
--cc=pratyush@kernel.org \
--cc=robin.murphy@arm.com \
--cc=shuah@kernel.org \
--cc=vipinsh@google.com \
--cc=will@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®