Re: [PATCH v8 11/18] iommu/vt-d: Restore IOMMU state and reclaimed domain ids
From: Baolu Lu
Date: Fri Dec 04 2026 - 21:45:18 EST
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@xxxxxxx/
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