Skip to content

Commit 0a3f6b3

Browse files
LuBaoluwilldeacon
authored andcommitted
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: c4d27ff ("iommu/vt-d: Add cache tag invalidation helpers") Signed-off-by: Lu Baolu <[email protected]> Reviewed-by: Kevin Tian <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent c420a2b commit 0a3f6b3

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

drivers/iommu/intel/cache.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ static unsigned long calculate_psi_aligned_address(unsigned long start,
246246
*/
247247
shared_bits = ~(pfn ^ end_pfn) & ~bitmask;
248248
mask = shared_bits ? __ffs(shared_bits) : MAX_AGAW_PFN_WIDTH;
249+
aligned_pages = 1UL << mask;
249250
}
250251

251252
*_pages = aligned_pages;

0 commit comments

Comments
 (0)