summaryrefslogtreecommitdiffstats
path: root/sys/i386/linux
diff options
context:
space:
mode:
authordchagin <dchagin@FreeBSD.org>2016-01-09 17:29:08 +0000
committerdchagin <dchagin@FreeBSD.org>2016-01-09 17:29:08 +0000
commit05243c722867c54470c4a8757c8c05652a7ad919 (patch)
tree3ff1c414355a992fc237bcf0de922831a0684ad1 /sys/i386/linux
parentd06d6422de7c5bb6015940e8cea11ea8a5faaa2c (diff)
downloadFreeBSD-src-05243c722867c54470c4a8757c8c05652a7ad919.zip
FreeBSD-src-05243c722867c54470c4a8757c8c05652a7ad919.tar.gz
MFC r283474:
Rework signal code to allow using it by other modules, like linprocfs: 1. Linux sigset always 64 bit on all platforms. In order to move Linux sigset code to the linux_common module define it as 64 bit int. Move Linux sigset manipulation routines to the MI path. 2. Move Linux signal number definitions to the MI path. In general, they are the same on all platforms except for a few signals. 3. Map Linux RT signals to the FreeBSD RT signals and hide signal conversion tables to avoid conversion errors. 4. Emulate Linux SIGPWR signal via FreeBSD SIGRTMIN signal which is outside of allowed on Linux signal numbers. PR: 197216
Diffstat (limited to 'sys/i386/linux')
-rw-r--r--sys/i386/linux/linux.h53
-rw-r--r--sys/i386/linux/linux_machdep.c6
-rw-r--r--sys/i386/linux/linux_ptrace.c3
-rw-r--r--sys/i386/linux/linux_sysvec.c49
4 files changed, 17 insertions, 94 deletions
diff --git a/sys/i386/linux/linux.h b/sys/i386/linux/linux.h
index ae12499..97493e2 100644
--- a/sys/i386/linux/linux.h
+++ b/sys/i386/linux/linux.h
@@ -33,6 +33,7 @@
#include <sys/signal.h> /* for sigval union */
+#include <compat/linux/linux.h>
#include <i386/linux/linux_syscall.h>
/*
@@ -234,48 +235,7 @@ struct l_statfs64 {
l_int f_spare[6];
};
-/*
- * Signalling
- */
-#define LINUX_SIGHUP 1
-#define LINUX_SIGINT 2
-#define LINUX_SIGQUIT 3
-#define LINUX_SIGILL 4
-#define LINUX_SIGTRAP 5
-#define LINUX_SIGABRT 6
-#define LINUX_SIGIOT LINUX_SIGABRT
-#define LINUX_SIGBUS 7
-#define LINUX_SIGFPE 8
-#define LINUX_SIGKILL 9
-#define LINUX_SIGUSR1 10
-#define LINUX_SIGSEGV 11
-#define LINUX_SIGUSR2 12
-#define LINUX_SIGPIPE 13
-#define LINUX_SIGALRM 14
-#define LINUX_SIGTERM 15
-#define LINUX_SIGSTKFLT 16
-#define LINUX_SIGCHLD 17
-#define LINUX_SIGCONT 18
-#define LINUX_SIGSTOP 19
-#define LINUX_SIGTSTP 20
-#define LINUX_SIGTTIN 21
-#define LINUX_SIGTTOU 22
-#define LINUX_SIGURG 23
-#define LINUX_SIGXCPU 24
-#define LINUX_SIGXFSZ 25
-#define LINUX_SIGVTALRM 26
-#define LINUX_SIGPROF 27
-#define LINUX_SIGWINCH 28
-#define LINUX_SIGIO 29
-#define LINUX_SIGPOLL LINUX_SIGIO
-#define LINUX_SIGPWR 30
-#define LINUX_SIGSYS 31
-#define LINUX_SIGRTMIN 32
-
-#define LINUX_SIGTBLSZ 31
#define LINUX_NSIG_WORDS 2
-#define LINUX_NBPW 32
-#define LINUX_NSIG (LINUX_NBPW * LINUX_NSIG_WORDS)
/* sigaction flags */
#define LINUX_SA_NOCLDSTOP 0x00000001
@@ -293,24 +253,13 @@ struct l_statfs64 {
#define LINUX_SIG_UNBLOCK 1
#define LINUX_SIG_SETMASK 2
-/* sigset_t macros */
-#define LINUX_SIGEMPTYSET(set) (set).__bits[0] = (set).__bits[1] = 0
-#define LINUX_SIGISMEMBER(set, sig) SIGISMEMBER(set, sig)
-#define LINUX_SIGADDSET(set, sig) SIGADDSET(set, sig)
-
/* sigaltstack */
#define LINUX_MINSIGSTKSZ 2048
-#define LINUX_SS_ONSTACK 1
-#define LINUX_SS_DISABLE 2
typedef void (*l_handler_t)(l_int);
typedef l_ulong l_osigset_t;
typedef struct {
- l_uint __bits[LINUX_NSIG_WORDS];
-} l_sigset_t;
-
-typedef struct {
l_handler_t lsa_handler;
l_osigset_t lsa_mask;
l_ulong lsa_flags;
diff --git a/sys/i386/linux/linux_machdep.c b/sys/i386/linux/linux_machdep.c
index 7c663e5..784a621 100644
--- a/sys/i386/linux/linux_machdep.c
+++ b/sys/i386/linux/linux_machdep.c
@@ -686,7 +686,7 @@ linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
act.lsa_flags = osa.lsa_flags;
act.lsa_restorer = osa.lsa_restorer;
LINUX_SIGEMPTYSET(act.lsa_mask);
- act.lsa_mask.__bits[0] = osa.lsa_mask;
+ act.lsa_mask.__mask = osa.lsa_mask;
}
error = linux_do_sigaction(td, args->sig, args->nsa ? &act : NULL,
@@ -696,7 +696,7 @@ linux_sigaction(struct thread *td, struct linux_sigaction_args *args)
osa.lsa_handler = oact.lsa_handler;
osa.lsa_flags = oact.lsa_flags;
osa.lsa_restorer = oact.lsa_restorer;
- osa.lsa_mask = oact.lsa_mask.__bits[0];
+ osa.lsa_mask = oact.lsa_mask.__mask;
error = copyout(&osa, args->osa, sizeof(l_osigaction_t));
}
@@ -720,7 +720,7 @@ linux_sigsuspend(struct thread *td, struct linux_sigsuspend_args *args)
#endif
LINUX_SIGEMPTYSET(mask);
- mask.__bits[0] = args->mask;
+ mask.__mask = args->mask;
linux_to_bsd_sigset(&mask, &sigmask);
return (kern_sigsuspend(td, sigmask));
}
diff --git a/sys/i386/linux/linux_ptrace.c b/sys/i386/linux/linux_ptrace.c
index 46a1169..2925e6b 100644
--- a/sys/i386/linux/linux_ptrace.c
+++ b/sys/i386/linux/linux_ptrace.c
@@ -91,8 +91,7 @@ static __inline int
map_signum(int signum)
{
- if (signum > 0 && signum <= LINUX_SIGTBLSZ)
- signum = linux_to_bsd_signal[_SIG_IDX(signum)];
+ signum = linux_to_bsd_signal(signum);
return ((signum == SIGSTOP)? 0 : signum);
}
diff --git a/sys/i386/linux/linux_sysvec.c b/sys/i386/linux/linux_sysvec.c
index 5ee9243..acf23ac 100644
--- a/sys/i386/linux/linux_sysvec.c
+++ b/sys/i386/linux/linux_sysvec.c
@@ -149,28 +149,6 @@ static int bsd_to_linux_errno[ELAST + 1] = {
-72, -67, -71
};
-int bsd_to_linux_signal[LINUX_SIGTBLSZ] = {
- LINUX_SIGHUP, LINUX_SIGINT, LINUX_SIGQUIT, LINUX_SIGILL,
- LINUX_SIGTRAP, LINUX_SIGABRT, 0, LINUX_SIGFPE,
- LINUX_SIGKILL, LINUX_SIGBUS, LINUX_SIGSEGV, LINUX_SIGSYS,
- LINUX_SIGPIPE, LINUX_SIGALRM, LINUX_SIGTERM, LINUX_SIGURG,
- LINUX_SIGSTOP, LINUX_SIGTSTP, LINUX_SIGCONT, LINUX_SIGCHLD,
- LINUX_SIGTTIN, LINUX_SIGTTOU, LINUX_SIGIO, LINUX_SIGXCPU,
- LINUX_SIGXFSZ, LINUX_SIGVTALRM, LINUX_SIGPROF, LINUX_SIGWINCH,
- 0, LINUX_SIGUSR1, LINUX_SIGUSR2
-};
-
-int linux_to_bsd_signal[LINUX_SIGTBLSZ] = {
- SIGHUP, SIGINT, SIGQUIT, SIGILL,
- SIGTRAP, SIGABRT, SIGBUS, SIGFPE,
- SIGKILL, SIGUSR1, SIGSEGV, SIGUSR2,
- SIGPIPE, SIGALRM, SIGTERM, SIGBUS,
- SIGCHLD, SIGCONT, SIGSTOP, SIGTSTP,
- SIGTTIN, SIGTTOU, SIGURG, SIGXCPU,
- SIGXFSZ, SIGVTALRM, SIGPROF, SIGWINCH,
- SIGIO, SIGURG, SIGSYS
-};
-
#define LINUX_T_UNKNOWN 255
static int _bsd_to_linux_trapcode[] = {
LINUX_T_UNKNOWN, /* 0 */
@@ -480,7 +458,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/*
* Build the argument list for the signal handler.
*/
- sig = BSD_TO_LINUX_SIGNAL(sig);
+ sig = bsd_to_linux_signal(sig);
bzero(&frame, sizeof(frame));
@@ -506,7 +484,7 @@ linux_rt_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
bsd_to_linux_sigset(mask, &frame.sf_sc.uc_sigmask);
- frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__bits[0];
+ frame.sf_sc.uc_mcontext.sc_mask = frame.sf_sc.uc_sigmask.__mask;
frame.sf_sc.uc_mcontext.sc_gs = rgs();
frame.sf_sc.uc_mcontext.sc_fs = regs->tf_fs;
frame.sf_sc.uc_mcontext.sc_es = regs->tf_es;
@@ -585,7 +563,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
struct l_sigframe *fp, frame;
l_sigset_t lmask;
int sig, code;
- int oonstack, i;
+ int oonstack;
PROC_LOCK_ASSERT(p, MA_OWNED);
psp = p->p_sigacts;
@@ -621,7 +599,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/*
* Build the argument list for the signal handler.
*/
- sig = BSD_TO_LINUX_SIGNAL(sig);
+ sig = bsd_to_linux_signal(sig);
bzero(&frame, sizeof(frame));
@@ -633,7 +611,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
/*
* Build the signal context to be used by sigreturn.
*/
- frame.sf_sc.sc_mask = lmask.__bits[0];
+ frame.sf_sc.sc_mask = lmask.__mask;
frame.sf_sc.sc_gs = rgs();
frame.sf_sc.sc_fs = regs->tf_fs;
frame.sf_sc.sc_es = regs->tf_es;
@@ -655,8 +633,7 @@ linux_sendsig(sig_t catcher, ksiginfo_t *ksi, sigset_t *mask)
frame.sf_sc.sc_cr2 = (register_t)ksi->ksi_addr;
frame.sf_sc.sc_trapno = bsd_to_linux_trapcode(ksi->ksi_trapno);
- for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
- frame.sf_extramask[i] = lmask.__bits[i+1];
+ frame.sf_extramask[0] = lmask.__mask;
if (copyout(&frame, fp, sizeof(frame)) != 0) {
/*
@@ -699,7 +676,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
struct trapframe *regs;
l_sigset_t lmask;
sigset_t bmask;
- int eflags, i;
+ int eflags;
ksiginfo_t ksi;
regs = td->td_frame;
@@ -740,9 +717,7 @@ linux_sigreturn(struct thread *td, struct linux_sigreturn_args *args)
return (EINVAL);
}
- lmask.__bits[0] = frame.sf_sc.sc_mask;
- for (i = 0; i < (LINUX_NSIG_WORDS-1); i++)
- lmask.__bits[i+1] = frame.sf_extramask[i];
+ lmask.__mask = frame.sf_sc.sc_mask;
linux_to_bsd_sigset(&lmask, &bmask);
kern_sigprocmask(td, SIG_SETMASK, &bmask, NULL, 0);
@@ -981,8 +956,8 @@ struct sysentvec linux_sysvec = {
.sv_size = LINUX_SYS_MAXSYSCALL,
.sv_table = linux_sysent,
.sv_mask = 0,
- .sv_sigsize = LINUX_SIGTBLSZ,
- .sv_sigtbl = bsd_to_linux_signal,
+ .sv_sigsize = 0,
+ .sv_sigtbl = NULL,
.sv_errsize = ELAST + 1,
.sv_errtbl = bsd_to_linux_errno,
.sv_transtrap = translate_traps,
@@ -1020,8 +995,8 @@ struct sysentvec elf_linux_sysvec = {
.sv_size = LINUX_SYS_MAXSYSCALL,
.sv_table = linux_sysent,
.sv_mask = 0,
- .sv_sigsize = LINUX_SIGTBLSZ,
- .sv_sigtbl = bsd_to_linux_signal,
+ .sv_sigsize = 0,
+ .sv_sigtbl = NULL,
.sv_errsize = ELAST + 1,
.sv_errtbl = bsd_to_linux_errno,
.sv_transtrap = translate_traps,
OpenPOWER on IntegriCloud