From: Baolu Lu <baolu.lu@linux.intel.com>
To: Samiullah Khawaja <skhawaja@google.com>
Cc: baolu.lu@linux.intel.com, 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 v8 11/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids
Date: Sat, 5 Dec 2026 10:45:00 +0800 [thread overview]
Message-ID: <833ec35b-e7c1-473c-a7b2-14ebda1f6aa5@linux.intel.com> (raw)
In-Reply-To: <axM-d7f6i0WhQgk_@google.com>
On 12/5/2026 8:03 AM, Samiullah Khawaja wrote:
>>> @@ -2247,6 +2263,15 @@ static int intel_iommu_add(struct
>>> dmar_drhd_unit *dmaru)
>>> struct intel_iommu *iommu = dmaru->iommu;
>>> int ret;
>>> + /*
>>> + * Hot-add of an IOMMU with preserved state is not supported. A
>>> + * preserved IOMMU is restored during boot, so it should never get
>>> + * here.
>>> + */
>>> + if (WARN_ON(iommu_get_restored_state(iommu->reg_phys,
>>> + IOMMU_SER_TYPE_INTEL)))
>>> + return -EBUSY;
>>> +
>>> /*
>>> * Disable translation if already enabled prior to OS handover.
>>> */
>>> @@ -2689,6 +2714,33 @@ static __init void tboot_force_iommu(void)
>>> no_iommu = 0;
>>> }
>>> +/*
>>> + * Devices preserved across a live update keep doing DMA through the
>>> preserved
>>> + * translation tables, so the IOMMUs can't be turned off. Force them
>>> on if the
>>> + * previous kernel preserved any IOMMU state.
>>> + */
>>> +static void __init liveupdate_force_iommu(void)
>>> +{
>>> + struct dmar_drhd_unit *drhd;
>>> +
>>> + if (dmar_policy_on())
>>> + return;
>>> +
>>> + for_each_drhd_unit(drhd) {
>>> + if (!iommu_get_restored_state(drhd->reg_base_addr,
>>> + IOMMU_SER_TYPE_INTEL))
>>> + continue;
>>> +
>>> + pr_warn("Forcing Intel-IOMMU to enabled for live update\n");
>>> +
>>> + /* No concurrent access to dmar_policy at this point. */
>>> + dmar_policy = DMAR_FORCE_ON;
>>
>> This skips the precedence rules in dmar_can_force_on(). In particular,
>> it overrides DMAR_FW_OFF, which no force_on may override. Please add a
>> DMAR_FORCEON_LIVEUPDATE level to dmar_can_force_on(), document where it
>> sits in the precedence, and panic if it can't be honored.
>
> See below.
>>
>>> + no_iommu = 0;
>>> + pci_request_acs();
>>
>> pci_request_acs() here comes too late for devices that have already been
>> enumerated.
>
> Hmm.. the ACS configuration of the preserved devices should also be
> preserved and pci_enable_acs() is called during driver probe so most
> devices will get it.
>
> But this is still inconsistent and it can miss the non-preserved
> devices/bridges that are probed before this point.
>
> Doing the force on properly needs the check in dmar_required(), so
> pci_request_acs() is called early like it is done for tboot and platform
> opt-in. That would require changing the point at which the KHO/LUO data
> is available during boot. Basically this:
>
> https://lore.kernel.org/all/20261005064018.1558-3-Ankit.Soni@amd.com/
>
> I think we can panic here if preserved state is found and the IOMMU is
> not enabled, instead of doing force_on, and add separate patches later
Sounds good to me. We only need to support it if a real use case arises
in the future.
> to add force on logic once the KHO/LUO stuff is moved early. This way
> the pci_request_acs() will be done at the right time also.
>
> Note that doing a check here and doing a panic() is not too late as the
> ACS configuration of the preserved devices (including their parent
> bridges) is also preserved and the IOMMU state is also intact at this
> point.
Thanks,
baolu
next prev parent reply other threads:[~2026-12-05 2:45 UTC|newest]
Thread overview: 46+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-23 4:49 [PATCH v8 00/18] iommu: Add live update state preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 01/18] liveupdate: Export symbols needed by modules Samiullah Khawaja
2026-12-04 1:45 ` Baolu Lu
2026-11-23 4:49 ` [PATCH v8 02/18] iommu: Implement IOMMU Live update FLB callbacks Samiullah Khawaja
2026-11-30 10:28 ` Ankit Soni
2026-11-30 18:40 ` Pranjal Shrivastava
2026-11-30 18:47 ` Pranjal Shrivastava
2026-12-02 21:34 ` Samiullah Khawaja
2026-12-01 22:04 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 03/18] iommu/pages: Add APIs to preserve/unpreserve/restore iommu pages Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 04/18] iommupt: Implement preserve/unpreserve/restore callbacks Samiullah Khawaja
2026-11-30 17:06 ` Dongli Zhang
2026-12-02 21:51 ` Samiullah Khawaja
2026-12-02 19:08 ` Pranjal Shrivastava
2026-11-23 4:49 ` [PATCH v8 05/18] iommu: Implement IOMMU domain preservation Samiullah Khawaja
2026-11-24 5:23 ` Ankit Soni
2026-11-24 17:40 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 06/18] iommu: Implement device and IOMMU HW preservation Samiullah Khawaja
2026-11-24 4:29 ` Ankit Soni
2026-11-24 17:40 ` Samiullah Khawaja
2026-12-04 6:14 ` Baolu Lu
2026-12-05 0:19 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 07/18] iommu/vt-d: Implement device and iommu preserve/unpreserve ops Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 08/18] iommu/vt-d: Clear unpreserved context entries during shutdown Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 09/18] iommu: Add APIs to get iommu and device restored state Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 10/18] iommu/vt-d: Combine disable_dmar_iommu() and free_dmar_iommu() Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 11/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids Samiullah Khawaja
2026-12-04 6:55 ` Baolu Lu
2026-12-05 0:03 ` Samiullah Khawaja
2026-12-05 2:45 ` Baolu Lu [this message]
2026-12-05 2:47 ` Baolu Lu
2026-11-23 4:49 ` [PATCH v8 12/18] iommu/vt-d: Preserve PASID table of preserved device Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 13/18] iommu: Restore and reattach preserved domains to devices Samiullah Khawaja
2026-11-23 5:18 ` sashiko-bot
2026-11-23 4:49 ` [PATCH v8 14/18] iommu/vt-d: Handle reattach of the restored domain Samiullah Khawaja
2026-11-23 5:03 ` sashiko-bot
2026-12-04 7:33 ` Baolu Lu
2026-12-04 22:27 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 15/18] iommufd: Implement ioctl to mark HWPT for preservation Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 16/18] iommufd: Persist iommu hardware pagetables for live update Samiullah Khawaja
2026-12-04 13:47 ` Baolu Lu
2026-12-04 21:46 ` Samiullah Khawaja
2026-11-23 4:49 ` [PATCH v8 17/18] iommufd: Add APIs to preserve/unpreserve a vfio cdev Samiullah Khawaja
2026-12-05 2:19 ` Baolu Lu
2026-11-23 4:49 ` [PATCH v8 18/18] iommufd/selftest: Add test to verify iommufd preservation Samiullah Khawaja
2026-11-23 5:11 ` sashiko-bot
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=833ec35b-e7c1-473c-a7b2-14ebda1f6aa5@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=Ankit.Soni@amd.com \
--cc=akpm@linux-foundation.org \
--cc=alex@shazbot.org \
--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=skhawaja@google.com \
--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