mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Samiullah Khawaja <skhawaja@google.com>
To: Baolu Lu <baolu.lu@linux.intel.com>
Cc: David Woodhouse <dwmw2@infradead.org>,
	Joerg Roedel <joro@8bytes.org>,  Will Deacon <will@kernel.org>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	 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>
Subject: Re: [PATCH v5 13/18] iommu/vt-d: Preserve PASID table of preserved device
Date: Sat, 10 Oct 2026 02:31:42 +0000	[thread overview]
Message-ID: <asmeX0tryM-fR-d_@google.com> (raw)
In-Reply-To: <f48258bb-df50-43bb-9141-433601d885a2@linux.intel.com>

On Fri, Oct 09, 2026 at 11:38:57AM +0800, Baolu Lu wrote:
>On 9/21/2026 8:48 AM, Samiullah Khawaja wrote:
>>In scalable mode the PASID table is used to fetch the io page tables.
>>Preserve and restore the PASID table of the preserved devices.
>>
>>Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
>>---
>>  drivers/iommu/intel/liveupdate.c | 141 +++++++++++++++++++++++++++++--
>>  drivers/iommu/intel/pasid.c      |  10 ++-
>>  drivers/iommu/intel/pasid.h      |   8 ++
>>  include/linux/kho/abi/iommu.h    |  17 ++++
>>  4 files changed, 169 insertions(+), 7 deletions(-)
>
>Should this patch come before patch 12/18, which restores the device’s
>domain attachment?

Agreed. I will move it before the patch that restores the device's
domain attachment.
>
>>

[snip]

>>diff --git a/drivers/iommu/intel/pasid.c b/drivers/iommu/intel/pasid.c
>>index e4f24d3f19a6..59cc69383799 100644
>>--- a/drivers/iommu/intel/pasid.c
>>+++ b/drivers/iommu/intel/pasid.c
>>@@ -13,6 +13,7 @@
>>  #include <linux/cpufeature.h>
>>  #include <linux/dmar.h>
>>  #include <linux/iommu.h>
>>+#include <linux/iommu-liveupdate.h>
>>  #include <linux/memory.h>
>>  #include <linux/pci.h>
>>  #include <linux/pci-ats.h>
>>@@ -60,8 +61,13 @@ int intel_pasid_alloc_table(struct device *dev)
>>  	size = max_pasid >> (PASID_PDE_SHIFT - 3);
>>  	order = size ? get_order(size) : 0;
>>-	dir = iommu_alloc_pages_node_sz(info->iommu->node, GFP_KERNEL,
>>-					1 << (order + PAGE_SHIFT));
>>+
>>+	max_pasid = 1 << (order + PAGE_SHIFT + 3);
>>+	if (dev_iommu_restored_state(dev))
>>+		dir = intel_pasid_restore_table(dev, max_pasid);
>>+	else
>>+		dir = iommu_alloc_pages_node_sz(info->iommu->node, GFP_KERNEL,
>>+						1 << (order + PAGE_SHIFT));
>
>This restores only the PASID table pages. The PASID table is eventually
>installed in the context entry during probe_device:
>
>        if (sm_supported(iommu) && !dev_is_real_dma_subdevice(dev)) {
>                ret = intel_pasid_alloc_table(dev);
>                if (ret) {
>                        dev_err(dev, "PASID table allocation failed\n");
>                        goto clear_rbtree;
>                }
>
>                if (!context_copied(iommu, info->bus, info->devfn)) {
>                        ret = intel_pasid_setup_sm_context(dev);
>                        if (ret)
>                                goto free_table;
>                }
>        }
>
>For a restored PASID table, the call to intel_pasid_setup_sm_context()
>should be skipped. Instead, it should check whether the preserved pasid
>table is compatible with the new kernel environment.

