Skip to contentSkip to conversation

iommu/vt-d: Avoid WARNING in sva unbind path

PATCH Applied Lu Baolu 3 participants 5 messages May 19 – Jun 1

Subsystems (3)
lore
Share & tools
lore

Lu Baolu

author maintainer
#0 lore raw

PATCH 1/1 iommu/vt-d: Avoid WARNING in sva unbind path

The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path.

This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf():

 WARNING: drivers/iommu/intel/iommu.c:3475 at intel_iommu_disable_iopf+0x4f/0x90d
 Call Trace:
  <TASK>
  blocking_domain_set_dev_pasid+0x50/0x70
  iommu_detach_device_pasid+0x89/0xc0
  iommu_sva_unbind_device+0x73/0x150
  xe_vm_close_and_put+0x4d2/0x1200 [xe]

Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths.

Fixes 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported")
---
 drivers/iommu/intel/iommu.h | 11 +++++++++++
 drivers/iommu/intel/svm.c   | 12 ++++--------
 2 files changed, 15 insertions(+), 8 deletions(-)
drivers/iommu/intel/iommu.h +11 -0
index ef145560aa98..775f1c4ae346 100644
@@ -1254,18 +1254,29 @@ void intel_iommu_disable_iopf(struct device *dev);
 static inline int iopf_for_domain_set(struct iommu_domain *domain,
 				      struct device *dev)
 {
+	struct device_domain_info *info = dev_iommu_priv_get(dev);
+
 	if (!domain || !domain->iopf_handler)
 		return 0;
 
+	/* SVA with non-IOMMU/PRI IOPF handling is allowed. */
+	if (domain->type == IOMMU_DOMAIN_SVA && !info->pri_supported)
+		return 0;
+
 	return intel_iommu_enable_iopf(dev);
 }
 
 static inline void iopf_for_domain_remove(struct iommu_domain *domain,
 					  struct device *dev)
 {
+	struct device_domain_info *info = dev_iommu_priv_get(dev);
+
 	if (!domain || !domain->iopf_handler)
 		return;
 
+	if (domain->type == IOMMU_DOMAIN_SVA && !info->pri_supported)
+		return;
+
 	intel_iommu_disable_iopf(dev);
 }
 
drivers/iommu/intel/svm.c +4 -8
index 57cd1db7207a..fea10acd4f02 100644
@@ -164,12 +164,9 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain,
 	if (IS_ERR(dev_pasid))
 		return PTR_ERR(dev_pasid);
 
-	/* SVA with non-IOMMU/PRI IOPF handling is allowed. */
-	if (info->pri_supported) {
-		ret = iopf_for_domain_replace(domain, old, dev);
-		if (ret)
-			goto out_remove_dev_pasid;
-	}
+	ret = iopf_for_domain_replace(domain, old, dev);
+	if (ret)
+		goto out_remove_dev_pasid;
 
 	/* Setup the pasid table: */
 	sflags = cpu_feature_enabled(X86_FEATURE_LA57) ? PASID_FLAG_FL5LP : 0;
