Skip to contentSkip to conversation

iommu/vt-d: Remove redundant SLTS cap check for nested and dirty tracking

PATCH In review Wei Wang 2 participants 2 messages Jun 5, 2025 – Jun 6, 2025

Subsystems (2)
lore
Share & tools
lore

Wei Wang

author
#0 lore raw

PATCH 1/1 iommu/vt-d: Remove redundant SLTS cap check for nested and dirty tracking

In intel_iommu_domain_alloc_paging_flags():
For the nested_parent case, nested_supported() has been check earlier, and for the dirty_tracking case, ssads_supported() has been check earlier. Both of these imply SLTS support, making the subsequent SLTS cap check redundant.
Also, false-initialize the first_stage boolean to simplify the code.

---
 drivers/iommu/intel/iommu.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)
drivers/iommu/intel/iommu.c +2 -7
index 7aa3932251b2..a79f91b47a8a 100644
@@ -3340,7 +3340,7 @@ intel_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
 	struct intel_iommu *iommu = info->iommu;
 	struct dmar_domain *dmar_domain;
 	struct iommu_domain *domain;
-	bool first_stage;
+	bool first_stage = false;
 
 	if (flags &
 	    (~(IOMMU_HWPT_ALLOC_NEST_PARENT | IOMMU_HWPT_ALLOC_DIRTY_TRACKING |
@@ -3356,13 +3356,8 @@ intel_iommu_domain_alloc_paging_flags(struct device *dev, u32 flags,
 	 * IOMMU_HWPT_ALLOC_NEST_PARENT or IOMMU_HWPT_ALLOC_DIRTY_TRACKING
 	 * is specified.
 	 */
-	if (nested_parent || dirty_tracking) {
-		if (!sm_supported(iommu) || !ecap_slts(iommu->ecap))
-			return ERR_PTR(-EOPNOTSUPP);
-		first_stage = false;
-	} else {
+	if (!nested_parent && !dirty_tracking)
 		first_stage = first_level_by_default(iommu);
-	}
 
 	dmar_domain = paging_domain_alloc(dev, first_stage);
 	if (IS_ERR(dmar_domain))

base-commit: 16b70698aa3ae7888826d0c84567c72241cf6713

Signature · 1 line
2.43.0
#1 lore raw
Quoted 11 lines · Wei Wang

In intel_iommu_domain_alloc_paging_flags():
For the nested_parent case, nested_supported() has been check earlier, and for the dirty_tracking case, ssads_supported() has been check earlier. Both of these imply SLTS support, making the subsequent SLTS cap check redundant.
Also, false-initialize the first_stage boolean to simplify the code.

---
 drivers/iommu/intel/iommu.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

I'm going to post a patch that fixes this (and the other one you sent) differently next week:

https://github.com/jgunthorpe/linux/commits/iommu_pt_vtd/

iommu/vtd: Split intel_iommu_domain_alloc_paging_flags()

Jason