linux-stable/arch/s390
Thomas Richter 97dfb89415 s390/cpum_cf: Fix endless loop in CF_DIAG event stop
[ Upstream commit e6ce1f12d7 ]

Event CF_DIAG reads out complete counter sets using stcctm
instruction. This is done at event start time when the process
starts execution and at event stop time when the process is
removed from the CPU. During removal the difference of each
counter in the counter sets is calculated and saved as raw data
in the ring buffer. This works fine unless the number of counters
in a counter set is zero. This may happen for the extended counter
set. This set is machine specific and the size of the counter
set can be zero even when extended counter set is authorized for
read access.

This case is not handled. cfdiag_diffctr() checks authorization
of the extended counter set. If true the functions assumes
the extended counter set has been saved in a data buffer. However
this is not the case, cfdiag_getctrset() does not save a counter
set with counter set size of zero. This mismatch causes an endless
loop in the counter set readout during event stop handling.

The calculation of the difference of the counters in each counter
now verifies the size of the counter set is non-zero. A counter set
with size zero is skipped.

Fixes: a029a4eab3 ("s390/cpumf: Allow concurrent access for CPU Measurement Counter Facility")
Signed-off-by: Thomas Richter <tmricht@linux.ibm.com>
Acked-by: Sumanth Korikkar <sumanthk@linux.ibm.com>
Acked-by: Heiko Carstens <hca@linux.ibm.com>
Cc: Heiko Carstens <hca@linux.ibm.com>
Cc: Vasily Gorbik <gor@linux.ibm.com>
Cc: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
2024-08-03 08:54:41 +02:00
..
appldata sysctl: Add size to register_sysctl 2023-08-15 15:26:17 -07:00
boot s390/boot: Remove alt_stfle_fac_list from decompressor 2024-06-12 11:12:33 +02:00
configs cred: get rid of CONFIG_DEBUG_CREDENTIALS 2023-12-20 17:01:51 +01:00
crypto crypto: s390/aes - Fix buffer overread in CTR mode 2024-01-31 16:18:50 -08:00
hypfs s390 updates for 6.6 merge window 2023-08-28 17:22:39 -07:00
include s390: Mark psw in __load_psw_mask() as __unitialized 2024-07-18 13:21:15 +02:00
kernel s390/cpum_cf: Fix endless loop in CF_DIAG event stop 2024-08-03 08:54:41 +02:00
kvm KVM: s390: fix LPSWEY handling 2024-07-11 12:49:12 +02:00
lib s390: replace #include <asm/export.h> with #include <linux/export.h> 2023-08-09 15:20:50 +02:00
mm s390/mm: Fix VM_FAULT_HWPOISON handling in do_exception() 2024-08-03 08:54:34 +02:00
net Revert "bpf: Take return from set_memory_rox() into account with bpf_jit_binary_lock_ro()" 2024-07-09 11:44:29 +02:00
pci s390/pci: Allow allocation of more than 1 MSI interrupt 2024-08-03 08:54:41 +02:00
purgatory s390 updates for 6.5 merge window part 2 2023-07-06 13:18:30 -07:00
tools KVM: s390: Add facility 197 to the allow list 2022-07-13 15:25:25 +02:00
Kbuild - An extensive rework of kexec and crash Kconfig from Eric DeVolder 2023-08-29 14:53:51 -07:00
Kconfig kexec: fix KEXEC_FILE dependencies 2024-01-05 15:19:41 +01:00
Kconfig.debug s390/Kconfig.debug: fix indentation 2022-06-01 12:03:15 +02:00
Makefile kbuild: unify vdso_install rules 2024-06-12 11:12:32 +02:00