iommu/vt-d: Flush piotlb for SVM and Nested domain
Subsystems (2)
PATCH 1/1 iommu/vt-d: Flush piotlb for SVM and Nested domain
For SVM and Nested domain, needs to use piotlb invalidation descriptor.
--- 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(-)
drivers/iommu/intel/cache.c +2 -1
@@ -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 ;
drivers/iommu/intel/iommu.h +9 -1
@@ -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)
drivers/iommu/intel/nested.c +1 -1
@@ -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,
drivers/iommu/intel/svm.c +1 -1
@@ -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 };
Signature · 1 line
2.34.1
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Yi,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.18 next-20251208]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Yi-Liu/iommu-vt-d-Flush-piotlb-for-SVM-and-Nested-domain/20251208-172359 base: linus/master patch link: https://lore.kernel.org/r/20251208091907.74719-1-yi.l.liu%40intel.com patch subject: [PATCH] iommu/vt-d: Flush piotlb for SVM and Nested domain config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20251208/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251208/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
ld: vmlinux.o: in function `dmar_domain_attach_device':
>> iommu.c:(.text+0x70aa38): undefined reference to `intel_svm_domain_ops' ld: vmlinux.o: in function `paging_domain_compatible': >> (.text+0x70ab8f): undefined reference to `intel_svm_domain_ops' ld: vmlinux.o: in function `intel_iommu_set_dev_pasid': iommu.c:(.text+0x70b487): undefined reference to `intel_svm_domain_ops' ld: vmlinux.o: in function `cache_tag_flush_iotlb': >> cache.c:(.text+0x70e74a): undefined reference to `intel_svm_domain_ops'
ld: vmlinux.o: in function `cache_tag_flush_range_np':
(.text+0x70f2d3): undefined reference to `intel_svm_domain_ops'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 27 lines · kernel test robot
Hi Yi,
kernel test robot noticed the following build errors:
[auto build test ERROR on linus/master]
[also build test ERROR on v6.18 next-20251208]
[If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]url: https://github.com/intel-lab-lkp/linux/commits/Yi-Liu/iommu-vt-d-Flush-piotlb-for-SVM-and-Nested-domain/20251208-172359 base: linus/master patch link: https://lore.kernel.org/r/20251208091907.74719-1-yi.l.liu%40intel.com patch subject: [PATCH] iommu/vt-d: Flush piotlb for SVM and Nested domain config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20251208/[email protected]/config) compiler: gcc-14 (Debian 14.2.0-19) 14.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20251208/[email protected]/reproduce)If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/All errors (new ones prefixed by >>):
ld: vmlinux.o: in function `dmar_domain_attach_device':
Quoted 1 line
Quoted 1 line
iommu.c:(.text+0x70aa38): undefined reference to `intel_svm_domain_ops'
Quoted 9 lines
ld: vmlinux.o: in function `paging_domain_compatible':
Quoted 1 line
Quoted 1 line
(.text+0x70ab8f): undefined reference to `intel_svm_domain_ops'
ld: vmlinux.o: in function `intel_iommu_set_dev_pasid':
iommu.c:(.text+0x70b487): undefined reference to `intel_svm_domain_ops'
ld: vmlinux.o: in function `cache_tag_flush_iotlb':Quoted 1 line
Quoted 1 line
cache.c:(.text+0x70e74a): undefined reference to `intel_svm_domain_ops'
ld: vmlinux.o: in function `cache_tag_flush_range_np':
(.text+0x70f2d3): undefined reference to `intel_svm_domain_ops'
hmmm. this happens when CONFIG_INTEL_IOMMU_SVM is not Y. will fix it thanks.
Quoted 12 lines
From: Liu, Yi L <[email protected]>
Sent: Monday, December 8, 2025 5:19 PMstatic inline bool
intel_domain_is_fs_paging(struct dmar_domain *domain){drivers/iommu/intel/iommu.h +5
-1-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)
drivers/iommu/intel/iommu.h struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, · line 1394
Quoted 3 lines
drivers/iommu/intel/iommu.h +2
-0+{ +return (domain->domain.ops == &intel_nested_domain_ops); }
hmm it's confusing to have a _paging name covering svm/nesting type.
they are different types.
Instead it's clearer to introduce a new helper e.g. intel_domain_use_piotlb() which covers both fs_paging, svm, and nesting types together.
and for svm/nesting just check their domain types instead of referencing to the domain ops.
Quoted 17 lines · Kevin
Quoted 12 lines
From: Liu, Yi L <[email protected]>
Sent: Monday, December 8, 2025 5:19 PMstatic inline bool intel_domain_is_fs_paging(struct dmar_domain *domain) {drivers/iommu/intel/iommu.h +5
-1-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)
drivers/iommu/intel/iommu.h struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus, · line 1394
Quoted 3 lines
drivers/iommu/intel/iommu.h +2
-0+{ +return (domain->domain.ops == &intel_nested_domain_ops); }hmm it's confusing to have a
_pagingname covering svm/nesting type.
got it. tbh. I had a long standing impression that paging==translation. But I think it is incorrect.
Quoted 7 lines
they are different types.
Instead it's clearer to introduce a new helper e.g.
intel_domain_use_piotlb()which covers bothfs_paging, svm, and nesting types together.and for svm/nesting just check their domain types instead of referencing to the domain ops.
got it.