]> www.infradead.org Git - users/dwmw2/linux.git/commit
iommu/vt-d: Fix aligned pages in calculate_psi_aligned_address()
authorLu Baolu <baolu.lu@linux.intel.com>
Tue, 9 Jul 2024 15:26:43 +0000 (23:26 +0800)
committerWill Deacon <will@kernel.org>
Wed, 10 Jul 2024 12:06:55 +0000 (13:06 +0100)
commit0a3f6b3463014b03f6ad10eacc4d1d9af75d54a1
tree90060f7e80b4fbe94628c8df38ad16c275c101e5
parentc420a2b4e8be06f16f3305472bd25a1dd12059ec
iommu/vt-d: Fix aligned pages in calculate_psi_aligned_address()

The helper calculate_psi_aligned_address() is used to convert an arbitrary
range into a size-aligned one.

The aligned_pages variable is calculated from input start and end, but is
not adjusted when the start pfn is not aligned and the mask is adjusted,
which results in an incorrect number of pages returned.

The number of pages is used by qi_flush_piotlb() to flush caches for the
first-stage translation. With the wrong number of pages, the cache is not
synchronized, leading to inconsistencies in some cases.

Fixes: c4d27ffaa8eb ("iommu/vt-d: Add cache tag invalidation helpers")
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Reviewed-by: Kevin Tian <kevin.tian@intel.com>
Link: https://lore.kernel.org/r/20240709152643.28109-3-baolu.lu@linux.intel.com
Signed-off-by: Will Deacon <will@kernel.org>
drivers/iommu/intel/cache.c