I will skip the setup call here, but the compatibility check is done in
the intel_pasid_restore_table(). The command line configuration and
other things can be verified during iommu unit restore as you pointed
out in the other patch.
>
>>  	if (!dir) {
>>  		kfree(pasid_table);
>>  		return -ENOMEM;
>>diff --git a/include/linux/kho/abi/iommu.h b/include/linux/kho/abi/iommu.h

[snip]

>>index 5aaa29da6832..308cd83fd3e3 100644
>>--- a/include/linux/kho/abi/iommu.h
>>+++ b/include/linux/kho/abi/iommu.h
>>@@ -129,6 +129,19 @@ struct iommu_dev_map_ser {
>>  	u64 iommu_phys;
>>  } __packed;
>>+/**
>>+ * struct iommu_device_intel_ser - Intel specific state of serialized device
>>+ * @restored: Whether the device state is restored
>>+ * @pasid_table: Physical address of pasid table
>>+ * @max_pasid: Maximum supported pasid
>>+ */
>>+struct iommu_device_intel_ser {
>>+	u8 restored;
>>+	u8 padding[7];
>>+	u64 pasid_table;
>>+	u64 max_pasid;
>>+} __packed;
>>+
>>  /**
>>   * struct iommu_device_ser - Serialized state of a device
>>   * @hdr: Common object header
>>@@ -136,6 +149,7 @@ struct iommu_dev_map_ser {
>>   * @pci_domain_nr: PCI domain number
>>   * @dma_owner_token: Token to identify the DMA owner of this device
>>   * @domain_iommu_ser: Domain and IOMMU mapping
>>+ * @intel: Intel specific serialization data
>>   */
>>  struct iommu_device_ser {
>>  	struct iommu_hdr_ser hdr;
>>@@ -143,6 +157,9 @@ struct iommu_device_ser {
>>  	u32 pci_domain_nr;
>>  	u64 dma_owner_token;
>>  	struct iommu_dev_map_ser domain_iommu_ser;
>>+	union {
>>+		struct iommu_device_intel_ser intel;
>>+	};
>>  } __packed;
>>  /* There are maximum 256 buses, so maximum 512 context tables */
>
>Thanks,
>baolu

Thanks,
Sami

  reply	other threads:[~2026-10-10  2:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-21  0:48 [PATCH v5 00/18] iommu: Add live update state preservation Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 01/18] memfd: export memfd_get_seals() Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 02/18] iommu: Implement IOMMU Live update FLB callbacks Samiullah Khawaja
2026-10-06 23:31   ` Nicolin Chen
2026-10-10  3:18     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 03/18] iommu/pages: Add APIs to preserve/unpreserve/restore iommu pages Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 04/18] iommupt: Implement preserve/unpreserve/restore callbacks Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 05/18] iommu: Implement IOMMU domain preservation Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 06/18] iommu: Implement device and IOMMU HW preservation Samiullah Khawaja
2026-10-07  3:21   ` Nicolin Chen
2026-10-10  3:27     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 07/18] iommu/vt-d: Implement device and iommu preserve/unpreserve ops Samiullah Khawaja
2026-10-08  7:54   ` Baolu Lu
2026-10-10  0:10     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 08/18] iommu/vt-d: Clear unpreserved context entries during shutdown Samiullah Khawaja
2026-10-09  0:43   ` Baolu Lu
2026-10-10  0:32     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 09/18] iommu: Add APIs to get iommu and device preserved state Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 10/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids Samiullah Khawaja
2026-10-09  1:44   ` Baolu Lu
2026-10-10  1:58     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 11/18] iommu: Restore and reattach preserved domains to devices Samiullah Khawaja
2026-10-07 19:44   ` Nicolin Chen
2026-10-10  3:51     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 12/18] iommu/vt-d: Handle reattach of the restored domain Samiullah Khawaja
2026-10-09  2:24   ` Baolu Lu
2026-10-10  2:09     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 13/18] iommu/vt-d: Preserve PASID table of preserved device Samiullah Khawaja
2026-10-09  3:38   ` Baolu Lu
2026-10-10  2:31     ` Samiullah Khawaja [this message]
2026-09-21  0:48 ` [PATCH v5 14/18] iommufd: Implement ioctl to mark HWPT for preservation Samiullah Khawaja
2026-10-07 20:17   ` Nicolin Chen
2026-10-10  3:52     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 15/18] iommufd: Persist iommu hardware pagetables for live update Samiullah Khawaja
2026-09-23 23:59   ` John Starks
2026-09-24 17:49     ` Samiullah Khawaja
2026-10-07 21:31   ` Nicolin Chen
2026-10-10  4:03     ` Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 16/18] iommufd: Add APIs to preserve/unpreserve a vfio cdev Samiullah Khawaja
2026-10-07 22:00   ` Nicolin Chen
2026-09-21  0:48 ` [PATCH v5 17/18] vfio/pci: Preserve the iommufd state of the " Samiullah Khawaja
2026-09-21  0:48 ` [PATCH v5 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=asmeX0tryM-fR-d_@google.com \
    --to=skhawaja@google.com \
    --cc=akpm@linux-foundation.org \
    --cc=alex@shazbot.org \
    --cc=baolu.lu@linux.intel.com \
    --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=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®