mirror-linux/drivers/iommu/intel
Eugene Koira dce043c07c iommu/vt-d: Fix __domain_mapping()'s usage of switch_to_super_page()
switch_to_super_page() assumes the memory range it's working on is aligned
to the target large page level. Unfortunately, __domain_mapping() doesn't
take this into account when using it, and will pass unaligned ranges
ultimately freeing a PTE range larger than expected.

Take for example a mapping with the following iov_pfn range [0x3fe400,
0x4c0600), which should be backed by the following mappings:

   iov_pfn [0x3fe400, 0x3fffff] covered by 2MiB pages
   iov_pfn [0x400000, 0x4bffff] covered by 1GiB pages
   iov_pfn [0x4c0000, 0x4c05ff] covered by 2MiB pages

Under this circumstance, __domain_mapping() will pass [0x400000, 0x4c05ff]
to switch_to_super_page() at a 1 GiB granularity, which will in turn
free PTEs all the way to iov_pfn 0x4fffff.

Mitigate this by rounding down the iov_pfn range passed to
switch_to_super_page() in __domain_mapping()
to the target large page level.

Additionally add range alignment checks to switch_to_super_page.

Fixes: 9906b9352a ("iommu/vt-d: Avoid duplicate removing in __domain_mapping()")
Signed-off-by: Eugene Koira <eugkoira@amazon.com>
Cc: stable@vger.kernel.org
Reviewed-by: Nicolas Saenz Julienne <nsaenz@amazon.com>
Reviewed-by: David Woodhouse <dwmw@amazon.co.uk>
Link: https://lore.kernel.org/r/20250826143816.38686-1-eugkoira@amazon.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
2025-09-05 15:11:08 +02:00
..
Kconfig iommu/vt-d: Move IOMMU_IOPF into INTEL_IOMMU 2024-11-05 13:32:26 +01:00
Makefile iommu: make inclusion of intel directory conditional 2025-05-16 08:46:46 +02:00
cache.c IOMMU Updates for Linux v6.17: 2025-07-30 10:42:00 -07:00
debugfs.c iommu/vt-d: Remove debugfs use of private data field 2024-04-26 11:57:38 +02:00
dmar.c iommu/vt-d: Remove the CONFIG_X86 wrapping from iommu init hook 2025-07-14 11:18:03 +01:00
iommu.c iommu/vt-d: Fix __domain_mapping()'s usage of switch_to_super_page() 2025-09-05 15:11:08 +02:00
iommu.h IOMMU Updates for Linux v6.17: 2025-07-30 10:42:00 -07:00
irq_remapping.c ARM: 2025-07-30 17:14:01 -07:00
nested.c iommu/vt-d: Create unique domain ops for each stage 2025-07-14 11:18:03 +01:00
pasid.c iommu/vt-d: Lift the __pa to domain_setup_first_level/intel_svm_set_dev_pasid() 2025-07-14 11:18:03 +01:00
pasid.h iommu/vt-d: Lift the __pa to domain_setup_first_level/intel_svm_set_dev_pasid() 2025-07-14 11:18:03 +01:00
perf.c iommu/vt-d: Use kcalloc() instead of kzalloc() 2024-03-01 13:51:18 +01:00
perf.h iommu/vt-d: Remove debugfs use of private data field 2024-04-26 11:57:38 +02:00
perfmon.c iommu/vt-d: Clean up cpumask and hotplug for perfmon 2024-09-10 11:44:13 +02:00
perfmon.h
prq.c iommu/vtd: Remove iommu_alloc_pages_node() 2025-04-17 16:22:54 +02:00
svm.c iommu/vt-d: Create unique domain ops for each stage 2025-07-14 11:18:03 +01:00
trace.c
trace.h iommu/vt-d: Deduplicate cache_tag_flush_all by reusing flush_range 2025-07-14 11:18:04 +01:00