You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
qemu/tcg
Markus Armbruster 82b5e6cc30 tcg: Fix error reporting on mprotect() failure in tcg_region_init()
tcg_region_init() calls one of qemu_mprotect_rwx(),
qemu_mprotect_rw(), and mprotect(), then reports failure with
error_setg_errno(&error_fatal, errno, ...).

The use of &error_fatal is undesirable.  qapi/error.h advises:

 * Please don't error_setg(&error_fatal, ...), use error_report() and
 * exit(), because that's more obvious.

The use of errno is wrong.  qemu_mprotect_rwx() and qemu_mprotect_rw()
wrap around qemu_mprotect__osdep().  qemu_mprotect__osdep() calls
mprotect() on POSIX, VirtualProtect() on Windows, and reports failure
with error_report().  VirtualProtect() doesn't set errno.  mprotect()
does, but error_report() may clobber it.

Fix tcg_region_init() to report errors only when it calls mprotect(),
and rely on qemu_mprotect_rwx()'s and qemu_mprotect_rw()'s error
reporting otherwise.  Use error_report(), not error_setg().

Fixes: 22c6a9938f (tcg: Merge buffer protection and guard page protection)
Fixes: 6bc144237a (tcg: Use Error with alloc_code_gen_buffer)
Cc: Richard Henderson <richard.henderson@linaro.org>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20250923091000.3180122-3-armbru@redhat.com>
Reviewed-by: Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
3 weeks ago
..
aarch64 include/hw/core/cpu: Introduce cpu_tlb_fast 4 weeks ago
arm include/hw/core/cpu: Introduce cpu_tlb_fast 4 weeks ago
i386 tcg/i386: Use vgf2p8affineqb for MO_8 vector shifts 2 months ago
loongarch64 tcg: Drop TCGContext.page_{mask,bits} 5 months ago
mips tcg: Drop TCGContext.page_{mask,bits} 5 months ago
ppc tcg: Drop TCGContext.page_{mask,bits} 5 months ago
riscv tcg/riscv: Fix typo in tgen_extract 4 months ago
s390x tcg: Drop TCGContext.page_{mask,bits} 5 months ago
sparc64 tcg: Drop TCGContext.page_{mask,bits} 5 months ago
tci tcg: Remove tcg_out_op 6 months ago
debuginfo.c accel/tcg: Move perf and debuginfo support to tcg/ 2 years ago
meson.build meson: remove lib{system, user}_ss aliases 5 months ago
optimize.c tcg/optimize: Fix folding of vector bitsel 4 weeks ago
perf.c tcg: Drop TCGContext.page_{mask,bits} 5 months ago
region.c tcg: Fix error reporting on mprotect() failure in tcg_region_init() 3 weeks ago
tcg-common.c tcg: Constify tcg_op_defs 9 months ago
tcg-has.h tcg: Remove add2/sub2 opcodes 6 months ago
tcg-internal.h tcg: Add TCGType to tcg_op_insert_{after,before} 6 months ago
tcg-op-gvec.c tcg: Split out tcg_gen_gvec_dup_imm_var 4 months ago
tcg-op-ldst.c tcg: Add tcg_gen_atomic_{xchg,fetch_and,fetch_or}_i128 2 months ago
tcg-op-vec.c tcg: Only include 'tcg-has.h' when necessary 9 months ago
tcg-op.c tcg: Merge INDEX_op_st*_{i32,i64} 6 months ago
tcg.c include/hw/core/cpu: Invert the indexing into CPUTLBDescFast 4 weeks ago
tci.c tcg: Merge INDEX_op_{ld,st}_{i32,i64,i128} 6 months ago