Skip to content

Commit 7aafac1

Browse files
aikmpe
authored andcommitted
powerpc/powernv/ioda2: Gracefully fail if too many TCE levels requested
The IODA2 specification says that a 64 DMA address cannot use top 4 bits (3 are reserved and one is a "TVE select"); bottom page_shift bits cannot be used for multilevel table addressing either. The existing IODA2 table allocation code aligns the minimum TCE table size to PAGE_SIZE so in the case of 64K system pages and 4K IOMMU pages, we have 64-4-12=48 bits. Since 64K page stores 8192 TCEs, i.e. needs 13 bits, the maximum number of levels is 48/13 = 3 so we physically cannot address more and EEH happens on DMA accesses. This adds a check that too many levels were requested. It is still possible to have 5 levels in the case of 4K system page size. Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru> Acked-by: Gavin Shan <gwshan@linux.vnet.ibm.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
1 parent 605df8d commit 7aafac1

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/powerpc/platforms/powernv/pci-ioda.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2624,6 +2624,9 @@ static long pnv_pci_ioda2_table_alloc_pages(int nid, __u64 bus_offset,
26242624
level_shift = entries_shift + 3;
26252625
level_shift = max_t(unsigned, level_shift, PAGE_SHIFT);
26262626

2627+
if ((level_shift - 3) * levels + page_shift >= 60)
2628+
return -EINVAL;
2629+
26272630
/* Allocate TCE table */
26282631
addr = pnv_pci_ioda2_table_do_alloc_pages(nid, level_shift,
26292632
levels, tce_table_size, &offset, &total_allocated);

0 commit comments

Comments
 (0)