android_kernel_motorola_sm6225/arch/s390
Niklas Schnelle 138da55940 s390/pci: fix iommu bitmap allocation
commit c1ae1c59c8c6e0b66a718308c623e0cb394dab6b upstream.

Since the fixed commits both zdev->iommu_bitmap and zdev->lazy_bitmap
are allocated as vzalloc(zdev->iommu_pages / 8). The problem is that
zdev->iommu_bitmap is a pointer to unsigned long but the above only
yields an allocation that is a multiple of sizeof(unsigned long) which
is 8 on s390x if the number of IOMMU pages is a multiple of 64.
This in turn is the case only if the effective IOMMU aperture is
a multiple of 64 * 4K = 256K. This is usually the case and so didn't
cause visible issues since both the virt_to_phys(high_memory) reduced
limit and hardware limits use nice numbers.

Under KVM, and in particular with QEMU limiting the IOMMU aperture to
the vfio DMA limit (default 65535), it is possible for the reported
aperture not to be a multiple of 256K however. In this case we end up
with an iommu_bitmap whose allocation is not a multiple of
8 causing bitmap operations to access it out of bounds.

Sadly we can't just fix this in the obvious way and use bitmap_zalloc()
because for large RAM systems (tested on 8 TiB) the zdev->iommu_bitmap
grows too large for kmalloc(). So add our own bitmap_vzalloc() wrapper.
This might be a candidate for common code, but this area of code will
be replaced by the upcoming conversion to use the common code DMA API on
s390 so just add a local routine.

Fixes: 2245932155 ("s390/pci: use virtual memory for iommu bitmap")
Fixes: 13954fd691 ("s390/pci_dma: improve lazy flush for unmap")
Cc: stable@vger.kernel.org
Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-25 11:17:02 +02:00
..
appldata s390/appldata: reuse generic proc handler functions 2018-07-06 08:48:08 +02:00
boot s390: make 'install' not depend on vmlinux 2020-03-11 14:14:53 +01:00
configs s390: update defconfigs 2018-04-27 06:51:31 +02:00
crypto s390/archrandom: simplify back to earlier design and initialize earlier 2022-07-07 17:35:09 +02:00
hypfs s390/hypfs: avoid error message under KVM 2022-09-05 10:26:34 +02:00
include s390/percpu: add READ_ONCE() to arch_this_cpu_to_op_simple() 2023-01-18 11:30:52 +01:00
kernel KVM: s390: fix sthyi error handling 2023-08-11 11:45:37 +02:00
kvm KVM: s390: fix sthyi error handling 2023-08-11 11:45:37 +02:00
lib s390/uaccess: add missing earlyclobber annotations to __clear_user() 2023-04-05 11:15:42 +02:00
mm s390/maccess: add no DAT mode to kernel_write 2023-03-11 16:32:02 +01:00
net s390/bpf: Fix optimizing out zero-extensions 2021-09-26 13:39:46 +02:00
numa s390/mm: Fix ERROR: "__node_distance" undefined! 2018-11-27 16:13:03 +01:00
oprofile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
pci s390/pci: fix iommu bitmap allocation 2023-10-25 11:17:02 +02:00
purgatory s390/kexec_file: fix diag308 subcode when loading crash kernel 2020-12-30 11:26:09 +01:00
scripts s390/build: add *.o.chkbss files to targets list 2018-07-02 12:32:23 +02:00
tools Minor code cleanups for PPC. 2018-08-19 10:38:36 -07:00
defconfig crypto: speck - remove Speck 2018-11-13 11:08:46 -08:00
Kbuild s390/kexec_file: Add purgatory 2018-04-16 09:10:22 +02:00
Kconfig s390: appldata depends on PROC_SYSCTL 2021-07-20 16:15:55 +02:00
Kconfig.debug Kconfig: consolidate the "Kernel hacking" menu 2018-08-02 08:06:48 +09:00
Makefile s390: disable -Warray-bounds 2022-05-18 09:42:49 +02:00