linux/drivers/vfio
Niklas Schnelle 895c0747f7 vfio/type1: Respect IOMMU reserved regions in vfio_test_domain_fgsp()
Since commit cbf7827bc5 ("iommu/s390: Fix potential s390_domain
aperture shrinking") the s390 IOMMU driver uses reserved regions for the
system provided DMA ranges of PCI devices. Previously it reduced the
size of the IOMMU aperture and checked it on each mapping operation.
On current machines the system denies use of DMA addresses below 2^32 for
all PCI devices.

Usually mapping IOVAs in a reserved regions is harmless until a DMA
actually tries to utilize the mapping. However on s390 there is
a virtual PCI device called ISM which is implemented in firmware and
used for cross LPAR communication. Unlike real PCI devices this device
does not use the hardware IOMMU but inspects IOMMU translation tables
directly on IOTLB flush (s390 RPCIT instruction). If it detects IOVA
mappings outside the allowed ranges it goes into an error state. This
error state then causes the device to be unavailable to the KVM guest.

Analysing this we found that vfio_test_domain_fgsp() maps 2 pages at DMA
address 0 irrespective of the IOMMUs reserved regions. Even if usually
harmless this seems wrong in the general case so instead go through the
freshly updated IOVA list and try to find a range that isn't reserved,
and fits 2 pages, is PAGE_SIZE * 2 aligned. If found use that for
testing for fine grained super pages.

Fixes: af029169b8 ("vfio/type1: Check reserved region conflict and update iova list")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>
Link: https://lore.kernel.org/r/20230110164427.4051938-2-schnelle@linux.ibm.com
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
2023-01-10 10:44:37 -07:00
..
fsl-mc VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
mdev vfio/mdev: add mdev available instance checking to the core 2022-10-04 12:06:58 -06:00
pci VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
platform VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
container.c vfio: Refactor dma APIs for emulated devices 2022-12-05 08:56:01 -04:00
group.c Driver Core changes for 6.2-rc1 2022-12-16 03:54:54 -08:00
iommufd.c vfio-iommufd: Support iommufd for emulated VFIO devices 2022-12-02 11:52:03 -04:00
iova_bitmap.c vfio/iova_bitmap: refactor iova_bitmap_set() to better handle page boundaries 2022-12-02 10:09:25 -07:00
Kconfig VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
Makefile VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
vfio_iommu_spapr_tce.c vfio: Move vfio_spapr_iommu_eeh_ioctl into vfio_iommu_spapr_tce.c 2022-12-05 12:04:32 -07:00
vfio_iommu_type1.c vfio/type1: Respect IOMMU reserved regions in vfio_test_domain_fgsp() 2023-01-10 10:44:37 -07:00
vfio_main.c VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
vfio.h VFIO updates for v6.2-rc1 2022-12-15 13:12:15 -08:00
virqfd.c vfio: Fold vfio_virqfd.ko into vfio.ko 2022-12-05 12:04:32 -07:00