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.

Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-ID: <20241029232211.206766-2-iii@linux.ibm.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
This commit is contained in:
Ilya Leoshkevich 2024-10-30 00:17:47 +01:00 committed by Richard Henderson
parent 6e9dcfb906
commit c107521e0e
6 changed files with 106 additions and 23 deletions

View file

@ -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