From nobody Mon Feb 9 19:33:15 2026 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 1580560171163347.6650514543403; Sat, 1 Feb 2020 04:29:31 -0800 (PST) Received: from localhost ([::1]:45618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrty-0002Yo-0t for importer@patchew.org; Sat, 01 Feb 2020 07:29:30 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51732) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrsn-0001IT-RS for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ixrsm-0001PL-LB for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:17 -0500 Received: from mout.kundenserver.de ([212.227.126.133]:55259) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixrsm-0001HM-CP for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:16 -0500 Received: from localhost.localdomain ([78.238.229.36]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MA7Ss-1irm0r22oM-00BaCo; Sat, 01 Feb 2020 13:27:51 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH 1/4] linux-user: add missing TARGET_SIGRTMIN for hppa Date: Sat, 1 Feb 2020 13:27:43 +0100 Message-Id: <20200201122746.1478003-2-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:X09yBxGr1Lqs0Ld5lGMVuy2X0kVCIHkH3ZD6fQtrzzwb/Zshez9 AEjb59AnyYyfM5hPjR1JyxzjDb/bf7nwkoq5KtbGmG3yaJz9fAJMCcrpf2hAnNRQG/a+fah fotAVTFCDdKeZo+bovBo3kG6K3B45PKqyJxFN6Qpw78kgK4hjDZWw5kB8NLP18USO1FyyQr cBtpicKTb12HeVU19L/GQ== X-UI-Out-Filterresults: notjunk:1;V03:K0:BE3DhtHtJEU=:Vy9S7757BTJY4ZgGWwcXeF d9HHYJxH9PHcfzrRIfmVcIAbwQC6R8NHu9IUKwA9ihXJtfxp0bfvX50b8gmkz5W/BdPKVUslz hngw8EhFGqMBnJQZTg+fB9XtfQqNPge4e7y8SdtBBuKV3DL4pHugcIvPANnAeLI4D2ryIKF/g dx8cr94+5Io/vYxYKH6WKUGpPESSFgzdFwMv4HthbqQbrSuz3uLH1BURjbniNH4x9mTRClIpy J1Gby8Z0Fq4Q58xpYgZ1OMGFr75aPQYOq2stLa6NXR6NeJ/Tggzb8kkKDtTN4dIW9oRRrr/LN w0fxAQDcjvsj6Z4dPXkxhJNZEZWLifsoxnwIxkjllWT+DSXQFVaSvhosKog91ulH2cmFAAL/1 VZFepHlbxei5yNg9smAOCPyp3wOmNnLks2DP5s1uaxwvvfOXWMw2wtuFQTetKWyK7S87JdUbC NgE/hU/OGlc9WLFbIYJhVJMV6aEtvbekwCpm0wRU3TiqsX0Y3YhZPkKzhYPlrHAloyf4Bz7hx nxnwNj6LRPBTWmKIJzyUKcPKtiGjd2heh2evB157DHfQydPEm3ZmDzr8RCaaqi/cS/Sfbu7vb iGtMSJ76r4fZhb11kzFNuuQMhgKQ5ZLpwgMIzhcVNmy0sZiCZoJ/EU+ku5acHlxsdOVm3ypwF tJpwHoVkih8I6zEUrIjKOXgSe/kk0Av8h7fRTYXu1hLIOMP994V8/J+pbGf3VtuBTk3ZV/hHg Fkpjex5O1JDuxe3zFdOVLauYJJcrsZKv75FgP1H4WTQeDXSYKZ17q1i0rrB2gvA4od6cF7l2g +ucOwcw/X0hjJm0P1Wb+p1x3nImO0i7wWvtrp2erkKR9OdfIaXdETvLngy8vofOP2QLKO/n X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.133 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" This signal is defined for all other targets and we will need it later Signed-off-by: Laurent Vivier --- linux-user/hppa/target_signal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/hppa/target_signal.h b/linux-user/hppa/target_signa= l.h index ba159ff8d006..c2a0102ed73d 100644 --- a/linux-user/hppa/target_signal.h +++ b/linux-user/hppa/target_signal.h @@ -34,6 +34,7 @@ #define TARGET_SIGURG 29 #define TARGET_SIGXFSZ 30 #define TARGET_SIGSYS 31 +#define TARGET_SIGRTMIN 32 =20 #define TARGET_SIG_BLOCK 0 #define TARGET_SIG_UNBLOCK 1 --=20 2.24.1 From nobody Mon Feb 9 19:33:15 2026 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 1580560299379234.52514300950713; Sat, 1 Feb 2020 04:31:39 -0800 (PST) Received: from localhost ([::1]:45656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrw2-0004wd-95 for importer@patchew.org; Sat, 01 Feb 2020 07:31:38 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51795) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrsy-0001VS-KT 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-00020a-QD for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:28 -0500 Received: from mout.kundenserver.de ([212.227.126.135]:36207) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixrsw-0001rm-FU 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 1MGz5f-1ikvSV1O7f-00E5JD; Sat, 01 Feb 2020 13:27:52 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH 2/4] linux-user: cleanup signal.c Date: Sat, 1 Feb 2020 13:27:44 +0100 Message-Id: <20200201122746.1478003-3-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:7zhL+jA1WW8QN7P25L0DrgsTFWKM/ZP9umW7q9LSBzMk7aFrWYF W98x0r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3DsHxo9xf/WEkyHyq7Qwr1rFgtuFgS X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 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" No functionnal changes. Prepare the field for future fixes. Remove memset(.., 0, ...) that is useless on a static array Signed-off-by: Laurent Vivier --- linux-user/signal.c | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index 5ca6d62b15d3..f42a2e1a82a5 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -66,12 +66,6 @@ static uint8_t host_to_target_signal_table[_NSIG] =3D { [SIGPWR] =3D TARGET_SIGPWR, [SIGSYS] =3D TARGET_SIGSYS, /* next signals stay the same */ - /* 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. */ - [__SIGRTMIN] =3D __SIGRTMAX, - [__SIGRTMAX] =3D __SIGRTMIN, }; static uint8_t target_to_host_signal_table[_NSIG]; =20 @@ -480,13 +474,18 @@ static int core_dump_signal(int sig) } } =20 -void signal_init(void) +static void signal_table_init(void) { - TaskState *ts =3D (TaskState *)thread_cpu->opaque; - struct sigaction act; - struct sigaction oact; int i, j; - int host_sig; + + /* + * 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. + */ + host_to_target_signal_table[__SIGRTMIN] =3D __SIGRTMAX; + host_to_target_signal_table[__SIGRTMAX] =3D __SIGRTMIN; =20 /* generate signal conversion tables */ for(i =3D 1; i < _NSIG; i++) { @@ -497,14 +496,22 @@ void signal_init(void) j =3D host_to_target_signal_table[i]; target_to_host_signal_table[j] =3D i; } +} + +void signal_init(void) +{ + TaskState *ts =3D (TaskState *)thread_cpu->opaque; + struct sigaction act; + struct sigaction oact; + int i; + int host_sig; + + /* initialize signal conversion tables */ + signal_table_init(); =20 /* Set the signal mask from the host mask. */ sigprocmask(0, 0, &ts->signal_mask); =20 - /* set all host signal handlers. ALL signals are blocked during - the handlers to serialize them. */ - memset(sigact_table, 0, sizeof(sigact_table)); - sigfillset(&act.sa_mask); act.sa_flags =3D SA_SIGINFO; act.sa_sigaction =3D host_signal_handler; --=20 2.24.1 From nobody Mon Feb 9 19:33:15 2026 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 1580560360856756.9289643642202; Sat, 1 Feb 2020 04:32:40 -0800 (PST) Received: from localhost ([::1]:45672 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrx1-0005tF-MX for importer@patchew.org; Sat, 01 Feb 2020 07:32:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:51796) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ixrsy-0001VT-KM 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-00020n-R8 for qemu-devel@nongnu.org; Sat, 01 Feb 2020 07:28:28 -0500 Received: from mout.kundenserver.de ([212.227.126.134]:40997) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ixrsw-0001we-GP 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 1McY0L-1jY12a0a8D-00cuwv; Sat, 01 Feb 2020 13:27:53 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PATCH 3/4] linux-user: fix TARGET_NSIG and _NSIG uses Date: Sat, 1 Feb 2020 13:27:45 +0100 Message-Id: <20200201122746.1478003-4-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:A58pRxSyC0i9mJW78ERtAsZVHvI/IaDIu97TPpAlAYdv2/nJEwY oIwJojyPw1l2BL6e8aPOAcqyPDncfx81RcVXk8kYWAjHEyBAz+yEzyy7iNN85R4BGftZsTd IxBaqdtxwLiP9MK9Z1+qE2mYvN6qCuMoTLxZC1dGfeXY0oNypQ2fvNyGWLiysEZv9wnQecS Pak5EYHgowxuyUpFSA0TA== X-UI-Out-Filterresults: notjunk:1;V03:K0:noddaypDHQQ=:Ez3ZNKXuZLW+nzmbn1m4aA QlWc8UzdQZIlUbAKFQNBIvXlVlqQp4MNSy/yoAnlOlZRZ1HOMRNtIlbEv4XOk9YUT6vBSQVXb Q8vg/M3i5Gn1XWjJbkRwJ6c792rL4HRRxVmq8SMJTpmuJ+aBPdrbBVIbOA1eEctd9Uo6weZSu GyfARXKHteLqQ3S+n+0yl+UKwCX123hKFFbKg5I8mu6p5gUeurF1aVxryX3KcOZVas91TSG/k aMIf7lVbQ2OdQVJaxtPnzuXDKDkfYGQPfa0wJLhxEgYwCFc9R2q8odvQgNZYYGO9dhjjKHY03 Z6jjAI0+eNdGxV/3Ec1kMoTGu+bh9smlRyC6VqGuAdokViGlNWeoYvqf9gKz3y5AtPk8rVhMK nBVxkfz9SjsLEqsHigXKrO44tWrv/+cQ0oZUJouzl7/lKGa9gWs1kMHc33h7JMby7CMAuMt15 DcE4tOiDoKMIHZAnemMMiYAzVVZ0UgJuIg1MYLX+scqYfvM3NIbXF+SttSwQjNnk55HZLhvec b0M2zkY9e4o9hceY6t2F3zWgPm8NUiJ7oagmCxBwZ/ysWsMBFWggYP65io3D90kJ8qrDKRE5c D6uNPFRrZRaCUNVAOBnB9nr14eS1ORwxSO532thIp6K2/GGG7fTjhRGoDy7TAgqz1bh/2MTXU R14TiHceMnniFcYZEjMKPU5MNPR9057MtyScoJlOQ1IhEzjuyQmIti4iw51dV5aGW7QKlTxMZ /+bEe9lLGyPhbsG9kubCQUDvvAI7j4TiQtFzKbCcy8upI33UoG4zgDNbd3ty3pyMnLLVItYUI AiXVCfH+uLffkc0N3R5+56yUFZji2snC+7pPo7ioD7ri/+TThJ66eaGo0P3iZ55pJsx/fJA X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.134 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" Valid signal numbers are between 1 (SIGHUP) and SIGRTMAX. System includes define _NSIG to SIGRTMAX + 1, but QEMU (like kernel) defines TARGET_NSIG to TARGET_SIGRTMAX. Fix all the checks involving the signal range. Signed-off-by: Laurent Vivier --- linux-user/signal.c | 51 ++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 14 deletions(-) diff --git a/linux-user/signal.c b/linux-user/signal.c index f42a2e1a82a5..3491f0a7ecb1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -30,6 +30,15 @@ static struct target_sigaction sigact_table[TARGET_NSIG]; static void host_signal_handler(int host_signum, siginfo_t *info, void *puc); =20 + +/* + * System includes define _NSIG as SIGRTMAX + 1, + * but qemu (like the kernel) defines TARGET_NSIG as TARGET_SIGRTMAX + * and the first signal is SIGHUP defined as 1 + * Signal number 0 is reserved for use as kill(pid, 0), to test whether + * a process exists without sending it a signal. + */ +QEMU_BUILD_BUG_ON(__SIGRTMAX + 1 !=3D _NSIG); static uint8_t host_to_target_signal_table[_NSIG] =3D { [SIGHUP] =3D TARGET_SIGHUP, [SIGINT] =3D TARGET_SIGINT, @@ -67,19 +76,24 @@ static uint8_t host_to_target_signal_table[_NSIG] =3D { [SIGSYS] =3D TARGET_SIGSYS, /* next signals stay the same */ }; -static uint8_t target_to_host_signal_table[_NSIG]; =20 +static uint8_t target_to_host_signal_table[TARGET_NSIG + 1]; + +/* valid sig is between 1 and _NSIG - 1 */ int host_to_target_signal(int sig) { - if (sig < 0 || sig >=3D _NSIG) + if (sig < 1 || sig >=3D _NSIG) { return sig; + } return host_to_target_signal_table[sig]; } =20 +/* valid sig is between 1 and TARGET_NSIG */ int target_to_host_signal(int sig) { - if (sig < 0 || sig >=3D _NSIG) + if (sig < 1 || sig > TARGET_NSIG) { return sig; + } return target_to_host_signal_table[sig]; } =20 @@ -100,11 +114,15 @@ static inline int target_sigismember(const target_sig= set_t *set, int signum) void host_to_target_sigset_internal(target_sigset_t *d, const sigset_t *s) { - int i; + int i, j; target_sigemptyset(d); - for (i =3D 1; i <=3D TARGET_NSIG; i++) { + for (i =3D 1; i < _NSIG; i++) { + j =3D host_to_target_signal(i); + if (j < 1 || j > TARGET_NSIG) { + continue; + } if (sigismember(s, i)) { - target_sigaddset(d, host_to_target_signal(i)); + target_sigaddset(d, j); } } } @@ -122,11 +140,15 @@ void host_to_target_sigset(target_sigset_t *d, const = sigset_t *s) void target_to_host_sigset_internal(sigset_t *d, const target_sigset_t *s) { - int i; + int i, j; sigemptyset(d); for (i =3D 1; i <=3D TARGET_NSIG; i++) { + j =3D target_to_host_signal(i); + if (j < 1 || j >=3D _NSIG) { + continue; + } if (target_sigismember(s, i)) { - sigaddset(d, target_to_host_signal(i)); + sigaddset(d, j); } } } @@ -488,13 +510,14 @@ static void signal_table_init(void) host_to_target_signal_table[__SIGRTMAX] =3D __SIGRTMIN; =20 /* generate signal conversion tables */ - for(i =3D 1; i < _NSIG; i++) { - if (host_to_target_signal_table[i] =3D=3D 0) + 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; - } - for(i =3D 1; i < _NSIG; i++) { + } j =3D host_to_target_signal_table[i]; - target_to_host_signal_table[j] =3D i; + if (j <=3D TARGET_NSIG) { + target_to_host_signal_table[j] =3D i; + } } } =20 @@ -517,7 +540,7 @@ void signal_init(void) act.sa_sigaction =3D host_signal_handler; for(i =3D 1; i <=3D TARGET_NSIG; i++) { #ifdef TARGET_GPROF - if (i =3D=3D SIGPROF) { + if (i =3D=3D TARGET_SIGPROF) { continue; } #endif --=20 2.24.1 From nobody Mon Feb 9 19:33:15 2026 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 c6haOJebBNzj0N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] 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