From nobody Tue Feb 10 03:45:04 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1494594971418614.0545827576234; Fri, 12 May 2017 06:16:11 -0700 (PDT) Received: from localhost ([::1]:53770 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d9AQS-0008Hm-1t for importer@patchew.org; Fri, 12 May 2017 09:16:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50041) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d98LK-00043i-Uo for qemu-devel@nongnu.org; Fri, 12 May 2017 07:02:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d98LI-0006Sp-D2 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:02:42 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:46759 helo=mail.rt-rk.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1d98LI-0006Rh-17 for qemu-devel@nongnu.org; Fri, 12 May 2017 07:02:40 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 8D6701A49C4; Fri, 12 May 2017 13:02:12 +0200 (CEST) Received: from rtrkw488-lin.domain.local (unknown [10.10.14.90]) by mail.rt-rk.com (Postfix) with ESMTPSA id 335351A2458; Fri, 12 May 2017 13:02:12 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com From: =?UTF-8?q?Milo=C5=A1=20Stojanovi=C4=87?= To: qemu-devel@nongnu.org, riku.voipio@iki.fi Date: Fri, 12 May 2017 13:02:23 +0200 Message-Id: <1494586944-7253-16-git-send-email-Milos.Stojanovic@rt-rk.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1494586944-7253-1-git-send-email-Milos.Stojanovic@rt-rk.com> References: <1494586944-7253-1-git-send-email-Milos.Stojanovic@rt-rk.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 89.216.37.149 X-Mailman-Approved-At: Fri, 12 May 2017 09:02:56 -0400 Subject: [Qemu-devel] [PATCH 15/16] [RFC] linux-user: add support for multiplexing larger target signals X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Milos.Stojanovic@rt-rk.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Add MUX_SIG as a multiplex signal number for all target signals which are out of the host range. Add support for multiplexing in do_sigaction(), process_pending_signals(), target_set_sigmask() and do_target_sigprocmask(). This patch solves the problem of unusable target signals which are out of the host range. This is done by enabling the usage of one of the host signals (MUX_SIG) as a multiplex for all the target signals that are out of range. In order to have the target signal masks available TRACK_TARGET_MASK is defined which enables the tracking of the target signals masks. The table of signal handlers already supports the whole range of target signals. In the do_sigaction() function the signal number of signals which are out of range are replaced by MUX_SIG which bypasses the error from the host system and doesn't interfere with signal handling on the target. Since the MUX_SIG is used as a multiplex, it must never be blocked on host, so support for emulating the blocking of this signal is added. This is done by only blocking MUX_SIG in the target mask and retrieving its status from there when it's needed. Signed-off-by: Milo=C5=A1 Stojanovi=C4=87 --- linux-user/signal.c | 32 ++++++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 20 ++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/linux-user/signal.c b/linux-user/signal.c index 9d4ad43..3d51424 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -308,6 +308,15 @@ int do_target_sigprocmask(int how, const target_sigset= _t *target_set, } if (oldset) { *oldset =3D ts->signal_mask; +#ifdef MUX_SIG + /* + * The emulation of MUX_SIG being blocked is done using the + * target_signal_mask, so the status of MUX_SIG is taken from ther= e. + */ + if (target_sigismember(&ts->target_signal_mask, MUX_SIG) =3D=3D 1)= { + sigaddset(oldset, MUX_SIG); + } +#endif } =20 if (target_set && set) { @@ -348,6 +357,15 @@ int do_target_sigprocmask(int how, const target_sigset= _t *target_set, target_sigdelset(&ts->target_signal_mask, SIGSTOP); sigdelset(&ts->signal_mask, SIGKILL); sigdelset(&ts->signal_mask, SIGSTOP); +#ifdef MUX_SIG + /* + * Since MUX_SIG is used for all the target signals out of the host + * range it must never be blocked on host. The emulation of MUX_SIG + * being blocked is done using the target_signal_mask. The status + * of MUX_SIG is taken form the target_signal_mask. + */ + sigdelset(&ts->signal_mask, MUX_SIG); +#endif } return 0; } @@ -373,6 +391,10 @@ static void target_set_sigmask(const sigset_t *set, =20 ts->signal_mask =3D *set; ts->target_signal_mask =3D *target_set; +#ifdef MUX_SIG + /* MUX_SIG can't be blocked on host */ + sigdelset(&ts->signal_mask, MUX_SIG); +#endif } #endif #endif @@ -909,6 +931,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); +#ifdef MUX_SIG + /* put the out of host range signal into the multiplex */ + if (sig >=3D _NSIG && sig < TARGET_NSIG) { + host_sig =3D MUX_SIG; + } +#endif if (host_sig !=3D SIGSEGV && host_sig !=3D SIGBUS) { sigfillset(&act1.sa_mask); act1.sa_flags =3D SA_SIGINFO; @@ -6841,6 +6869,10 @@ void process_pending_signals(CPUArchState *cpu_env) set =3D ts->signal_mask; sigdelset(&set, SIGSEGV); sigdelset(&set, SIGBUS); +#ifdef MUX_SIG + /* MUX_SIG can't be blocked on host */ + sigdelset(&ts->signal_mask, MUX_SIG); +#endif sigprocmask(SIG_SETMASK, &set, 0); } ts->in_sigsuspend =3D 0; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 7eec420..42089fc 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -394,6 +394,26 @@ struct target_dirent64 { #define TARGET_NSIG_BPW TARGET_ABI_BITS #define TARGET_NSIG_WORDS (TARGET_NSIG / TARGET_NSIG_BPW) =20 +#if _NSIG <=3D TARGET_NSIG +/* + * MUX_SIG is used as a multiplex signal number - signals that are + * out of the host range and in the target range are sent through it. + * It is defined as the maximal available real-time signal in order to + * comply with the rule that low-numbered signals have highest priority. + * (signals using it will have the same priority but it will be smaller + * than all the other real-time signals) + * SIGRMTAX is avoided so it doesn't interfere with the hack of reversing + * __SIGRTMIN and __SIGRTMAX in the host_to_target_signal_table. + */ +#define MUX_SIG (SIGRTMAX - 1) + +/* + * The target signal masks must be tracked since they are larger than + * the host signal masks. + */ +#define TRACK_TARGET_SIGMASK +#endif + typedef struct { abi_ulong sig[TARGET_NSIG_WORDS]; } target_sigset_t; --=20 1.9.1