Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

powerpc/powernv/ioda: Return correct error if TCE level allocation failed

The iommu_table_ops::xchg_no_kill() callback updates TCE. It is quite
possible that not entire table is allocated if it is huge and multilevel
so xchg may also allocate subtables. If failed, it returns H_HARDWARE
for failed allocation and H_TOO_HARD if it needs it but cannot do because
the alloc parameter is "false" (set when called with MMU=off to force
retry with MMU=on).

The problem is that having separate errors only matters in real mode
(MMU=off) but the only caller with alloc="false" does not check the exact
error code and simply returns H_TOO_HARD; and for every other mode
alloc is "true". Also, the function is also called from the ioctl()
handler of the VFIO SPAPR TCE IOMMU subdriver which does not expect
hypervisor error codes (H_xxx) and will expose them to the userspace.

This converts wrong error codes to -ENOMEM.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200617003835.48831-1-aik@ozlabs.ru

authored by

Alexey Kardashevskiy and committed by
Michael Ellerman
5f202c1a 178748b6

+1 -1
+1 -1
arch/powerpc/platforms/powernv/pci-ioda-tce.c
··· 166 166 if (!ptce) { 167 167 ptce = pnv_tce(tbl, false, idx, alloc); 168 168 if (!ptce) 169 - return alloc ? H_HARDWARE : H_TOO_HARD; 169 + return -ENOMEM; 170 170 } 171 171 172 172 if (newtce & TCE_PCI_WRITE)