android_kernel_xiaomi_sm8450/arch/s390
Niklas Schnelle b55808b96e s390/pci: fix max size calculation in zpci_memcpy_toio()
[ Upstream commit 80df7d6af7f6d229b34cf237b2cc9024c07111cd ]

The zpci_get_max_write_size() helper is used to determine the maximum
size a PCI store or load can use at a given __iomem address.

For the PCI block store the following restrictions apply:

1. The dst + len must not cross a 4K boundary in the (pseudo-)MMIO space
2. len must not exceed ZPCI_MAX_WRITE_SIZE
3. len must be a multiple of 8 bytes
4. The src address must be double word (8 byte) aligned
5. The dst address must be double word (8 byte) aligned

Otherwise only a normal PCI store which takes its src value from
a register can be used. For these PCI store restriction 1 still applies.
Similarly 1 also applies to PCI loads.

It turns out zpci_max_write_size() instead implements stricter
conditions which prevents PCI block stores from being used where they
can and should be used. In particular instead of conditions 4 and 5 it
wrongly enforces both dst and src to be size aligned. This indirectly
covers condition 1 but also prevents many legal PCI block stores.

On top of the functional shortcomings the zpci_get_max_write_size() is
misnamed as it is used for both read and write size calculations. Rename
it to zpci_get_max_io_size() and implement the listed conditions
explicitly.

Reviewed-by: Matthew Rosato <mjrosato@linux.ibm.com>
Fixes: cd24834130 ("s390/pci: base support")
Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
[agordeev@linux.ibm.com replaced spaces with tabs]
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-01-25 14:37:55 -08:00
..
appldata s390/appldata: use struct_size() helper 2020-06-29 16:32:34 +02:00
boot s390/ipl: add missing intersection check to ipl_report handling 2023-03-22 13:30:05 +01:00
configs s390: update defconfigs 2020-11-12 12:10:36 +01:00
crypto s390/paes: fix PKEY_TYPE_EP11_AES handling for secure keyblobs 2023-09-19 12:20:07 +02:00
hypfs s390/hypfs: avoid error message under KVM 2022-09-05 10:28:57 +02:00
include s390/pci: fix max size calculation in zpci_memcpy_toio() 2024-01-25 14:37:55 -08:00
kernel s390/ipl: add missing secure/has_secure file to ipl type 'unknown' 2023-09-19 12:20:22 +02:00
kvm KVM: s390: fix sthyi error handling 2023-08-11 11:57:47 +02:00
lib s390/uaccess: add missing earlyclobber annotations to __clear_user() 2023-04-05 11:23:51 +02:00
mm KVM: s390/mm: Properly reset no-dat 2023-12-13 18:27:05 +01:00
net bpf, s390: Fix potential memory leak about jit_data 2021-10-13 10:04:29 +02:00
oprofile s390/unwind: introduce stack unwind API 2019-05-02 13:54:11 +02:00
pci s390/pci: fix max size calculation in zpci_memcpy_toio() 2024-01-25 14:37:55 -08:00
purgatory s390/purgatory: disable branch profiling 2023-06-28 10:28:15 +02:00
tools .gitignore: add SPDX License Identifier 2020-03-25 11:50:48 +01:00
Kbuild s390/numa: move code to arch/s390/kernel 2020-08-11 18:16:55 +02:00
Kconfig s390: remove unneeded 'select BUILD_BIN2C' 2022-07-07 17:52:18 +02:00
Kconfig.debug s390/mm,ptdump: convert to generic page table dumper 2020-09-14 11:38:34 +02:00
Makefile s390/decompressor: fix misaligned symbol build error 2023-07-27 08:44:31 +02:00