Skip to content

Commit c420a2b

Browse files
LuBaoluwilldeacon
authored andcommitted
iommu/vt-d: Limit max address mask to MAX_AGAW_PFN_WIDTH
Address mask specifies the number of low order bits of the address field that must be masked for the invalidation operation. Since address bits masked start from bit 12, the max address mask should be MAX_AGAW_PFN_WIDTH, as defined in Table 19 ("Invalidate Descriptor Address Mask Encodings") of the spec. Limit the max address mask returned from calculate_psi_aligned_address() to MAX_AGAW_PFN_WIDTH to prevent potential integer overflow in the following code: qi_flush_dev_iotlb(): ... addr |= (1ULL << (VTD_PAGE_SHIFT + mask - 1)) - 1; ... 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 3753311 commit c420a2b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/iommu/intel/cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ static unsigned long calculate_psi_aligned_address(unsigned long start,
245245
* shared_bits are all equal in both pfn and end_pfn.
246246
*/
247247
shared_bits = ~(pfn ^ end_pfn) & ~bitmask;
248-
mask = shared_bits ? __ffs(shared_bits) : BITS_PER_LONG;
248+
mask = shared_bits ? __ffs(shared_bits) : MAX_AGAW_PFN_WIDTH;
249249
}
250250

251251
*_pages = aligned_pages;

0 commit comments

Comments
 (0)