From nobody Thu Nov 13 13:37:44 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 158056017943279.80000966700345; Sat, 1 Feb 2020 04:29:39 -0800 (PST) Received: from localhost ([::1]:45624 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixru6-0002sD-4k for importer@patchew.org; Sat, 01 Feb 2020 07:29:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51797) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrsy-0001VU-Ky for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixrsw-0001zJ-HA for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:27 -0500 Received: from mout.kundenserver.de ([212.227.126.187]:55499) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixrsu-0001pD-Va for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:26 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1Mzz6s-1jjnGp42nG-00x5A6; Sat, 01 Feb 2020 13:27:54 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH 4/4] linux-user: fix use of SIGRTMIN Date: Sat, 1 Feb 2020 13:27:46 +0100 Message-Id: <20200201122746.1478003-5-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200201122746.1478003-1-laurent@vivier.eu> References: <20200201122746.1478003-1-laurent@vivier.eu> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Provags-ID: V03:K1:uZvkDltmplsVxV9Exg8Kxxvw24erQUxYov1pUBuC/j8lafDsly+ UilvZAL8JzwbrxsoYImkxI6jyM+z+xlkdme05yogHsUXUSngYLVcmnv+qmilg8LA/KmG/AI c6haOJebBNzj0NJBZxA9YrRfLwzpdc2PTyNEx3ta7j/fbmY7WrOEVbFRmLhBKtjrcx/O550 UOZOY0/8W7o03WlheMmHw== X-UI-Out-Filterresults: notjunk:1;V03:K0:sidQ/StkU1M=:NKl/OWvunHRjA7l9h25j5/ 4uO7yHhCvfzU9Nf2urBPcfFBVBVE+Cs5MJ4FwRd32VdB1aI3ElOBA0H5lLFmoMRttXJAEz9jN l6Ctb/iiH3MGMui5pH+/zYSYQG0P6WDUvMNt+IEq64f/KP1WIznNRyBqpPrauPQVvCjkJ2X2G 04Ks/MkbQW6HEusPAtExy+PUxzPLCYKfnYI2V9UYbvtWLklXEiJsVD7oJi54p60ydeYVX75Q7 F/6f7orWScbWHXhLZYae3vYO7818C21t6nfNODyZ7nYOu9b+dh69+Ff2i5sHYlw/MSKR8o4bE TVNIXA5Zbn4Hkd6RTi8wUYa2InqX8OQGixrXpZ2ino/e5m39NPxTSeUZ8ZGTRvbJkh22Isdo7 liYjJKiVWy2+aJa4YdQamFeKHY/VSXh++0PnMLb5tbyGcted6LKRoyS/tqJ3dxq4biwBRgi3E jhzo+Sg79BuH8kW6e0jIaqThW81O25X3QR9sw0VrgbY8WNOG7/DxazV0dIKkRe+zv7Yx2ttLx qYjyBZ2PXrF+SPoxKMAAOsGUfY+uw3j/2FS1KVlaSjH4q+VMdn4CGkre7eEGxsgnT1UQCDbyt /5qxhWuTikUyYA9iNqeR7NezQiCU+ttRpeDwpHAbh4BR2UabJ/fy/SHV5JziXtcLm+rnkHMyz 7HGOivOJ2oTdO2HObY+FbFIMAcZuqo2V4hZvDfJSK6dLC8BGvj4tn3uwIiQzidgNM/tdi3P4y ckWT+M9w1GOVIzinUpmBqJIrX+ZgK6gGci0QnwqwnDw5CtPaRoJxnsqmTABUgeMUiz21r/xDg vmUyJZZSFR3KZD/o/ThR99kfwNxZpfMTrEgTePv8WIpNkbZP4rPtAt52HXBmaKBr0/lcG+z X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.187 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Marlies Ruck , Riku Voipio , Laurent Vivier , Aleksandar Markovic , Josh Kunz , Taylor Simpson , Matus Kysel , milos.stojanovic@rt-rk.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Some RT signals can be in use by glibc, it's why SIGRTMIN (34) is generally greater than __SIGRTMIN (32). So SIGRTMIN cannot be mapped to TARGET_SIGRTMIN. Instead of swapping only SIGRTMIN and SIGRTMAX, map all the range [TARGET_SIGRTMIN ... TARGET_SIGRTMAX - X] to [__SIGRTMIN + X ... SIGRTMAX ] (SIGRTMIN is __SIGRTMIN + X). Signed-off-by: Laurent Vivier --- linux-user/signal.c | 34 ++++++++++++++++++++++++++++------ linux-user/trace-events | 3 +++ 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 3491f0a7ecb1..c4abacde49a0 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -501,15 +501,20 @@ static void signal_table_init(void) int i, j; =20 /* - * Nasty hack: Reverse SIGRTMIN and SIGRTMAX to avoid overlap with - * host libpthread signals. This assumes no one actually uses SIGRTMA= X :-/ - * To fix this properly we need to do manual signal delivery multiplex= ed - * over a single host signal. + * some RT signals can be in use by glibc, + * it's why SIGRTMIN (34) is generally greater than __SIGRTMIN (32) */ - host_to_target_signal_table[__SIGRTMIN] =3D __SIGRTMAX; - host_to_target_signal_table[__SIGRTMAX] =3D __SIGRTMIN; + for (i =3D SIGRTMIN; i <=3D SIGRTMAX; i++) { + j =3D i - SIGRTMIN + TARGET_SIGRTMIN; + if (j <=3D TARGET_NSIG) { + host_to_target_signal_table[i] =3D j; + } + } =20 /* generate signal conversion tables */ + for (i =3D 1; i <=3D TARGET_NSIG; i++) { + target_to_host_signal_table[i] =3D _NSIG; /* poison */ + } for (i =3D 1; i < _NSIG; i++) { if (host_to_target_signal_table[i] =3D=3D 0) { host_to_target_signal_table[i] =3D i; @@ -519,6 +524,15 @@ static void signal_table_init(void) target_to_host_signal_table[j] =3D i; } } + + if (TRACE_SIGNAL_TABLE_INIT_BACKEND_DSTATE()) { + for (i =3D 1, j =3D 0; i <=3D TARGET_NSIG; i++) { + if (target_to_host_signal_table[i] =3D=3D _NSIG) { + j++; + } + } + trace_signal_table_init(j); + } } =20 void signal_init(void) @@ -817,6 +831,8 @@ int do_sigaction(int sig, const struct target_sigaction= *act, int host_sig; int ret =3D 0; =20 + trace_signal_do_sigaction_guest(sig, TARGET_NSIG); + if (sig < 1 || sig > TARGET_NSIG || sig =3D=3D TARGET_SIGKILL || sig = =3D=3D TARGET_SIGSTOP) { return -TARGET_EINVAL; } @@ -847,6 +863,12 @@ int do_sigaction(int sig, const struct target_sigactio= n *act, =20 /* we update the host linux signal state */ host_sig =3D target_to_host_signal(sig); + trace_signal_do_sigaction_host(host_sig, TARGET_NSIG); + if (host_sig > SIGRTMAX) { + /* we don't have enough host signals to map all target signals= */ + qemu_log_mask(LOG_UNIMP, "Unsupported target signal #%d\n", si= g); + return -TARGET_EINVAL; + } if (host_sig !=3D SIGSEGV && host_sig !=3D SIGBUS) { sigfillset(&act1.sa_mask); act1.sa_flags =3D SA_SIGINFO; diff --git a/linux-user/trace-events b/linux-user/trace-events index f6de1b8befc0..eb4b7701c400 100644 --- a/linux-user/trace-events +++ b/linux-user/trace-events @@ -1,6 +1,9 @@ # See docs/devel/tracing.txt for syntax documentation. =20 # signal.c +signal_table_init(int i) "missing signal number: %d" +signal_do_sigaction_guest(int sig, int max) "target signal %d (MAX %d)" +signal_do_sigaction_host(int sig, int max) "host signal %d (MAX %d)" # */signal.c user_setup_frame(void *env, uint64_t frame_addr) "env=3D%p frame_addr=3D0x= %"PRIx64 user_setup_rt_frame(void *env, uint64_t frame_addr) "env=3D%p frame_addr= =3D0x%"PRIx64 --=20 2.24.1