Skip to contentSkip to conversation

iommu/vt-d: Allow zero SAGAW if second-stage not supported

PATCH In review Lu Baolu 2 participants 3 messages Mar 18, 2023 – Mar 24, 2023

Subsystems (2)
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

PATCH 1/1 iommu/vt-d: Allow zero SAGAW if second-stage not supported

The VT-d spec states (section 11.4.2) that hardware implementations reporting second-stage translation support (SSTS) field as Clear also report the SAGAW field as 0. Reflect this in the sanity check of alloc_iommu().

Fixes 792fb43ce2c9 ("iommu/vt-d: Enable Intel IOMMU scalable mode by default")
---
 drivers/iommu/intel/dmar.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +2 -1
index 6acfe879589c..23828d189c2a 100644
@@ -1071,7 +1071,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
 	}
 
 	err = -EINVAL;
-	if (cap_sagaw(iommu->cap) == 0) {
+	if (!cap_sagaw(iommu->cap) &&
+	    (!ecap_smts(iommu->ecap) || ecap_slts(iommu->ecap))) {
 		pr_info("%s: No supported address widths. Not attempting DMA translation.\n",
 			iommu->name);
 		drhd->ignored = 1;
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 31 lines

From: Lu Baolu <[email protected]>
Sent: Saturday, March 18, 2023 10:48 AM

The VT-d spec states (section 11.4.2) that hardware implementations reporting second-stage translation support (SSTS) field as Clear also report the SAGAW field as 0. Reflect this in the sanity check of alloc_iommu().

Fixes 792fb43ce2c9 ("iommu/vt-d: Enable Intel IOMMU scalable mode by

default")

---
 drivers/iommu/intel/dmar.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +2 -1
index 6acfe879589c..23828d189c2a 100644
@@ -1071,7 +1071,8 @@ static int alloc_iommu(struct dmar_drhd_unit
 *drhd)
 	}
 
 	err = -EINVAL;
-	if (cap_sagaw(iommu->cap) == 0) {
+	if (!cap_sagaw(iommu->cap) &&
+	    (!ecap_smts(iommu->ecap) || ecap_slts(iommu->ecap))) {
 		pr_info("%s: No supported address widths. Not attempting
 DMA translation.\n",

drivers/iommu/intel/dmar.c static int alloc_iommu(struct dmar_drhd_unit *drhd) · line 1078

Quoted 2 lines
drivers/iommu/intel/dmar.c +0 -0
 			iommu->name);
 		drhd->ignored = 1;

btw I wonder whether it's cleaner to record separate agaw values for stage1/stage2 instead of picking a minimal set from both in __iommu_calculate_sagaw().

author maintainer
#2 lore raw
Quoted 36 lines · Kevin
Quoted 31 lines

From: Lu Baolu <[email protected]>
Sent: Saturday, March 18, 2023 10:48 AM

The VT-d spec states (section 11.4.2) that hardware implementations reporting second-stage translation support (SSTS) field as Clear also report the SAGAW field as 0. Reflect this in the sanity check of alloc_iommu().

Fixes 792fb43ce2c9 ("iommu/vt-d: Enable Intel IOMMU scalable mode by

default")

---
  drivers/iommu/intel/dmar.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +2 -1
index 6acfe879589c..23828d189c2a 100644
@@ -1071,7 +1071,8 @@ static int alloc_iommu(struct dmar_drhd_unit
 *drhd)
  	}
 
  	err = -EINVAL;
-	if (cap_sagaw(iommu->cap) == 0) {
+	if (!cap_sagaw(iommu->cap) &&
+	    (!ecap_smts(iommu->ecap) || ecap_slts(iommu->ecap))) {
  		pr_info("%s: No supported address widths. Not attempting
 DMA translation.\n",
Quoted 2 lines
  			iommu->name);
  		drhd->ignored = 1;
Quoted 3 lines

btw I wonder whether it's cleaner to record separate agaw values for stage1/stage2 instead of picking a minimal set from both in __iommu_calculate_sagaw().

That's better. The agaw could be picked according to which stage the domain is used for translation.

Best regards,
baolu