@@ -184,8 +181,7 @@ static int intel_svm_set_dev_pasid(struct iommu_domain *domain,
 
 	return 0;
 out_unwind_iopf:
-	if (info->pri_supported)
-		iopf_for_domain_replace(old, domain, dev);
+	iopf_for_domain_replace(old, domain, dev);
 out_remove_dev_pasid:
 	domain_remove_dev_pasid(domain, dev, pasid);
 	return ret;
Signature · 1 line
2.43.0
Reviewed-by on v1 1/1
#1 lore raw
Quoted 23 lines

From: Lu Baolu <[email protected]>
Sent: Tuesday, May 19, 2026 1:29 PM

The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when
PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path.

This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf():

 WARNING: drivers/iommu/intel/iommu.c:3475 at
intel_iommu_disable_iopf+0x4f/0x90d
 Call Trace:
  <TASK>
  blocking_domain_set_dev_pasid+0x50/0x70
  iommu_detach_device_pasid+0x89/0xc0
  iommu_sva_unbind_device+0x73/0x150
  xe_vm_close_and_put+0x4d2/0x1200 [xe]
Quoted 8 lines

Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths.

Fixes 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is

supported")

#2 lore raw
In reply to Lu Baolu
Quoted 37 lines · Lu Baolu

The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path.

This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf():

  WARNING: drivers/iommu/intel/iommu.c:3475 at intel_iommu_disable_iopf+0x4f/0x90d
  Call Trace:
   <TASK>
   blocking_domain_set_dev_pasid+0x50/0x70
   iommu_detach_device_pasid+0x89/0xc0
   iommu_sva_unbind_device+0x73/0x150
   xe_vm_close_and_put+0x4d2/0x1200 [xe]

Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths.

Fixes 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported")
---
  drivers/iommu/intel/iommu.h | 11 +++++++++++
  drivers/iommu/intel/svm.c   | 12 ++++--------
  2 files changed, 15 insertions(+), 8 deletions(-)
drivers/iommu/intel/iommu.h +0 -0
index ef145560aa98..775f1c4ae346 100644
@@ -1254,18 +1254,29 @@ void intel_iommu_disable_iopf(struct device *dev);
  static inline int iopf_for_domain_set(struct iommu_domain *domain,
  				      struct device *dev)

drivers/iommu/intel/iommu.h void intel_iommu_disable_iopf(struct device *dev); · line 1265

Quoted 10 lines
drivers/iommu/intel/iommu.h +6 -0
  {
+	struct device_domain_info *info = dev_iommu_priv_get(dev);
+
  	if (!domain || !domain->iopf_handler)
  		return 0;
 
+	/* SVA with non-IOMMU/PRI IOPF handling is allowed. */
+	if (domain->type == IOMMU_DOMAIN_SVA && !info->pri_supported)
+		return 0;
+

Looked into the history a bit, and this story begins with commit a86fb7717320 ("iommu/vt-d: Allow SVA with device-specific IOPF"). This commit enabled devices that support their own IOPF mechanism to use SVA even when the platform IOMMU doesn't support IOPF.

However, SVA isn't the only fault-capable domain type. Other fault-capable domain types (e.g., paging domains) should also be able to leverage device-specific IOPF capabilities.

My question is: can we drop the domain type check to support other types of fault-capable domains that rely on device-specific IOPF?

Regards,
Yi Liu

author maintainer
#3 lore raw
Quoted 54 lines · Yi Liu
Quoted 37 lines · Lu Baolu

The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path.

This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf():

  WARNING: drivers/iommu/intel/iommu.c:3475 at intel_iommu_disable_iopf+0x4f/0x90d
  Call Trace:
   <TASK>
   blocking_domain_set_dev_pasid+0x50/0x70
   iommu_detach_device_pasid+0x89/0xc0
   iommu_sva_unbind_device+0x73/0x150
   xe_vm_close_and_put+0x4d2/0x1200 [xe]

Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths.

Fixes 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported")

---
  drivers/iommu/intel/iommu.h | 11 +++++++++++
  drivers/iommu/intel/svm.c   | 12 ++++--------

  2 files changed, 15 insertions(+), 8 deletions(-)
drivers/iommu/intel/iommu.h +0 -0
index ef145560aa98..775f1c4ae346 100644
@@ -1254,18 +1254,29 @@ void intel_iommu_disable_iopf(struct device 
 *dev);
   static inline int iopf_for_domain_set(struct iommu_domain *domain,

drivers/iommu/intel/iommu.h void intel_iommu_disable_iopf(struct device · line 1265

Quoted 10 lines
drivers/iommu/intel/iommu.h +6 -0
                         struct device *dev)
   {
+    struct device_domain_info *info = dev_iommu_priv_get(dev);
+
       if (!domain || !domain->iopf_handler)
           return 0;
+    /* SVA with non-IOMMU/PRI IOPF handling is allowed. */
+    if (domain->type == IOMMU_DOMAIN_SVA && !info->pri_supported)
+        return 0;
+

Looked into the history a bit, and this story begins with commit a86fb7717320 ("iommu/vt-d: Allow SVA with device-specific IOPF"). This commit enabled devices that support their own IOPF mechanism to use SVA even when the platform IOMMU doesn't support IOPF.

Quoted 6 lines

However, SVA isn't the only fault-capable domain type. Other fault-capable domain types (e.g., paging domains) should also be able to leverage device-specific IOPF capabilities.

My question is: can we drop the domain type check to support other types of fault-capable domains that rely on device-specific IOPF?

The Intel IOMMU driver treats the SVA case as a special case. It allows an SVA domain with a registered iopf_handler to attach to a device for SVA functionality. Broadly speaking, it would be better to handle this in the IOMMU core — for example, by preventing the attachment of a fault-capable domain to a device that lacks IOMMU-backed page fault capabilities.

Thanks,
baolu

author maintainer Applied
#4 lore raw
In reply to Lu Baolu
Quoted 21 lines · Lu Baolu

The Intel IOMMU driver allows SVA on devices even if they do not support PCI/PRI. Commit 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported") modified the SVA bind path to allow this configuration by skipping IOPF enablement when PRI is missing. However, it failed to update the unbind path.

This creates an imbalance: the unbind path attempts to disable IOPF for a device that never had it enabled, triggering a WARNING in intel_iommu_disable_iopf():

  WARNING: drivers/iommu/intel/iommu.c:3475 at intel_iommu_disable_iopf+0x4f/0x90d
  Call Trace:
   <TASK>
   blocking_domain_set_dev_pasid+0x50/0x70
   iommu_detach_device_pasid+0x89/0xc0
   iommu_sva_unbind_device+0x73/0x150
   xe_vm_close_and_put+0x4d2/0x1200 [xe]

Fix this by bypassing IOPF operations for SVA domains on non-PRI hardware in both the bind and unbind paths.

Quoted 8 lines
Fixes 39c20c4e83b9 ("iommu/vt-d: Only handle IOPF for SVA when PRI is supported")
---
  drivers/iommu/intel/iommu.h | 11 +++++++++++
  drivers/iommu/intel/svm.c   | 12 ++++--------
  2 files changed, 15 insertions(+), 8 deletions(-)

Queued for linux-next.