xemu/target/s390x
Ilya Leoshkevich 066b9de4b3 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>
(cherry picked from commit e43ced8be18dda77c229ab09f85136a4d600d40d)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2025-02-01 11:59:14 +03:00
..
kvm kvm: Allow kvm_arch_get/put_registers to accept Error** 2024-10-03 22:04:19 +02:00
tcg target/s390x: Fix MVC not always invalidating translation blocks 2025-02-01 11:59:14 +03:00
Kconfig target/s390x: Add a CONFIG switch to disable legacy CPUs 2024-06-24 08:22:30 +02:00
arch_dump.c target/s390x/arch_dump: use correct byte order for pid 2024-06-24 08:13:58 +02:00
cpu-dump.c target/s390x: Prefer fast cpu_env() over slower CPU QOM cast macro 2024-02-06 10:27:50 +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-sysemu.c s390x/cpu topology: resetting the Topology-Change-Report 2023-10-20 07:16:53 +02:00
cpu.c target/s390x: Explicitly set 2-NaN propagation rule 2024-11-05 10:09:54 +00:00
cpu.h target/s390: Convert CPU to Resettable interface 2024-09-13 15:31:43 +01:00
cpu_features.c target/s390x: flag te and cte as deprecated 2024-05-10 08:34:29 +02:00
cpu_features.h target/s390x: report deprecated-props in cpu-model-expansion reply 2024-05-10 08:34:20 +02: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: correct typos 2024-02-21 08:16:58 +03:00
cpu_models.c target/s390x: Add a CONFIG switch to disable legacy CPUs 2024-06-24 08:22:30 +02: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_sysemu.c target/s390x: move @deprecated-props to CpuModelExpansion Info 2024-07-29 21:47:16 +02:00
cpu_models_user.c target/s390x: split sysemu part of cpu models 2021-07-07 14:01:59 +02:00
diag.c s390x: Rebuild IPLB for SCSI device directly from DIAG308 2024-10-23 06:53:44 +02:00
gdbstub.c target/s390x: Use explicit big-endian LD/ST API 2024-10-07 11:33:20 +02:00
gen-features.c target/s390x: AP-passthrough for PV guests 2023-09-12 11:35:46 +02:00
helper.c target/s390x: Prefer fast cpu_env() over slower CPU QOM cast macro 2024-02-06 10:27:50 +01:00
helper.h target/s390x: Simplify per_ifetch, per_check_exception 2024-05-29 12:41:15 +02:00
interrupt.c target/s390x: move kvm files into kvm/ 2021-07-07 14:01:59 +02:00
ioinst.c target/s390x: Use explicit big-endian LD/ST API 2024-10-07 11:33:20 +02:00
machine.c target/s390x: Constify VMState in machine.c 2023-12-29 11:17:30 +11:00
meson.build meson: Rename target_softmmu_arch -> target_system_arch 2023-10-07 19:03:07 +02:00
mmu_helper.c target/s390x: Use s390_skeys_get|set() helper 2024-06-19 12:42:03 +02:00
s390x-internal.h target/s390x: Fix float_comp_to_cc() prototype 2023-03-24 11:46:08 +01:00
sigp.c target/s390: Convert CPU to Resettable interface 2024-09-13 15:31:43 +01:00
trace-events target/s390x: Use s390_skeys_get|set() helper 2024-06-19 12:42:03 +02:00
trace.h trace: switch position of headers to what Meson requires 2020-08-21 06:18:24 -04:00