diff --git a/sys/compat/linux32/arch/amd64/linux32_siginfo.h b/sys/compat/linux32/arch/amd64/linux32_siginfo.h new file mode 100644 index 000000000000..e15d4c167a7e --- /dev/null +++ b/sys/compat/linux32/arch/amd64/linux32_siginfo.h @@ -0,0 +1,91 @@ +/* $NetBSD: linux32_siginfo.h,v 1.1 2011/11/18 04:08:56 christos Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Eric Haszlakiewicz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _AMD64_LINUX32_SIGINFO_H +#define _AMD64_LINUX32_SIGINFO_H + +typedef union linux32_sigval { + int sival_int; + netbsd32_voidp sival_ptr; +} linux32_sigval_t; + +#define SI_MAX_SIZE 128 +#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) + +typedef struct linux32_siginfo { + int lsi_signo; + int lsi_errno; + int lsi_code; + union { + int _pad[SI_PAD_SIZE]; + + /* kill() */ + struct { + linux32_pid_t _pid; + linux32_uid_t _uid; + } _kill; + + /* POSIX.1b signals */ + struct { + linux32_pid_t _pid; + linux32_uid_t _uid; + linux32_sigval_t _sigval; + } _rt; + + /* POSIX.1b timers */ + struct { + unsigned int _timer1; + unsigned int _timer2; + } _timer; + + /* SIGCHLD */ + struct { + linux32_pid_t _pid; + linux32_uid_t _uid; + int _status; + linux32_clock_t _utime; + linux32_clock_t _stime; + } _sigchld; + + /* SIGPOLL */ + struct { + int _band; + int _fd; + } _sigpoll; + + /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ + struct { + netbsd32_voidp _addr; + } _sigfault; + } _sidata; +} linux32_siginfo_t; + +#endif /* !_AMD64_LINUX32_SIGINFO_H */ diff --git a/sys/compat/linux32/arch/amd64/linux32_signal.h b/sys/compat/linux32/arch/amd64/linux32_signal.h index bcea301b7afd..28c0a6d0ffdf 100644 --- a/sys/compat/linux32/arch/amd64/linux32_signal.h +++ b/sys/compat/linux32/arch/amd64/linux32_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_signal.h,v 1.2 2009/06/08 14:42:10 njoly Exp $ */ +/* $NetBSD: linux32_signal.h,v 1.3 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -91,137 +91,6 @@ struct linux32_sigaction { linux32_sigset_t linux_sa_mask; }; -typedef union linux32_sigval { - int sival_int; - netbsd32_voidp sival_ptr; -} linux32_sigval_t; - -#define SI_MAX_SIZE 128 -#define SI_PAD_SIZE ((SI_MAX_SIZE/sizeof(int)) - 3) - -typedef struct linux32_siginfo { - int lsi_signo; - int lsi_errno; - int lsi_code; - union { - int _pad[SI_PAD_SIZE]; - - /* kill() */ - struct { - linux32_pid_t _pid; - linux32_uid_t _uid; - } _kill; - - /* POSIX.1b signals */ - struct { - linux32_pid_t _pid; - linux32_uid_t _uid; - linux32_sigval_t _sigval; - } _rt; - - /* POSIX.1b timers */ - struct { - unsigned int _timer1; - unsigned int _timer2; - } _timer; - - /* SIGCHLD */ - struct { - linux32_pid_t _pid; - linux32_uid_t _uid; - int _status; - linux32_clock_t _utime; - linux32_clock_t _stime; - } _sigchld; - - /* SIGPOLL */ - struct { - int _band; - int _fd; - } _sigpoll; - - /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ - struct { - netbsd32_voidp _addr; - } _sigfault; - } _sidata; -} linux32_siginfo_t; - -#define lsi_pid _sidata._kill._pid -#define lsi_uid _sidata._kill._uid -#define lsi_status _sidata._sigchld._status -#define lsi_utime _sidata._sigchld._utime -#define lsi_stime _sidata._sigchld._stime -#define lsi_value _sidata._rt._sigval -#define lsi_int _sidata._rt._sigval.sival_int -#define lsi_ptr _sidata._rt._sigval.sival_ptr -#define lsi_addr _sidata._sigfault._addr -#define lsi_band _sidata._sigpoll._band -#define lsi_fd _sidata._sigpoll._fd - -/* - * si_code values for non-signals - */ -#define LINUX32_SI_USER 0 -#define LINUX32_SI_KERNEL 0x80 -#define LINUX32_SI_QUEUE -1 -#define LINUX32_SI_TIMER -2 -#define LINUX32_SI_MESGQ -3 -#define LINUX32_SI_ASYNCIO -4 -#define LINUX32_SI_SIGIO -5 -#define LINUX32_SI_SIGNL -6 - -/* si_code values for SIGILL */ -#define LINUX32_ILL_ILLOPC 1 -#define LINUX32_ILL_ILLOPN 2 -#define LINUX32_ILL_ILLADR 3 -#define LINUX32_ILL_ILLTRP 4 -#define LINUX32_ILL_PRVOPC 5 -#define LINUX32_ILL_PRVREG 6 -#define LINUX32_ILL_COPROC 7 -#define LINUX32_ILL_BADSTK 8 - -/* si_code values for SIGFPE */ -#define LINUX32_FPE_INTDIV 1 -#define LINUX32_FPE_INTOVF 2 -#define LINUX32_FPE_FLTDIV 3 -#define LINUX32_FPE_FLTOVF 4 -#define LINUX32_FPE_FLTUND 5 -#define LINUX32_FPE_FLTRES 6 -#define LINUX32_FPE_FLTINV 7 -#define LINUX32_FPE_FLTSUB 8 - -/* si_code values for SIGSEGV */ -#define LINUX32_SEGV_MAPERR 1 -#define LINUX32_SEGV_ACCERR 2 - -/* si_code values for SIGBUS */ -#define LINUX32_BUS_ADRALN 1 -#define LINUX32_BUS_ADRERR 2 -#define LINUX32_BUS_OBJERR 3 - -/* si_code values for SIGTRAP */ -#define LINUX32_TRAP_BRKPT 1 -#define LINUX32_TRAP_TRACE 2 - -/* si_code values for SIGCHLD */ -#define LINUX32_CLD_EXITED 1 -#define LINUX32_CLD_KILLED 2 -#define LINUX32_CLD_DUMPED 3 -#define LINUX32_CLD_TRAPPED 4 -#define LINUX32_CLD_STOPPED 5 -#define LINUX32_CLD_CONTINUED 6 - -/* si_code values for SIGPOLL */ -#define LINUX32_POLL_IN 1 -#define LINUX32_POLL_OUT 2 -#define LINUX32_POLL_MSG 3 -#define LINUX32_POLL_ERR 4 -#define LINUX32_POLL_PRI 5 -#define LINUX32_POLL_HUP 6 - -#define LINUX32_SI_FROMUSER(sp) ((sp)->si_code <= 0) -#define LINUX32_SI_FROMKERNEL(sp) ((sp)->si_code > 0) struct linux32_sigaltstack { netbsd32_voidp ss_sp; diff --git a/sys/compat/linux32/arch/amd64/linux32_syscall.h b/sys/compat/linux32/arch/amd64/linux32_syscall.h index f4b12a1e0c76..a703e7afe50e 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscall.h +++ b/sys/compat/linux32/arch/amd64/linux32_syscall.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_syscall.h,v 1.63 2011/05/30 21:37:40 alnsn Exp $ */ +/* $NetBSD: linux32_syscall.h,v 1.64 2011/11/18 04:08:56 christos Exp $ */ /* * System call numbers. @@ -445,6 +445,9 @@ /* syscall: "rt_sigpending" ret: "int" args: "linux32_sigsetp_t" "netbsd32_size_t" */ #define LINUX32_SYS_rt_sigpending 176 +/* syscall: "rt_sigtimedwait" ret: "int" args: "const linux32_sigset_t *" "linux32_siginfo_t *" "const struct linux_timespec32 *" */ +#define LINUX32_SYS_rt_sigtimedwait 177 + /* syscall: "rt_queueinfo" ret: "int" args: "int" "int" "linux32_siginfop_t" */ #define LINUX32_SYS_rt_queueinfo 178 diff --git a/sys/compat/linux32/arch/amd64/linux32_syscallargs.h b/sys/compat/linux32/arch/amd64/linux32_syscallargs.h index 94da6de1f672..d41988dc4267 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscallargs.h +++ b/sys/compat/linux32/arch/amd64/linux32_syscallargs.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_syscallargs.h,v 1.63 2011/05/30 21:37:40 alnsn Exp $ */ +/* $NetBSD: linux32_syscallargs.h,v 1.64 2011/11/18 04:08:56 christos Exp $ */ /* * System call argument lists. @@ -604,6 +604,13 @@ struct linux32_sys_rt_sigpending_args { }; check_syscall_args(linux32_sys_rt_sigpending) +struct linux32_sys_rt_sigtimedwait_args { + syscallarg(const linux32_sigset_t *) set; + syscallarg(linux32_siginfo_t *) info; + syscallarg(const struct linux_timespec32 *) timeout; +}; +check_syscall_args(linux32_sys_rt_sigtimedwait) + struct linux32_sys_rt_queueinfo_args { syscallarg(int) pid; syscallarg(int) sig; @@ -1189,6 +1196,8 @@ int linux32_sys_rt_sigprocmask(struct lwp *, const struct linux32_sys_rt_sigproc int linux32_sys_rt_sigpending(struct lwp *, const struct linux32_sys_rt_sigpending_args *, register_t *); +int linux32_sys_rt_sigtimedwait(struct lwp *, const struct linux32_sys_rt_sigtimedwait_args *, register_t *); + int linux32_sys_rt_queueinfo(struct lwp *, const struct linux32_sys_rt_queueinfo_args *, register_t *); int linux32_sys_rt_sigsuspend(struct lwp *, const struct linux32_sys_rt_sigsuspend_args *, register_t *); diff --git a/sys/compat/linux32/arch/amd64/linux32_syscalls.c b/sys/compat/linux32/arch/amd64/linux32_syscalls.c index 43b7cfb1cc43..5fd50634b466 100644 --- a/sys/compat/linux32/arch/amd64/linux32_syscalls.c +++ b/sys/compat/linux32/arch/amd64/linux32_syscalls.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_syscalls.c,v 1.63 2011/05/30 21:37:40 alnsn Exp $ */ +/* $NetBSD: linux32_syscalls.c,v 1.64 2011/11/18 04:08:56 christos Exp $ */ /* * System call names. @@ -8,7 +8,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_syscalls.c,v 1.63 2011/05/30 21:37:40 alnsn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_syscalls.c,v 1.64 2011/11/18 04:08:56 christos Exp $"); #if defined(_KERNEL_OPT) #include @@ -212,7 +212,7 @@ const char *const linux32_syscallnames[] = { /* 174 */ "rt_sigaction", /* 175 */ "rt_sigprocmask", /* 176 */ "rt_sigpending", - /* 177 */ "#177 (unimplemented rt_sigtimedwait)", + /* 177 */ "rt_sigtimedwait", /* 178 */ "rt_queueinfo", /* 179 */ "rt_sigsuspend", /* 180 */ "pread", diff --git a/sys/compat/linux32/arch/amd64/linux32_sysent.c b/sys/compat/linux32/arch/amd64/linux32_sysent.c index c09bb3a688db..2891eb638d4d 100644 --- a/sys/compat/linux32/arch/amd64/linux32_sysent.c +++ b/sys/compat/linux32/arch/amd64/linux32_sysent.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_sysent.c,v 1.63 2011/05/30 21:37:40 alnsn Exp $ */ +/* $NetBSD: linux32_sysent.c,v 1.64 2011/11/18 04:08:56 christos Exp $ */ /* * System call switch table. @@ -8,7 +8,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_sysent.c,v 1.63 2011/05/30 21:37:40 alnsn Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_sysent.c,v 1.64 2011/11/18 04:08:56 christos Exp $"); #include #include @@ -391,8 +391,8 @@ struct sysent linux32_sysent[] = { (sy_call_t *)linux32_sys_rt_sigprocmask },/* 175 = rt_sigprocmask */ { ns(struct linux32_sys_rt_sigpending_args), 0, (sy_call_t *)linux32_sys_rt_sigpending },/* 176 = rt_sigpending */ - { 0, 0, 0, - linux_sys_nosys }, /* 177 = unimplemented rt_sigtimedwait */ + { ns(struct linux32_sys_rt_sigtimedwait_args), 0, + (sy_call_t *)linux32_sys_rt_sigtimedwait },/* 177 = rt_sigtimedwait */ { ns(struct linux32_sys_rt_queueinfo_args), 0, (sy_call_t *)linux32_sys_rt_queueinfo },/* 178 = rt_queueinfo */ { ns(struct linux32_sys_rt_sigsuspend_args), 0, diff --git a/sys/compat/linux32/arch/amd64/syscalls.master b/sys/compat/linux32/arch/amd64/syscalls.master index f8c94c88c43e..c2f0dc17f7e8 100644 --- a/sys/compat/linux32/arch/amd64/syscalls.master +++ b/sys/compat/linux32/arch/amd64/syscalls.master @@ -1,4 +1,4 @@ - $NetBSD: syscalls.master,v 1.59 2011/05/30 17:50:32 alnsn Exp $ + $NetBSD: syscalls.master,v 1.60 2011/11/18 04:08:56 christos Exp $ ; NetBSD i386 COMPAT_LINUX32 system call name/number "master" file. ; (See syscalls.conf to see what it is processed into.) @@ -317,7 +317,10 @@ netbsd32_size_t sigsetsize); } 176 STD { int|linux32_sys||rt_sigpending(linux32_sigsetp_t set, \ netbsd32_size_t sigsetsize); } -177 UNIMPL rt_sigtimedwait +177 STD { int|linux32_sys||rt_sigtimedwait( \ + const linux32_sigset_t *set, \ + linux32_siginfo_t *info, \ + const struct linux_timespec32 *timeout); } 178 STD { int|linux32_sys||rt_queueinfo(int pid, int sig, \ linux32_siginfop_t uinfo); } 179 STD { int|linux32_sys||rt_sigsuspend(linux32_sigsetp_t unewset, \ diff --git a/sys/compat/linux32/common/linux32_misc.c b/sys/compat/linux32/common/linux32_misc.c index 3eb54fabbcc4..9dfa303270a7 100644 --- a/sys/compat/linux32/common/linux32_misc.c +++ b/sys/compat/linux32/common/linux32_misc.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $ */ +/* $NetBSD: linux32_misc.c,v 1.22 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 1995, 1998, 1999 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.22 2011/11/18 04:08:56 christos Exp $"); #include #include @@ -49,6 +49,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_misc.c,v 1.21 2010/11/02 18:18:07 chs Exp $" #include #include +#include #include #include diff --git a/sys/compat/linux32/common/linux32_sched.h b/sys/compat/linux32/common/linux32_sched.h new file mode 100644 index 000000000000..ad802a30a389 --- /dev/null +++ b/sys/compat/linux32/common/linux32_sched.h @@ -0,0 +1,88 @@ +/* $NetBSD: linux32_sched.h,v 1.1 2011/11/18 04:08:56 christos Exp $ */ + +/*- + * Copyright (c) 1999 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, + * NASA Ames Research Center. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUX32_SCHED_H +#define _LINUX32_SCHED_H + +/* + * Flags passed to the Linux __clone(2) system call. + */ +#define LINUX32_CLONE_CSIGNAL 0x000000ff /* signal to be sent at exit */ +#define LINUX32_CLONE_VM 0x00000100 /* share address space */ +#define LINUX32_CLONE_FS 0x00000200 /* share "file system" info */ +#define LINUX32_CLONE_FILES 0x00000400 /* share file descriptors */ +#define LINUX32_CLONE_SIGHAND 0x00000800 /* share signal actions */ +#define LINUX32_CLONE_PID 0x00001000 /* share process ID */ +#define LINUX32_CLONE_PTRACE 0x00002000 /* ptrace(2) continues on + child */ +#define LINUX32_CLONE_VFORK 0x00004000 /* parent blocks until child + exits */ +#define LINUX32_CLONE_PARENT 0x00008000 /* want same parent as cloner */ +#define LINUX32_CLONE_THREAD 0x00010000 /* same thread group */ +#define LINUX32_CLONE_NEWNS 0x00020000 /* new namespace group */ +#define LINUX32_CLONE_SYSVSEM 0x00040000 /* share SysV SEM_UNDO */ +#define LINUX32_CLONE_SETTLS 0x00080000 /* create new TLS for child */ +#define LINUX32_CLONE_PARENT_SETTID \ + 0x00100000 /* set TID in the parent */ +#define LINUX32_CLONE_CHILD_CLEARTID \ + 0x00200000 /* clear TID in the child */ +#define LINUX32_CLONE_DETACHED 0x00400000 /* unused */ +#define LINUX32_CLONE_UNTRACED 0x00800000 /* set if parent cannot force CLONE_PTRACE */ +#define LINUX32_CLONE_CHILD_SETTID \ + 0x01000000 /* set TID in the child */ +#define LINUX32_CLONE_STOPPED 0x02000000 /* start in stopped state */ + +struct linux32_sched_param { + int sched_priority; +}; + +#define LINUX32_SCHED_OTHER 0 +#define LINUX32_SCHED_FIFO 1 +#define LINUX32_SCHED_RR 2 + +struct linux32_timespec { + linux32_time_t tv_sec; /* seconds */ + int tv_nsec; /* nanoseconds */ +}; + +#define LINUX32_CLOCK_REALTIME 0 +#define LINUX32_CLOCK_MONOTONIC 1 +#define LINUX32_CLOCK_PROCESS_CPUTIME_ID 2 +#define LINUX32_CLOCK_THREAD_CPUTIME_ID 3 +#define LINUX32_CLOCK_REALTIME_HR 4 +#define LINUX32_CLOCK_MONOTONIC_HR 5 + +int linux32_to_native_clockid(clockid_t *, clockid_t); +void native_to_linux32_timespec(struct linux32_timespec *, struct timespec *); +void linux32_to_native_timespec(struct timespec *, struct linux32_timespec *); + +#endif /* _LINUX32_SCHED_H */ diff --git a/sys/compat/linux32/common/linux32_siginfo.h b/sys/compat/linux32/common/linux32_siginfo.h new file mode 100644 index 000000000000..374d9a0ac71f --- /dev/null +++ b/sys/compat/linux32/common/linux32_siginfo.h @@ -0,0 +1,118 @@ +/* $NetBSD: linux32_siginfo.h,v 1.1 2011/11/18 04:08:56 christos Exp $ */ + +/*- + * Copyright (c) 1998 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Eric Haszlakiewicz. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef _LINUX32_SIGINFO_H +#define _LINUX32_SIGINFO_H + +#if defined(__amd64__) +#include +#endif + +/* si_code values for non signal */ +#define LINUX32_SI_USER 0 +#define LINUX32_SI_KERNEL 0x80 +#define LINUX32_SI_QUEUE -1 +#ifndef LINUX32_SI_TIMER /* all except mips */ +#define LINUX32_SI_TIMER -2 +#define LINUX32_SI_MESGQ -3 +#define LINUX32_SI_ASYNCIO -4 +#endif /* LINUX32_SI_TIMER */ +#define LINUX32_SI_SIGIO -5 +#define LINUX32_SI_TKILL -6 +#define LINUX32_SI_DETHREAD -7 + +/* si_code values for SIGILL */ +#define LINUX32_ILL_ILLOPC 1 +#define LINUX32_ILL_ILLOPN 2 +#define LINUX32_ILL_ILLADR 3 +#define LINUX32_ILL_ILLTRP 4 +#define LINUX32_ILL_PRVOPC 5 +#define LINUX32_ILL_PRVREG 6 +#define LINUX32_ILL_COPROC 7 +#define LINUX32_ILL_BADSTK 8 + +/* si_code values for SIGFPE */ +#define LINUX32_FPE_INTDIV 1 +#define LINUX32_FPE_INTOVF 2 +#define LINUX32_FPE_FLTDIV 3 +#define LINUX32_FPE_FLTOVF 4 +#define LINUX32_FPE_FLTUND 5 +#define LINUX32_FPE_FLTRES 6 +#define LINUX32_FPE_FLTINV 7 +#define LINUX32_FPE_FLTSUB 8 + +/* si_code values for SIGSEGV */ +#define LINUX32_SEGV_MAPERR 1 +#define LINUX32_SEGV_ACCERR 2 + +/* si_code values for SIGBUS */ +#define LINUX32_BUS_ADRALN 1 +#define LINUX32_BUS_ADRERR 2 +#define LINUX32_BUS_OBJERR 3 + +/* si_code values for SIGTRAP */ +#define LINUX32_TRAP_BRKPT 1 +#define LINUX32_TRAP_TRACE 2 + +/* si_code values for SIGCHLD */ +#define LINUX32_CLD_EXITED 1 +#define LINUX32_CLD_KILLED 2 +#define LINUX32_CLD_DUMPED 3 +#define LINUX32_CLD_TRAPPED 4 +#define LINUX32_CLD_STOPPED 5 +#define LINUX32_CLD_CONTINUED 6 + +/* si_code values for SIGPOLL */ +#define LINUX32_POLL_IN 1 +#define LINUX32_POLL_OUT 2 +#define LINUX32_POLL_MSG 3 +#define LINUX32_POLL_ERR 4 +#define LINUX32_POLL_PRI 5 +#define LINUX32_POLL_HUP 6 + +#define LINUX32_SI_FROMUSER(sp) ((sp)->si_code <= 0) +#define LINUX32_SI_FROMKERNEL(sp) ((sp)->si_code > 0) + +#define lsi_pid _sidata._kill._pid +#define lsi_uid _sidata._kill._uid +#define lsi_status _sidata._sigchld._status +#define lsi_utime _sidata._sigchld._utime +#define lsi_stime _sidata._sigchld._stime +#define lsi_value _sidata._rt._sigval +#define lsi_sival_int _sidata._rt._sigval.sival_int +#define lsi_sival_ptr _sidata._rt._sigval.sival_ptr +#define lsi_addr _sidata._sigfault._addr +#define lsi_band _sidata._sigpoll._band +#define lsi_fd _sidata._sigpoll._fd + +void native_to_linux32_siginfo(linux32_siginfo_t *, const struct _ksiginfo *); + +#endif /* !_LINUX32_SIGINFO_H */ diff --git a/sys/compat/linux32/common/linux32_signal.c b/sys/compat/linux32/common/linux32_signal.c index 24569d2665f1..05535d2fc408 100644 --- a/sys/compat/linux32/common/linux32_signal.c +++ b/sys/compat/linux32/common/linux32_signal.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_signal.c,v 1.13 2009/06/08 13:34:23 njoly Exp $ */ +/* $NetBSD: linux32_signal.c,v 1.14 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -32,7 +32,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.13 2009/06/08 13:34:23 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.14 2011/11/18 04:08:56 christos Exp $"); #include #include @@ -40,12 +40,17 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_signal.c,v 1.13 2009/06/08 13:34:23 njoly Ex #include #include #include +#include #include +#include #include #include +#include #include +#include +#include #define linux32_sigemptyset(s) memset((s), 0, sizeof(*(s))) #define linux32_sigismember(s, n) ((s)->sig[((n) - 1) / LINUX32__NSIG_BPW] \ @@ -92,6 +97,71 @@ native_to_linux32_sigset(linux32_sigset_t *lss, const sigset_t *bss) } } +void +native_to_linux32_siginfo(linux32_siginfo_t *lsi, const struct _ksiginfo *ksi) +{ + memset(lsi, 0, sizeof(*lsi)); + + lsi->lsi_signo = native_to_linux32_signo[ksi->_signo]; + lsi->lsi_errno = native_to_linux32_errno[ksi->_errno]; + lsi->lsi_code = native_to_linux32_si_code(ksi->_code); + + switch (ksi->_code) { + case SI_NOINFO: + break; + + case SI_USER: + lsi->lsi_pid = ksi->_reason._rt._pid; + lsi->lsi_uid = ksi->_reason._rt._uid; + if (lsi->lsi_signo == LINUX_SIGALRM || + lsi->lsi_signo >= LINUX_SIGRTMIN) + NETBSD32PTR32(lsi->lsi_value.sival_ptr, + ksi->_reason._rt._value.sival_ptr); + break; + + case SI_TIMER: + case SI_QUEUE: + lsi->lsi_uid = ksi->_reason._rt._uid; + lsi->lsi_uid = ksi->_reason._rt._uid; + NETBSD32PTR32(lsi->lsi_value.sival_ptr, + ksi->_reason._rt._value.sival_ptr); + break; + + case SI_ASYNCIO: + case SI_MESGQ: + NETBSD32PTR32(lsi->lsi_value.sival_ptr, + ksi->_reason._rt._value.sival_ptr); + break; + + default: + switch (ksi->_signo) { + case SIGCHLD: + lsi->lsi_uid = ksi->_reason._child._uid; + lsi->lsi_pid = ksi->_reason._child._pid; + lsi->lsi_status = native_to_linux32_si_status( + ksi->_code, ksi->_reason._child._status); + lsi->lsi_utime = ksi->_reason._child._utime; + lsi->lsi_stime = ksi->_reason._child._stime; + break; + + case SIGILL: + case SIGFPE: + case SIGSEGV: + case SIGBUS: + case SIGTRAP: + NETBSD32PTR32(lsi->lsi_addr, ksi->_reason._fault._addr); + break; + + case SIGIO: + lsi->lsi_fd = ksi->_reason._poll._fd; + lsi->lsi_band = ksi->_reason._poll._band; + break; + default: + break; + } + } +} + unsigned int native_to_linux32_sigflags(const int bsf) { @@ -362,6 +432,66 @@ linux32_sys_rt_sigsuspend(struct lwp *l, const struct linux32_sys_rt_sigsuspend_ return sigsuspend1(l, &bss); } +static int +fetchss(const void *u, void *s, size_t len) +{ + int error; + linux32_sigset_t lss; + + KASSERT(len == sizeof(lss)); + if ((error = copyin(u, &lss, sizeof(lss))) != 0) + return error; + + linux32_to_native_sigset(s, &lss); + return 0; +} + +static int +fetchts(const void *u, void *s, size_t len) +{ + int error; + struct linux32_timespec lts; + + KASSERT(len == sizeof(lts)); + if ((error = copyin(u, <s, sizeof(lts))) != 0) + return error; + + linux32_to_native_timespec(s, <s); + return 0; +} + +static int +fakestorets(const void *u, void *s, size_t len) +{ + /* Do nothing, sigtimedwait does not alter timeout like ours */ + return 0; +} + +static int +storeinfo(const void *s, void *u, size_t len) +{ + linux32_siginfo_t lsi; + + KASSERT(len == sizeof(lsi)); + + native_to_linux32_siginfo(&lsi, &((const siginfo_t *)s)->_info); + return copyout(&lsi, u, sizeof(lsi)); +} + +int +linux32_sys_rt_sigtimedwait(struct lwp *l, + const struct linux32_sys_rt_sigtimedwait_args *uap, register_t *retval) +{ + /* { + syscallarg(const linux32_sigset_t *) set; + syscallarg(linux32_siginfo_t *) info); + syscallarg(const struct linux32_timespec *) timeout; + } */ + + return sigtimedwait1(l, (const struct sys_____sigtimedwait50_args *)uap, + retval, fetchss, storeinfo, fetchts, fakestorets); +} + int linux32_sys_signal(struct lwp *l, const struct linux32_sys_signal_args *uap, register_t *retval) { @@ -470,3 +600,41 @@ linux32_sys_rt_queueinfo(struct lwp *l, const struct linux32_sys_rt_queueinfo_ar /* XXX keep a list of queued signals somewhere. */ return linux32_sys_kill(l, (const void *)uap, retval); } + +int +native_to_linux32_si_code(int code) +{ + int si_codes[] = { + LINUX32_SI_USER, LINUX32_SI_QUEUE, LINUX32_SI_TIMER, + LINUX32_SI_ASYNCIO, LINUX32_SI_MESGQ, LINUX32_SI_TKILL /* SI_LWP */ + }; + + if (code <= 0 && -code < __arraycount(si_codes)) + return si_codes[-code]; + + return code; +} + +int +native_to_linux32_si_status(int code, int status) +{ + int sts; + + switch (code) { + case CLD_CONTINUED: + sts = LINUX_SIGCONT; + break; + case CLD_EXITED: + sts = WEXITSTATUS(status); + break; + case CLD_STOPPED: + case CLD_TRAPPED: + case CLD_DUMPED: + case CLD_KILLED: + default: + sts = native_to_linux32_signo[WTERMSIG(status)]; + break; + } + + return sts; +} diff --git a/sys/compat/linux32/common/linux32_signal.h b/sys/compat/linux32/common/linux32_signal.h index fb79025f8d82..30b0b609698a 100644 --- a/sys/compat/linux32/common/linux32_signal.h +++ b/sys/compat/linux32/common/linux32_signal.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_signal.h,v 1.2 2007/12/04 18:40:18 dsl Exp $ */ +/* $NetBSD: linux32_signal.h,v 1.3 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,6 +33,7 @@ #ifndef _LINUX32_SIGNAL_H_ #define _LINUX32_SIGNAL_H_ +#include #ifdef __amd64__ #include #endif @@ -51,5 +52,7 @@ void native_to_linux32_old_sigset(linux32_old_sigset_t *, const sigset_t *); void linux32_old_extra_to_native_sigset(sigset_t *, const linux32_old_sigset_t *, const unsigned long *); void linux32_old_to_native_sigset(sigset_t *, const linux32_old_sigset_t *); +int native_to_linux32_si_code(int); +int native_to_linux32_si_status(int, int); #endif /* _LINUX32_SIGNAL_H_ */ diff --git a/sys/compat/linux32/common/linux32_time.c b/sys/compat/linux32/common/linux32_time.c index a16a3045ea8c..ed28a892472c 100644 --- a/sys/compat/linux32/common/linux32_time.c +++ b/sys/compat/linux32/common/linux32_time.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_time.c,v 1.35 2010/07/12 12:01:53 njoly Exp $ */ +/* $NetBSD: linux32_time.c,v 1.36 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -33,7 +33,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.35 2010/07/12 12:01:53 njoly Exp $"); +__KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.36 2011/11/18 04:08:56 christos Exp $"); #include #include @@ -74,6 +74,7 @@ __KERNEL_RCSID(0, "$NetBSD: linux32_time.c,v 1.35 2010/07/12 12:01:53 njoly Exp #include #include #include +#include #include extern struct timezone linux_sys_tz; diff --git a/sys/compat/linux32/common/linux32_types.h b/sys/compat/linux32/common/linux32_types.h index 0459ed9d88ca..afc7026ba327 100644 --- a/sys/compat/linux32/common/linux32_types.h +++ b/sys/compat/linux32/common/linux32_types.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux32_types.h,v 1.14 2010/11/02 18:14:06 chs Exp $ */ +/* $NetBSD: linux32_types.h,v 1.15 2011/11/18 04:08:56 christos Exp $ */ /*- * Copyright (c) 2006 Emmanuel Dreyfus, all rights reserved. @@ -111,11 +111,6 @@ struct linux32_sysinfo { char _f[20-2*sizeof(netbsd32_long)-sizeof(int)]; }; -struct linux32_timespec { - linux32_time_t tv_sec; - netbsd32_long tv_nsec; -}; - #define LINUX32_MAXNAMLEN 255 struct linux32_dirent { linux32_ino_t d_ino;