s390/checksum: always use cksm instruction
authorHeiko Carstens <hca@linux.ibm.com>
Thu, 30 Mar 2023 10:55:46 +0000 (12:55 +0200)
committerVasily Gorbik <gor@linux.ibm.com>
Thu, 13 Apr 2023 15:36:25 +0000 (17:36 +0200)
commite42ac7789df64120d7d3d57433dfc9f37ec0cb99
tree5ef63c7760ad3ee38fd8ac0d684ced4041d104f1
parentb94c0ebb1ec752016a3e41bfb66bb51ea905e533
s390/checksum: always use cksm instruction

Commit dfe843dce775 ("s390/checksum: support GENERIC_CSUM, enable it for
KASAN") switched s390 to use the generic checksum functions, so that KASAN
instrumentation also works checksum functions by avoiding architecture
specific inline assemblies.

There is however the problem that the generic csum_partial() function
returns a 32 bit value with a 16 bit folded checksum, while the original
s390 variant does not fold to 16 bit. This in turn causes that the
ipib_checksum in lowcore contains different values depending on kernel
config options.

The ipib_checksum is used by system dumpers to verify if pointers in
lowcore point to valid data. Verification is done by comparing checksum
values. The system dumpers still use 32 bit checksum values which are not
folded, and therefore the checksum verification fails (incorrectly).

Symptom is that reboot after dump does not work anymore when a KASAN
instrumented kernel is dumped.

Fix this by not using the generic checksum implementation. Instead add an
explicit kasan_check_read() so that KASAN knows about the read access from
within the inline assembly.

Reported-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Fixes: dfe843dce775 ("s390/checksum: support GENERIC_CSUM, enable it for KASAN")
Tested-by: Alexander Egorenkov <egorenar@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
arch/s390/Kconfig
arch/s390/include/asm/checksum.h