Skip to contentSkip to conversation

iommu/vt-d: Flush piotlb for SVM and Nested domain

PATCH In review Yi Liu 3 participants 3 messages Dec 23, 2025 – Jan 20

Subsystems (2)
lore
Share & tools
lore

Yi Liu

author
#0 lore raw

PATCH v2 1/1 iommu/vt-d: Flush piotlb for SVM and Nested domain

Besides the paging domains that use FS, SVM and Nested domains need to use piotlb invalidation descriptor as well.

Fixes b33125296b50 ("iommu/vt-d: Create unique domain ops for each stage")

---
Change log:
v2:
- Use domain.type to filter nested and SVA type domain. This eliminates the SVA domain ops reference issue when SVM is compiled out. (Kevin)
- Add a intel_domain_use_piotlb() helper to cover the three cases which need to flush piotlb. (Kevin)

v1: https://lore.kernel.org/linux-iommu/[email protected]/

---
 drivers/iommu/intel/cache.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iommu/intel/cache.c +8 -1
index 265e7290256b..385ae5cfb30d 100644
@@ -363,6 +363,13 @@ static void qi_batch_add_pasid_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16
 	qi_batch_increment_index(iommu, batch);
 }
 
+static bool intel_domain_use_piotlb(struct dmar_domain *domain)
+{
+	return domain->domain.type == IOMMU_DOMAIN_SVA ||
+			domain->domain.type == IOMMU_DOMAIN_NESTED ||
+			intel_domain_is_fs_paging(domain);
+}
+
 static void cache_tag_flush_iotlb(struct dmar_domain *domain, struct cache_tag *tag,
 				  unsigned long addr, unsigned long pages,
 				  unsigned long mask, int ih)
@@ -370,7 +377,7 @@ static void cache_tag_flush_iotlb(struct dmar_domain *domain, struct cache_tag *
 	struct intel_iommu *iommu = tag->iommu;
 	u64 type = DMA_TLB_PSI_FLUSH;
 
-	if (intel_domain_is_fs_paging(domain)) {
+	if (intel_domain_use_piotlb(domain)) {
 		qi_batch_add_piotlb(iommu, tag->domain_id, tag->pasid, addr,
 				    pages, ih, domain->qi_batch);
 		return;
Signature · 1 line
2.43.0
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines

From: Liu, Yi L <[email protected]>
Sent: Tuesday, December 23, 2025 2:58 PM

Besides the paging domains that use FS, SVM and Nested domains need to use piotlb invalidation descriptor as well.

Fixes b33125296b50 ("iommu/vt-d: Create unique domain ops for each

stage")

cc stable

Quoted 28 lines

---
Change log:
v2:
- Use domain.type to filter nested and SVA type domain. This eliminates the SVA domain ops reference issue when SVM is compiled out. (Kevin)
- Add a intel_domain_use_piotlb() helper to cover the three cases which need to flush piotlb. (Kevin)

v1: https://lore.kernel.org/linux-iommu/20251208091907.74719-1-
[email protected]/

---
 drivers/iommu/intel/cache.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
drivers/iommu/intel/cache.c +0 -0
index 265e7290256b..385ae5cfb30d 100644
@@ -363,6 +363,13 @@ static void qi_batch_add_pasid_dev_iotlb(struct

intel_iommu *iommu, u16 sid, u16

drivers/iommu/intel/cache.c +4 -0
 	qi_batch_increment_index(iommu, batch);
 }
 
+static bool intel_domain_use_piotlb(struct dmar_domain *domain)
+{
+	return domain->domain.type == IOMMU_DOMAIN_SVA ||
+			domain->domain.type == IOMMU_DOMAIN_NESTED

||

drivers/iommu/intel/cache.c static void qi_batch_add_pasid_dev_iotlb(struct intel_iommu *iommu, u16 sid, u16 · line 370

Quoted 1 line
drivers/iommu/intel/cache.c +1 -0
+			intel_domain_is_fs_paging(domain);

for readability:
intel_domain_is_sva()
intel_domain_is_nested()

otherwise,

maintainer
#2 lore raw
In reply to Yi Liu
Quoted 13 lines · Yi Liu

Besides the paging domains that use FS, SVM and Nested domains need to use piotlb invalidation descriptor as well.

Fixes b33125296b50 ("iommu/vt-d: Create unique domain ops for each stage")

---
Change log:
v2:
- Use domain.type to filter nested and SVA type domain. This eliminates the SVA domain ops reference issue when SVM is compiled out. (Kevin)
- Add a intel_domain_use_piotlb() helper to cover the three cases which need to flush piotlb. (Kevin)

Quoted 4 lines

v1:https://lore.kernel.org/linux-iommu/20251208091907.74719-1- [email protected]/

---
  drivers/iommu/intel/cache.c | 9 ++++++++-
  1 file changed, 8 insertions(+), 1 deletion(-)

Queued for iommu next.

Thanks,
baolu