linux-user: Allow mapping low priority rt signals
v3 cover linux-user: Allow mapping low priority rt signals
v1: Unfortunately lost.
v2: https://lore.kernel.org/qemu-devel/[email protected]/
v2 -> v3: Make the mapping configurable (Richard).
Hi,
There are apps out there that want to use SIGRTMAX, which linux-user currently does not map to a host signal. The reason is that with the current approach it's not possible to map all target signals, so it was decided to sacrifice the end of the range.
This series improves the situation by making the mapping configurable. Patch 1 is the implementation, patch 2 is a test.
Best regards,
Ilya
Ilya Leoshkevich (2):
linux-user: Allow custom rt signal mappings
tests/tcg: Add SIGRTMIN/SIGRTMAX test
linux-user/main.c | 12 +- linux-user/signal-common.h | 2 +- linux-user/signal.c | 108 ++++++++++++++---- meson.build | 3 +- meson_options.txt | 2 + scripts/meson-buildoptions.sh | 2 + tests/tcg/Makefile.target | 4 +- tests/tcg/multiarch/linux/linux-sigrtminmax.c | 74 ++++++++++++ 8 files changed, 182 insertions(+), 25 deletions(-) create mode 100644 tests/tcg/multiarch/linux/linux-sigrtminmax.c
Signature · 1 line
2.47.0
PATCH v3 1/2 linux-user: Allow custom rt signal mappings
Some applications want to use low priority realtime signals (e.g., SIGRTMAX). Currently QEMU cannot map all target realtime signals to host realtime signals, and chooses to sacrifice the end of the target realtime signal range.
Allow users to choose how to map target realtime signals to host realtime signals using the new -t option, the new QEMU_RTSIG_MAP environment variable, and the new -Drtsig_map=\"...\" meson flag. To simplify things, the meson flag is not per-target, because the intended use case is app-specific qemu-user builds.
The mapping is specified using the "tsig hsig count[,...]" syntax. Target realtime signals [tsig,tsig+count) are mapped to host realtime signals [hsig,hsig+count). Care is taken to avoid double and out-of-range mappings.
--- linux-user/main.c | 12 +++- linux-user/signal-common.h | 2 +- linux-user/signal.c | 108 +++++++++++++++++++++++++++------- meson.build | 3 +- meson_options.txt | 2 + scripts/meson-buildoptions.sh | 2 + 6 files changed, 106 insertions(+), 23 deletions(-)
linux-user/main.c +11 -1
@@ -412,6 +412,13 @@ static void handle_arg_reserved_va(const char *arg) reserved_va = val ? val -1 :0 ; } +static const char *rtsig_map =CONFIG_QEMU_RTSIG_MAP ; + +static void handle_arg_rtsig_map (const char *arg) +{ + rtsig_map = arg; +} +static void handle_arg_one_insn_per_tb (const char *arg) { opt_one_insn_per_tb = true;
@@ -494,6 +501,9 @@ static const struct qemu_argument arg_table[] = { "address", "set guest_base address to 'address'"}, {"R" ,"QEMU_RESERVED_VA" , true, handle_arg_reserved_va, "size", "reserve 'size' bytes for guest virtual address space"}, + {"t", "QEMU_RTSIG_MAP", true, handle_arg_rtsig_map, +"tsig hsig n[,...]" , + "map target rt signals [tsig,tsig+n) to [hsig,hsig+n]"}, {"d", "QEMU_LOG", true, handle_arg_log,"item[,...]" ,"enable logging of specified items " "(use '-d help' for a list of items)"},
@@ -1002,7 +1012,7 @@ int main(int argc, char **argv, char **envp)target_set_brk (info->brk);syscall_init (); -signal_init (); +signal_init (rtsig_map);/* Now that we've loaded the binary, GUEST_BASE is fixed. Delay generating the prologue until now so that the prologue can take
linux-user/signal-common.h +1 -1
@@ -56,7 +56,7 @@ void setup_rt_frame(int sig, struct target_sigaction *ka, target_sigset_t *set, CPUArchState *env);void process_pending_signals (CPUArchState *cpu_env); -void signal_init (void ); +void signal_init (const char *rtsig_map);void queue_signal (CPUArchState *env,int sig,int si_type,target_siginfo_t *info);void host_to_target_siginfo (target_siginfo_t *tinfo,const siginfo_t *info);
linux-user/signal.c +88 -20
148 lines not on this page · raw message
meson.build +2 -1
@@ -3167,7 +3167,8 @@ foreach target : target_dirs config_target += { 'CONFIG_USER_ONLY': 'y', 'CONFIG_QEMU_INTERP_PREFIX': - get_option('interp_prefix').replace('%M', config_target['TARGET_NAME']) + get_option('interp_prefix').replace('%M', config_target['TARGET_NAME']), + 'CONFIG_QEMU_RTSIG_MAP': get_option('rtsig_map'), } endif
meson_options.txt +2 -0
@@ -27,6 +27,8 @@ option('block_drv_ro_whitelist', type : 'string', value : '', description: 'set block driver read-only whitelist (by default affects only QEMU, not tools like qemu-img)') option('interp_prefix', type : 'string', value : '/usr/gnemul/qemu-%M', description: 'where to find shared libraries etc., use %M for cpu name') +option('rtsig_map', type : 'string', value : 'NULL', + description: 'default value of QEMU_RTSIG_MAP') option('fuzzing_engine', type : 'string', value : '', description: 'fuzzing engine library for OSS-Fuzz') option('trace_file', type: 'string', value: 'trace',
scripts/meson-buildoptions.sh +2 -0
@@ -72,6 +72,7 @@ meson_options_help() { printf "%s\n" ' "manufacturer" name for qemu-ga registry entries' printf "%s\n" ' [QEMU]' printf "%s\n" ' --qemu-ga-version=VALUE version number for qemu-ga installer' + printf "%s\n" ' --rtsig-map=VALUE default value of QEMU_RTSIG_MAP [NULL]' printf "%s\n" ' --smbd=VALUE Path to smbd for slirp networking' printf "%s\n" ' --sysconfdir=VALUE Sysconf data directory [etc]' printf "%s\n" ' --tls-priority=VALUE Default TLS protocol/cipher priority string'
@@ -457,6 +458,7 @@ _meson_option_parse() { --disable-replication) printf "%s" -Dreplication=disabled ;; --enable-rng-none) printf "%s" -Drng_none=true ;; --disable-rng-none) printf "%s" -Drng_none=false ;; + --rtsig-map=*) quote_sh "-Drtsig_map=$2" ;; --enable-rust) printf "%s" -Drust=enabled ;; --disable-rust) printf "%s" -Drust=disabled ;; --enable-rutabaga-gfx) printf "%s" -Drutabaga_gfx=enabled ;;
Signature · 1 line
2.47.0
Re: [PATCH v3 1/2] linux-user: Allow custom rt signal mappings
Quoted 17 lines · Ilya Leoshkevich
Some applications want to use low priority realtime signals (e.g., SIGRTMAX). Currently QEMU cannot map all target realtime signals to host realtime signals, and chooses to sacrifice the end of the target realtime signal range.
Allow users to choose how to map target realtime signals to host realtime signals using the new -t option, the new
QEMU_RTSIG_MAPenvironment variable, and the new -Drtsig_map=\"...\" meson flag. To simplify things, the meson flag is not per-target, because the intended use case is app-specific qemu-user builds.The mapping is specified using the "tsig hsig count[,...]" syntax. Target realtime signals [tsig,tsig+count) are mapped to host realtime signals [hsig,hsig+count). Care is taken to avoid double and out-of-range mappings.
Signed-off-by Ilya Leoshkevich<[email protected]>
Quoted 8 lines
--- linux-user/main.c | 12 +++- linux-user/signal-common.h | 2 +- linux-user/signal.c | 108 +++++++++++++++++++++++++++------- meson.build | 3 +- meson_options.txt | 2 + scripts/meson-buildoptions.sh | 2 + 6 files changed, 106 insertions(+), 23 deletions(-)
r~
PATCH v3 2/2 tests/tcg: Add SIGRTMIN/SIGRTMAX test
In reply to Ilya LeoshkevichTest the lowest and the highest real-time signals. This requires configuring the real-time signal mapping, and therefore some knowledge about the host. To this end, pass the emulator path in the QEMU environment variable to all tests (this should not disturb the existing ones), and assume that all hosts have signals 36-39 available.
--- tests/tcg/Makefile.target | 4 +- tests/tcg/multiarch/linux/linux-sigrtminmax.c | 74 +++++++++++++++++++ 2 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 tests/tcg/multiarch/linux/linux-sigrtminmax.c
tests/tcg/Makefile.target +2 -2
@@ -179,10 +179,10 @@ run-plugin-%-with-libmem.so: PLUGIN_ARGS=$(COMMA)inline=true ifeq ($(filter %-softmmu, $(TARGET)),) run-%: % - $(call run-test, $<, $(QEMU) $(QEMU_OPTS) $<) + $(call run-test, $<, env QEMU=$(QEMU) $(QEMU) $(QEMU_OPTS) $<) run-plugin-%: - $(call run-test, $@, $(QEMU) $(QEMU_OPTS) \ + $(call run-test, $@, env QEMU=$(QEMU) $(QEMU) $(QEMU_OPTS) \ -plugin $(PLUGIN_LIB)/$(call extract-plugin,$@)$(PLUGIN_ARGS) \ -d plugin -D $*.pout \ $(call strip-plugin,$<))
tests/tcg/multiarch/linux/linux-sigrtminmax.c new file +74 -0
74 lines not on this page · raw message
Signature · 1 line
2.47.0
Quoted 15 lines · Ilya Leoshkevich
v1: Unfortunately lost.
v2:https://lore.kernel.org/qemu-devel/[email protected]/ v2 -> v3: Make the mapping configurable (Richard).
Hi,
There are apps out there that want to use SIGRTMAX, which linux-user currently does not map to a host signal. The reason is that with the current approach it's not possible to map all target signals, so it was decided to sacrifice the end of the range.
This series improves the situation by making the mapping configurable. Patch 1 is the implementation, patch 2 is a test.
Quoted 6 lines
Best regards,
IlyaIlya Leoshkevich (2):
linux-user: Allow custom rt signal mappings
tests/tcg: Add SIGRTMIN/SIGRTMAX test
Thanks, queued.
r~