summary refs log tree commit diff stats
path: root/linux-user/main.c
diff options
context:
space:
mode:
authorIlya Leoshkevich <iii@linux.ibm.com>2024-10-30 00:17:47 +0100
committerRichard Henderson <richard.henderson@linaro.org>2024-11-05 10:36:08 +0000
commitc107521e0ee9ea1744f674a79d02d3d5ea2ba98c (patch)
treeaf3793e5dc52a2d96aeb3fc1143146cc173e7ef1 /linux-user/main.c
parent6e9dcfb906f734b1e5b44d4ca2fac0a87bbac777 (diff)
downloadfocaccia-qemu-c107521e0ee9ea1744f674a79d02d3d5ea2ba98c.tar.gz
focaccia-qemu-c107521e0ee9ea1744f674a79d02d3d5ea2ba98c.zip
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>
Diffstat (limited to 'linux-user/main.c')
-rw-r--r--linux-user/main.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/linux-user/main.c b/linux-user/main.c
index 8143a0d4b0..b09af8d436 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -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