]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
powerpc/iommu: Fix iommu_table_in_use for a small default DMA window case
authorAlexey Kardashevskiy <aik@ozlabs.ru>
Thu, 14 Jul 2022 08:11:19 +0000 (18:11 +1000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 17 Aug 2022 12:42:11 +0000 (14:42 +0200)
commita992ba86d3bffc5307e327ba8d2fae106bb43f96
tree2f743246c9a32bb3da586d552df6420768b7ec27
parentb9f08b2649dddd4eb0698cb428b173bb01dd2fc5
powerpc/iommu: Fix iommu_table_in_use for a small default DMA window case

[ Upstream commit d80f6de9d601c30b53c17f00cb7cfe3169f2ddad ]

The existing iommu_table_in_use() helper checks if the kernel is using
any of TCEs. There are some reserved TCEs:
1) the very first one if DMA window starts from 0 to avoid having a zero
but still valid DMA handle;
2) it_reserved_start..it_reserved_end to exclude MMIO32 window in case
the default window spans across that - this is the default for the first
DMA window on PowerNV.

When 1) is the case and 2) is not the helper does not skip 1) and returns
wrong status.

This only seems occurring when passing through a PCI device to a nested
guest (not something we support really well) so it has not been seen
before.

This fixes the bug by adding a special case for no MMIO32 reservation.

Fixes: 3c33066a2190 ("powerpc/kernel/iommu: Add new iommu_table_in_use() helper")
Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220714081119.3714605-1-aik@ozlabs.ru
Signed-off-by: Sasha Levin <sashal@kernel.org>
arch/powerpc/kernel/iommu.c