[RFC PATCH v2 26/32] iommu/vt-d: reclaim domain ids of the preserved devices
From: Samiullah Khawaja
Date: Tue Dec 02 2025 - 18:08:04 EST
During IOMMU unit state restore, reclaim the domain ids of the preserved
devices so these are not acquired by another device.
Signed-off-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>
---
drivers/iommu/intel/liveupdate.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/drivers/iommu/intel/liveupdate.c b/drivers/iommu/intel/liveupdate.c
index 140887187084..fc1e8545ed0e 100644
--- a/drivers/iommu/intel/liveupdate.c
+++ b/drivers/iommu/intel/liveupdate.c
@@ -92,6 +92,15 @@ static void restore_iommu_context(struct intel_iommu *iommu)
}
}
+static int __restore_used_domain_ids(struct device_ser *ser, void *arg)
+{
+ int id = ser->domain_iommu_ser.did;
+ struct intel_iommu *iommu = arg;
+
+ ida_alloc_range(&iommu->domain_ida, id, id, GFP_KERNEL);
+ return 0;
+}
+
void intel_iommu_liveupdate_restore_root_table(struct intel_iommu *iommu,
struct iommu_ser *iommu_ser)
{
@@ -99,6 +108,7 @@ void intel_iommu_liveupdate_restore_root_table(struct intel_iommu *iommu,
iommu->root_entry = __va(iommu_ser->intel.root_table);
restore_iommu_context(iommu);
+ iommu_for_each_preserved_device(__restore_used_domain_ids, iommu);
pr_info("Restored IOMMU[0x%llx] Root Table at: 0x%llx\n",
iommu->reg_phys, iommu_ser->intel.root_table);
}
--
2.52.0.158.g65b55ccf14-goog