iommu.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] iommu/vt-d: Flush piotlb for SVM and Nested domain
@ 2025-12-08  9:19 Yi Liu
  2025-12-08 15:50 ` kernel test robot
  2025-12-12  7:57 ` Tian, Kevin
  0 siblings, 2 replies; 5+ messages in thread
From: Yi Liu @ 2025-12-08  9:19 UTC (permalink / raw)
  To: kevin.tian, baolu.lu; +Cc: joro, yi.l.liu, iommu, jgg

For SVM and Nested domain, needs to use piotlb invalidation descriptor.

Fixes: b33125296b50 ("iommu/vt-d: Create unique domain ops for each stage")
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
---
 drivers/iommu/intel/cache.c  |  3 ++-
 drivers/iommu/intel/iommu.h  | 10 +++++++++-
 drivers/iommu/intel/nested.c |  2 +-
 drivers/iommu/intel/svm.c    |  2 +-
 4 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/drivers/iommu/intel/cache.c b/drivers/iommu/intel/cache.c
index 265e7290256b..bf6ebf7c4ca5 100644
--- a/drivers/iommu/intel/cache.c
+++ b/drivers/iommu/intel/cache.c
@@ -370,7 +370,8 @@ 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_is_fs_paging(domain) ||
+	    intel_domain_is_nested_paging(domain)) {
 		qi_batch_add_piotlb(iommu, tag->domain_id, tag->pasid, addr,
 				    pages, ih, domain->qi_batch);
 		return;
diff --git a/drivers/iommu/intel/iommu.h b/drivers/iommu/intel/iommu.h
index 3056583d7f56..3b655af211a9 100644
--- a/drivers/iommu/intel/iommu.h
+++ b/drivers/iommu/intel/iommu.h
@@ -1379,10 +1379,18 @@ struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
 extern const struct iommu_ops intel_iommu_ops;
 extern const struct iommu_domain_ops intel_fs_paging_domain_ops;
 extern const struct iommu_domain_ops intel_ss_paging_domain_ops;
+extern const struct iommu_domain_ops intel_svm_domain_ops;
+extern const struct iommu_domain_ops intel_nested_domain_ops;
 
 static inline bool intel_domain_is_fs_paging(struct dmar_domain *domain)
 {
-	return domain->domain.ops == &intel_fs_paging_domain_ops;
+	return (domain->domain.ops == &intel_fs_paging_domain_ops) ||
+	       (domain->domain.ops == &intel_svm_domain_ops);
+}
+
+static inline bool intel_domain_is_nested_paging(struct dmar_domain *domain)
+{
+	return (domain->domain.ops == &intel_nested_domain_ops);
 }
 
 static inline bool intel_domain_is_ss_paging(struct dmar_domain *domain)
diff --git a/drivers/iommu/intel/nested.c b/drivers/iommu/intel/nested.c
index 1b6ad9c900a5..cc755af1bd6b 100644
--- a/drivers/iommu/intel/nested.c
+++ b/drivers/iommu/intel/nested.c
@@ -191,7 +191,7 @@ static int intel_nested_set_dev_pasid(struct iommu_domain *domain,
 	return ret;
 }
 
-static const struct iommu_domain_ops intel_nested_domain_ops = {
+const struct iommu_domain_ops intel_nested_domain_ops = {
 	.attach_dev		= intel_nested_attach_dev,
 	.set_dev_pasid		= intel_nested_set_dev_pasid,
 	.free			= intel_nested_domain_free,
diff --git a/drivers/iommu/intel/svm.c b/drivers/iommu/intel/svm.c
index e147f71f91b7..75b9475c33dd 100644
--- a/drivers/iommu/intel/svm.c
+++ b/drivers/iommu/intel/svm.c
@@ -194,7 +194,7 @@ static void intel_svm_domain_free(struct iommu_domain *domain)
 	mmu_notifier_put(&dmar_domain->notifier);
 }
 
-static const struct iommu_domain_ops intel_svm_domain_ops = {
+const struct iommu_domain_ops intel_svm_domain_ops = {
 	.set_dev_pasid		= intel_svm_set_dev_pasid,
 	.free			= intel_svm_domain_free
 };
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-12-12 10:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-08  9:19 [PATCH] iommu/vt-d: Flush piotlb for SVM and Nested domain Yi Liu
2025-12-08 15:50 ` kernel test robot
2025-12-09  4:13   ` Yi Liu
2025-12-12  7:57 ` Tian, Kevin
2025-12-12 10:49   ` Yi Liu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).