Re: [PATCH v2 09/16] iommu/vt-d: Restore IOMMU state and reclaimed domain ids
From: Samiullah Khawaja
Date: Thu May 07 2026 - 13:35:30 EST
On Thu, May 07, 2026 at 05:05:07PM +0800, Baolu Lu wrote:
On 4/28/2026 1:56 AM, 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@xxxxxxxxxx>
---
drivers/iommu/intel/iommu.c | 55 ++++++++++++++++++++++--------
drivers/iommu/intel/iommu.h | 7 ++++
drivers/iommu/intel/liveupdate.c | 57 ++++++++++++++++++++++++++++++++
3 files changed, 105 insertions(+), 14 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index 68fecd4e57fa..4118a0861f38 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -670,10 +670,17 @@ void dmar_fault_dump_ptes(struct intel_iommu *iommu, u16 source_id,
#endif
/* iommu handling */
-static int iommu_alloc_root_entry(struct intel_iommu *iommu)
+static int iommu_alloc_root_entry(struct intel_iommu *iommu,
+ struct iommu_hw_ser *iommu_ser)
{
struct root_entry *root;
+ if (iommu_ser) {
+ intel_iommu_liveupdate_restore_root_table(iommu, iommu_ser);
+ __iommu_flush_cache(iommu, iommu->root_entry, ROOT_SIZE);
The root table is already active and being used by the hardware at this
point, correct? Since the CPU should not be modifying an active table,
the __iommu_flush_cache() call seems unnecessary and potentially risky.
Furthermore, if the iommu state has been restored, is it necessary to
call iommu_set_root_entry()? Calling it would essentially replace an
active, in-use root table with an identical one, which appears
redundant.
Agreed to both points. I will remove the redundant flush here.
The set_root_entry() is done outside this function in a separate loop
after setup of all iommus, I will check whether the iommu was preserved
there and skip set_root_entry().
+ return 0;
+ }
+
root = iommu_alloc_pages_node_sz(iommu->node, GFP_ATOMIC, SZ_4K);
if (!root) {
pr_err("Allocating root entry for %s failed\n",
Thanks,
baolu