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 10/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids
Date: Mon, 16 Nov 2026 20:34:11 +0000 [thread overview]
Message-ID: <avtiC6VfIf7uc5gj@google.com> (raw)
In-Reply-To: <57c85edf-8400-4b45-9a64-5eddc0d29134@linux.intel.com>
On Mon, Nov 16, 2026 at 11:31:29AM +0800, Baolu Lu wrote:
>On 11/10/2026 12:08 PM, Samiullah Khawaja wrote:
>>During boot fetch the preserved state of IOMMU unit and if found then
>>restore the state.
>>
>>- Reuse the root_table that was preserved in the previous kernel.
>>- Reclaim the domain ids of the preserved domains for each preserved
>> devices so these are not acquired by another domain.
>>
>>Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
>>---
>> drivers/iommu/intel/iommu.c | 57 ++++++++++---
>> drivers/iommu/intel/iommu.h | 14 ++++
>> drivers/iommu/intel/liveupdate.c | 139 +++++++++++++++++++++++++++++++
>> 3 files changed, 197 insertions(+), 13 deletions(-)
>>
>>diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
>>index 6c86c155d12b..a83971368bef 100644
>>--- a/drivers/iommu/intel/iommu.c
>>+++ b/drivers/iommu/intel/iommu.c
>>@@ -987,6 +987,8 @@ static void iommu_disable_translation(struct intel_iommu *iommu)
>> static void release_dmar_iommu(struct intel_iommu *iommu)
>> {
>>+ intel_iommu_handle_drhd_restore_failure(iommu);
>>+
>> /*
>> * All iommu domains must have been detached from the devices,
>> * hence there should be no domain IDs in use.
>>@@ -1452,7 +1454,7 @@ static void intel_iommu_init_qi(struct intel_iommu *iommu)
>> * Returns 0 when the ID is reserved, was already reserved, or cannot be
>> * re-assigned, and a negative errno for a genuine allocation failure.
>> */
>>-static int reserve_domain_id(struct intel_iommu *iommu, int did)
>>+int reserve_domain_id(struct intel_iommu *iommu, int did)
>> {
>> int ret;
>>@@ -1743,12 +1745,16 @@ static int copy_translation_tables(struct intel_iommu *iommu)
>> static int __init init_dmars(void)
>> {
>>+ struct iommu_hw_ser *iommu_ser;
>> struct dmar_drhd_unit *drhd;
>> struct intel_iommu *iommu;
>> int ret;
>> for_each_iommu(iommu, drhd) {
>>+ iommu_ser = iommu_get_restored_state(iommu->reg_phys,
>>+ IOMMU_SER_TYPE_INTEL);
>> if (drhd->ignored) {
>>+ intel_iommu_handle_drhd_restore_failure(iommu);
>> iommu_disable_translation(iommu);
>> continue;
>> }
>>@@ -1766,7 +1772,9 @@ static int __init init_dmars(void)
>> }
>> intel_iommu_init_qi(iommu);
>>- init_translation_status(iommu);
>>+
>>+ if (!iommu_ser)
>>+ init_translation_status(iommu);
>> if (translation_pre_enabled(iommu) && !is_kdump_kernel()) {
>> iommu_disable_translation(iommu);
>>@@ -1775,14 +1783,18 @@ static int __init init_dmars(void)
>> iommu->name);
>> }
>>- /*
>>- * TBD:
>>- * we could share the same root & context tables
>>- * among all IOMMU's. Need to Split it later.
>>- */
>>- ret = iommu_alloc_root_entry(iommu);
>>- if (ret)
>>- goto free_iommu;
>>+ if (iommu_ser) {
>>+ intel_iommu_liveupdate_restore_root_table(iommu, iommu_ser);
>
>What happens if the incoming kernel is booted with intel_iommu=off?
>
>intel_iommu_init() calls intel_disable_iommus() before reaching this
>restore path. A preserved device may still be issuing DMA, which would
>then bypass translation.
>
>Could we detect preserved IOMMUs and force VT-d on in that case? We
Booting the new kernel with intel_iommu=off after a live update is a
configuration mistake. I will check for preserved IOMMU state in
intel_iommu_init() and force VT-d on like you suggested.
>should also ensure that the ACS configuration for preserved devices and
>their upstream bridges remains consistent with the previous kernel.
The ACS configuration of the preserved devices and their upstream
bridges is preserved and restored by the PCI live update series.
>
>Thanks,
>baolu
Thanks,
Sami
next prev parent reply other threads:[~2026-11-16 20:34 UTC|newest]
Thread overview: 28+ 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-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 [this message]
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-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=avtiC6VfIf7uc5gj@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®