qemu/target/s390x
Ilya Leoshkevich e43ced8be1 target/s390x: Fix MVC not always invalidating translation blocks
Node.js crashes in qemu-system-s390x with random SIGSEGVs / SIGILLs.

The v8 JIT used by Node.js can garbage collect and overwrite unused
code. Overwriting is performed by WritableJitAllocation::CopyCode(),
which ultimately calls memcpy(). For certain sizes, memcpy() uses the
MVC instruction.

QEMU implements MVC and other similar instructions using helpers. While
TCG store ops invalidate affected translation blocks automatically,
helpers must do this manually by calling probe_access_flags(). The MVC
helper does this using the access_prepare() -> access_prepare_nf() ->
s390_probe_access() -> probe_access_flags() call chain.

At the last step of this chain, the store size is replaced with 0. This
causes the probe_access_flags() -> notdirty_write() ->
tb_invalidate_phys_range_fast() chain to miss some translation blocks.

When this happens, QEMU executes a mix of old and new code. This
quickly leads to either a SIGSEGV or a SIGILL in case the old code
ends in the middle of a new instruction.

Fix by passing the true size.

Reported-by: Berthold Gunreben <azouhr@opensuse.org>
Cc: Sarah Kriesch <ada.lovelace@gmx.de>
Cc: qemu-stable@nongnu.org
Closes: https://bugzilla.opensuse.org/show_bug.cgi?id=1235709
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Reviewed-by: David Hildenbrand <david@redhat.com>
Fixes: e2faabee78 ("accel/tcg: Forward probe size on to notdirty_write")
Message-ID: <20250128001338.11474-1-iii@linux.ibm.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
2025-01-30 10:39:37 +01:00
..
kvm hw/s390x: Remove the cpu_model_allowed flag and related code 2025-01-07 14:51:39 +01:00
tcg target/s390x: Fix MVC not always invalidating translation blocks 2025-01-30 10:39:37 +01:00
arch_dump.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-dump.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu-param.h license: Update deprecated SPDX tag GPL-2.0+ to GPL-2.0-or-later 2024-09-20 10:11:59 +03:00
cpu-qom.h target: Move ArchCPUClass definition to 'cpu.h' 2023-11-07 13:08:48 +01:00
cpu-system.c Hi, 2024-12-22 14:33:27 -05:00
cpu.c accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core 2024-12-24 08:32:15 -08:00
cpu.h s390x: remember the maximum page size 2024-12-21 15:59:59 +01:00
cpu_features.c s390x/cpumodel: Add PLO-extension facility 2024-12-11 09:18:38 +01:00
cpu_features.h s390x/cpumodel: add Concurrent-functions facility support 2024-12-11 09:18:38 +01:00
cpu_features_def.h meson: rename .inc.h files to .h.inc 2020-08-21 06:18:35 -04:00
cpu_features_def.h.inc s390x/cpumodel: Add PLO-extension facility 2024-12-11 09:18:38 +01:00
cpu_models.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu_models.h target/s390x/cpu_models: Make kvm_s390_apply_cpu_model() return boolean 2024-04-30 06:21:47 +02:00
cpu_models_system.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
cpu_models_user.c target/s390x: split sysemu part of cpu models 2021-07-07 14:01:59 +02:00
diag.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
gdbstub.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
gen-features.c s390x/cpumodel: gen17 model 2024-12-11 09:18:38 +01:00
helper.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
helper.h target/s390x: Simplify per_ifetch, per_check_exception 2024-05-29 12:41:15 +02:00
interrupt.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
ioinst.c target/s390x: Use explicit big-endian LD/ST API 2024-10-07 11:33:20 +02:00
Kconfig target/s390x: Add a CONFIG switch to disable legacy CPUs 2024-06-24 08:22:30 +02:00
machine.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
meson.build include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
mmu_helper.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
s390x-internal.h accel/tcg: Move gen_intermediate_code to TCGCPUOps.translate_core 2024-12-24 08:32:15 -08:00
sigp.c include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
trace-events include: Rename sysemu/ -> system/ 2024-12-20 17:44:56 +01:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00