From 65957d54f1ae43a0c7543a6c8d9b3547c5e556ef Mon Sep 17 00:00:00 2001 From: "David P. Reese, Jr." Date: Fri, 24 Oct 2003 14:10:46 +0000 Subject: [PATCH] Remove the FreeBSD 3.x signal code. This includes osendsig(), osigreturn() and a couple of structures that these syscalls depended on. Split the sigaction(), sigprocmask(), sigpending(), sigsuspend(), sigaltstack() and kill() syscalls. Move the 4.3BSD signal syscalls osigvec(), osigblock(), osigsetmask(), osigstack() and okillpg() to the 43bsd subtree. I'm not too sure if these will even work with the FreeBSD-4 signal trampoline code, but they do compile and link. Implement linux_signal(), linux_rt_sigaction(), linux_sigprocmask(), linux_rt_sigprocmask(), linux_sigpending(), linux_kill(), linux_sigaction(), linux_sigsuspend(), linux_rt_sigsuspend(), linux_pause(), and linux_sigaltstack() with the new in-kernel syscalls. This patch kills 7 stackgap allocations in the Linuxolator. --- sys/conf/files | 3 +- sys/cpu/i386/include/sigframe.h | 37 +-- sys/cpu/i386/include/signal.h | 31 +- sys/emulation/43bsd/43bsd_signal.c | 171 +++++++++++ sys/emulation/linux/i386/linux_machdep.c | 133 ++++----- sys/emulation/linux/linux_signal.c | 214 +++++--------- sys/emulation/linux/linux_signal.h | 5 +- sys/i386/i386/genassym.c | 7 +- sys/i386/i386/locore.s | 21 +- sys/i386/i386/machdep.c | 240 +-------------- sys/i386/include/md_var.h | 4 +- sys/i386/include/sigframe.h | 37 +-- sys/i386/include/signal.h | 31 +- sys/kern/init_sysent.c | 14 +- sys/kern/kern_sig.c | 360 +++++++---------------- sys/kern/syscalls.c | 14 +- sys/kern/syscalls.master | 13 +- sys/platform/pc32/i386/genassym.c | 7 +- sys/platform/pc32/i386/locore.s | 21 +- sys/platform/pc32/i386/machdep.c | 240 +-------------- sys/platform/pc32/include/md_var.h | 4 +- sys/platform/vkernel/i386/genassym.c | 7 +- sys/sys/kern_syscall.h | 16 +- sys/sys/signalvar.h | 30 +- sys/sys/syscall-hide.h | 9 +- sys/sys/syscall.h | 14 +- sys/sys/syscall.mk | 4 +- sys/sys/sysproto.h | 47 +-- sys/sys/sysunion.h | 17 +- 29 files changed, 484 insertions(+), 1267 deletions(-) create mode 100644 sys/emulation/43bsd/43bsd_signal.c diff --git a/sys/conf/files b/sys/conf/files index 2bc2294c57..5a564497a4 100644 --- a/sys/conf/files +++ b/sys/conf/files @@ -1,5 +1,5 @@ # $FreeBSD: src/sys/conf/files,v 1.340.2.137 2003/06/04 17:10:30 sam Exp $ -# $DragonFly: src/sys/conf/files,v 1.20 2003/10/21 01:05:09 daver Exp $ +# $DragonFly: src/sys/conf/files,v 1.21 2003/10/24 14:10:45 daver Exp $ # # The long compile-with and dependency lines are required because of # limitations in config: backslash-newline doesn't work in strings, and @@ -1583,3 +1583,4 @@ dev/drm/tdfx/tdfx_drv.c optional tdfxdrm emulation/43bsd/43bsd_socket.c optional compat_43 emulation/43bsd/43bsd_stats.c optional compat_43 emulation/43bsd/43bsd_file.c optional compat_43 +emulation/43bsd/43bsd_signal.c optional compat_43 diff --git a/sys/cpu/i386/include/sigframe.h b/sys/cpu/i386/include/sigframe.h index 4ce6221e21..d5a35a7511 100644 --- a/sys/cpu/i386/include/sigframe.h +++ b/sys/cpu/i386/include/sigframe.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/sigframe.h,v 1.5 1999/12/04 10:40:24 marcel Exp $ - * $DragonFly: src/sys/cpu/i386/include/sigframe.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/sigframe.h,v 1.3 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_SIGFRAME_H_ @@ -36,41 +36,6 @@ * Signal frames, arguments passed to application signal handlers. */ -struct osigframe { - /* - * The first four members may be used by applications. - */ - - register_t sf_signum; - - /* - * Either 'int' for old-style FreeBSD handler or 'siginfo_t *' - * pointing to sf_siginfo for SA_SIGINFO handlers. - */ - register_t sf_arg2; - - /* Points to sf_siginfo.si_sc. */ - register_t sf_scp; - - register_t sf_addr; - - /* - * The following arguments are not constrained by the - * function call protocol. - * Applications are not supposed to access these members, - * except using the pointers we provide in the first three - * arguments. - */ - - union { - __osiginfohandler_t *sf_action; - __sighandler_t *sf_handler; - } sf_ahu; - - /* In the SA_SIGINFO case, sf_arg2 points here. */ - osiginfo_t sf_siginfo; -}; - struct sigframe { /* * The first four members may be used by applications. diff --git a/sys/cpu/i386/include/signal.h b/sys/cpu/i386/include/signal.h index f21002b451..7cedfd147d 100644 --- a/sys/cpu/i386/include/signal.h +++ b/sys/cpu/i386/include/signal.h @@ -32,7 +32,7 @@ * * @(#)signal.h 8.1 (Berkeley) 6/11/93 * $FreeBSD: src/sys/i386/include/signal.h,v 1.12 1999/11/12 13:52:11 marcel Exp $ - * $DragonFly: src/sys/cpu/i386/include/signal.h,v 1.4 2003/08/20 23:05:33 dillon Exp $ + * $DragonFly: src/sys/cpu/i386/include/signal.h,v 1.5 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_SIGNAL_H_ @@ -60,34 +60,7 @@ typedef int sig_atomic_t; * execution of the signal handler. It is also made available * to the handler to allow it to restore state properly if * a non-standard exit is performed. - */ -typedef unsigned int osigset_t; - -struct osigcontext { - int sc_onstack; /* sigstack state to restore */ - osigset_t sc_mask; /* signal mask to restore */ - int sc_esp; /* machine state follows: */ - int sc_ebp; - int sc_isp; - int sc_eip; - int sc_efl; - int sc_es; - int sc_ds; - int sc_cs; - int sc_ss; - int sc_edi; - int sc_esi; - int sc_ebx; - int sc_edx; - int sc_ecx; - int sc_eax; - int sc_gs; - int sc_fs; - int sc_trapno; - int sc_err; -}; - -/* + * * The sequence of the fields/registers in struct sigcontext should match * those in mcontext_t. */ diff --git a/sys/emulation/43bsd/43bsd_signal.c b/sys/emulation/43bsd/43bsd_signal.c new file mode 100644 index 0000000000..b662084dd9 --- /dev/null +++ b/sys/emulation/43bsd/43bsd_signal.c @@ -0,0 +1,171 @@ +/* + * 43BSD_SIGNAL.C - 4.3BSD compatibility signal syscalls + * + * Copyright (c) 1989, 1993 + * The Regents of the University of California. All rights reserved. + * (c) UNIX System Laboratories, Inc. + * All or some portions of this file are derived from material licensed + * to the University of California by American Telephone and Telegraph + * Co. or Unix System Laboratories, Inc. and are reproduced herein with + * the permission of UNIX System Laboratories, Inc. + * + * 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. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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. + * + * $DragonFly: src/sys/emulation/43bsd/43bsd_signal.c,v 1.1 2003/10/24 14:10:45 daver Exp $ + * from: DragonFly kern/kern_sig.c,v 1.22 + * + * These syscalls used to live in kern/kern_sig.c. They are modified + * to use the new split syscalls. + */ + +#include "opt_compat.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ + +#define SIG2OSIG(sig, osig) osig = (sig).__bits[0] +#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig + +#define SIGSETLO(set1, set2) ((set1).__bits[0] = (set2).__bits[0]) + +/* + * These syscalls are unncessary because it is next to impossible to + * find 4.3BSD binaries built for i386. The current libc has routines + * which fake the 4.3BSD family of signal syscalls, so anything built + * from source won't be using these. + * + * This file is provided for educational purposes only. The osigvec() + * syscall is probably broken because the current signal code uses + * a different signal trampoline. + */ + +int +osigvec(struct osigvec_args *uap) +{ + struct sigvec vec; + struct sigaction nsa, osa; + struct sigaction *nsap, *osap; + int error; + + if (uap->signum <= 0 || uap->signum >= ONSIG) + return (EINVAL); + nsap = (uap->nsv != NULL) ? &nsa : NULL; + osap = (uap->osv != NULL) ? &osa : NULL; + if (nsap) { + error = copyin(uap->nsv, &vec, sizeof(vec)); + if (error) + return (error); + nsap->sa_handler = vec.sv_handler; + OSIG2SIG(vec.sv_mask, nsap->sa_mask); + nsap->sa_flags = vec.sv_flags; + nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */ + } + + error = kern_sigaction(uap->signum, nsap, osap); + + if (osap && !error) { + vec.sv_handler = osap->sa_handler; + SIG2OSIG(osap->sa_mask, vec.sv_mask); + vec.sv_flags = osap->sa_flags; + vec.sv_flags &= ~SA_NOCLDWAIT; + vec.sv_flags ^= SA_RESTART; + error = copyout(&vec, uap->osv, sizeof(vec)); + } + return (error); +} + +int +osigblock(struct osigblock_args *uap) +{ + struct proc *p = curproc; + sigset_t set; + + OSIG2SIG(uap->mask, set); + SIG_CANTMASK(set); + (void) splhigh(); + SIG2OSIG(p->p_sigmask, uap->sysmsg_result); + SIGSETOR(p->p_sigmask, set); + (void) spl0(); + return (0); +} + +int +osigsetmask(struct osigsetmask_args *uap) +{ + struct proc *p = curproc; + sigset_t set; + + OSIG2SIG(uap->mask, set); + SIG_CANTMASK(set); + (void) splhigh(); + SIG2OSIG(p->p_sigmask, uap->sysmsg_result); + SIGSETLO(p->p_sigmask, set); + (void) spl0(); + return (0); +} + +int +osigstack(struct osigstack_args *uap) +{ + struct proc *p = curproc; + struct sigstack ss; + int error = 0; + + ss.ss_sp = p->p_sigstk.ss_sp; + ss.ss_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; + if (uap->oss && (error = copyout(&ss, uap->oss, + sizeof(struct sigstack)))) + return (error); + if (uap->nss && (error = copyin(uap->nss, &ss, sizeof(ss))) == 0) { + p->p_sigstk.ss_sp = ss.ss_sp; + p->p_sigstk.ss_size = 0; + p->p_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK; + p->p_flag |= P_ALTSTACK; + } + return (error); +} + +int +okillpg(struct okillpg_args *uap) +{ + int error; + + error = kern_kill(uap->signum, -uap->pgid); + + return (error); +} diff --git a/sys/emulation/linux/i386/linux_machdep.c b/sys/emulation/linux/i386/linux_machdep.c index 19d72ce6b8..5c75cca71d 100644 --- a/sys/emulation/linux/i386/linux_machdep.c +++ b/sys/emulation/linux/i386/linux_machdep.c @@ -26,11 +26,12 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/linux/linux_machdep.c,v 1.6.2.4 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/i386/linux_machdep.c,v 1.9 2003/08/20 07:13:27 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/i386/linux_machdep.c,v 1.10 2003/10/24 14:10:45 daver Exp $ */ #include #include +#include #include #include #include @@ -691,7 +692,8 @@ int linux_sigaction(struct linux_sigaction_args *args) { l_osigaction_t osa; - l_sigaction_t act, oact; + l_sigaction_t linux_act, linux_oact; + struct sigaction act, oact; int error; #ifdef DEBUG @@ -700,30 +702,29 @@ linux_sigaction(struct linux_sigaction_args *args) args->sig, (void *)args->nsa, (void *)args->osa); #endif - if (args->nsa != NULL) { - error = copyin((caddr_t)args->nsa, &osa, - sizeof(l_osigaction_t)); + if (args->nsa) { + error = copyin(args->nsa, &osa, sizeof(l_osigaction_t)); if (error) return (error); - act.lsa_handler = osa.lsa_handler; - 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; + linux_act.lsa_handler = osa.lsa_handler; + linux_act.lsa_flags = osa.lsa_flags; + linux_act.lsa_restorer = osa.lsa_restorer; + LINUX_SIGEMPTYSET(linux_act.lsa_mask); + linux_act.lsa_mask.__bits[0] = osa.lsa_mask; + linux_to_bsd_sigaction(&linux_act, &act); } - error = linux_do_sigaction(args->sig, args->nsa ? &act : NULL, - args->osa ? &oact : NULL, &args->sysmsg_result); + error = kern_sigaction(args->sig, args->nsa ? &act : NULL, + args->osa ? &oact : NULL); if (args->osa != NULL && !error) { - 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]; - error = copyout(&osa, (caddr_t)args->osa, - sizeof(l_osigaction_t)); + bsd_to_linux_sigaction(&oact, &linux_oact); + osa.lsa_handler = linux_oact.lsa_handler; + osa.lsa_flags = linux_oact.lsa_flags; + osa.lsa_restorer = linux_oact.lsa_restorer; + osa.lsa_mask = linux_oact.lsa_mask.__bits[0]; + error = copyout(&osa, args->osa, sizeof(l_osigaction_t)); } - return (error); } @@ -735,10 +736,8 @@ linux_sigaction(struct linux_sigaction_args *args) int linux_sigsuspend(struct linux_sigsuspend_args *args) { - struct sigsuspend_args bsd; - sigset_t *sigmask; - l_sigset_t mask; - caddr_t sg = stackgap_init(); + l_sigset_t linux_mask; + sigset_t mask; int error; #ifdef DEBUG @@ -746,24 +745,20 @@ linux_sigsuspend(struct linux_sigsuspend_args *args) printf(ARGS(sigsuspend, "%08lx"), (unsigned long)args->mask); #endif - sigmask = stackgap_alloc(&sg, sizeof(sigset_t)); LINUX_SIGEMPTYSET(mask); mask.__bits[0] = args->mask; - linux_to_bsd_sigset(&mask, sigmask); - bsd.sigmask = sigmask; - bsd.sysmsg_result = 0; - error = sigsuspend(&bsd); - args->sysmsg_result = bsd.sysmsg_result; + linux_to_bsd_sigset(&linux_mask, &mask); + + error = kern_sigsuspend(&mask); + return(error); } int linux_rt_sigsuspend(struct linux_rt_sigsuspend_args *uap) { - l_sigset_t lmask; - sigset_t *bmask; - struct sigsuspend_args bsd; - caddr_t sg = stackgap_init(); + l_sigset_t linux_mask; + sigset_t mask; int error; #ifdef DEBUG @@ -775,26 +770,23 @@ linux_rt_sigsuspend(struct linux_rt_sigsuspend_args *uap) if (uap->sigsetsize != sizeof(l_sigset_t)) return (EINVAL); - error = copyin(uap->newset, &lmask, sizeof(l_sigset_t)); + error = copyin(uap->newset, &linux_mask, sizeof(l_sigset_t)); if (error) return (error); - bmask = stackgap_alloc(&sg, sizeof(sigset_t)); - linux_to_bsd_sigset(&lmask, bmask); - bsd.sigmask = bmask; - bsd.sysmsg_result = 0; - error = sigsuspend(&bsd); - uap->sysmsg_result = bsd.sysmsg_result; + linux_to_bsd_sigset(&linux_mask, &mask); + + error = kern_sigsuspend(&mask); + return(error); } int linux_pause(struct linux_pause_args *args) { - struct proc *p = curproc; - struct sigsuspend_args bsd; - sigset_t *sigmask; - caddr_t sg = stackgap_init(); + struct thread *td = curthread; + struct proc *p = td->td_proc; + sigset_t mask; int error; #ifdef DEBUG @@ -802,56 +794,43 @@ linux_pause(struct linux_pause_args *args) printf(ARGS(pause, "")); #endif - sigmask = stackgap_alloc(&sg, sizeof(sigset_t)); - *sigmask = p->p_sigmask; - bsd.sigmask = sigmask; - bsd.sysmsg_result = 0; - error = sigsuspend(&bsd); - args->sysmsg_result = bsd.sysmsg_result; + mask = p->p_sigmask; + + error = kern_sigsuspend(&mask); + return(error); } int linux_sigaltstack(struct linux_sigaltstack_args *uap) { - struct sigaltstack_args bsd; - stack_t *ss, *oss; - l_stack_t lss; + stack_t ss, oss; + l_stack_t linux_ss; int error; - caddr_t sg = stackgap_init(); #ifdef DEBUG if (ldebug(sigaltstack)) printf(ARGS(sigaltstack, "%p, %p"), uap->uss, uap->uoss); #endif - if (uap->uss == NULL) { - ss = NULL; - } else { - error = copyin(uap->uss, &lss, sizeof(l_stack_t)); + if (uap->uss) { + error = copyin(uap->uss, &linux_ss, sizeof(l_stack_t)); if (error) return (error); - ss = stackgap_alloc(&sg, sizeof(stack_t)); - ss->ss_sp = lss.ss_sp; - ss->ss_size = lss.ss_size; - ss->ss_flags = linux_to_bsd_sigaltstack(lss.ss_flags); + ss.ss_sp = linux_ss.ss_sp; + ss.ss_size = linux_ss.ss_size; + ss.ss_flags = linux_to_bsd_sigaltstack(linux_ss.ss_flags); } - oss = (uap->uoss != NULL) - ? stackgap_alloc(&sg, sizeof(stack_t)) - : NULL; - - bsd.ss = ss; - bsd.oss = oss; - bsd.sysmsg_result = 0; - error = sigaltstack(&bsd); - uap->sysmsg_result = bsd.sysmsg_result; - - if (!error && oss != NULL) { - lss.ss_sp = oss->ss_sp; - lss.ss_size = oss->ss_size; - lss.ss_flags = bsd_to_linux_sigaltstack(oss->ss_flags); - error = copyout(&lss, uap->uoss, sizeof(l_stack_t)); + + error = kern_sigaltstack(uap->uss ? &ss : NULL, + uap->uoss ? &oss : NULL); + + if (error == 0 && uap->uoss) { + linux_ss.ss_sp = oss.ss_sp; + linux_ss.ss_size = oss.ss_size; + linux_ss.ss_flags = bsd_to_linux_sigaltstack(oss.ss_flags); + error = copyout(&linux_ss, uap->uoss, sizeof(l_stack_t)); } return (error); diff --git a/sys/emulation/linux/linux_signal.c b/sys/emulation/linux/linux_signal.c index 3c19bc25ff..dce0784615 100644 --- a/sys/emulation/linux/linux_signal.c +++ b/sys/emulation/linux/linux_signal.c @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_signal.c,v 1.23.2.3 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_signal.c,v 1.7 2003/08/15 06:32:51 dillon Exp $ + * $DragonFly: src/sys/emulation/linux/linux_signal.c,v 1.8 2003/10/24 14:10:45 daver Exp $ */ #include @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -83,7 +84,7 @@ bsd_to_linux_sigset(sigset_t *bss, l_sigset_t *lss) } } -static void +void linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) { @@ -106,7 +107,7 @@ linux_to_bsd_sigaction(l_sigaction_t *lsa, struct sigaction *bsa) bsa->sa_flags |= SA_NODEFER; } -static void +void bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa) { @@ -130,73 +131,28 @@ bsd_to_linux_sigaction(struct sigaction *bsa, l_sigaction_t *lsa) lsa->lsa_flags |= LINUX_SA_NOMASK; } -int -linux_do_sigaction(int linux_sig, l_sigaction_t *linux_nsa, - l_sigaction_t *linux_osa, int *res) -{ - struct sigaction *nsa, *osa; - struct sigaction_args sa_args; - int error; - caddr_t sg = stackgap_init(); - - if (linux_sig <= 0 || linux_sig > LINUX_NSIG) - return (EINVAL); - - if (linux_osa != NULL) - osa = stackgap_alloc(&sg, sizeof(struct sigaction)); - else - osa = NULL; - - if (linux_nsa != NULL) { - nsa = stackgap_alloc(&sg, sizeof(struct sigaction)); - linux_to_bsd_sigaction(linux_nsa, nsa); - } - else - nsa = NULL; - -#ifndef __alpha__ - if (linux_sig <= LINUX_SIGTBLSZ) - sa_args.sig = linux_to_bsd_signal[_SIG_IDX(linux_sig)]; - else -#endif - sa_args.sig = linux_sig; - - sa_args.act = nsa; - sa_args.oact = osa; - sa_args.sysmsg_result = 0; - error = sigaction(&sa_args); - if (error) - return (error); - *res = sa_args.sysmsg_result; - - if (linux_osa != NULL) - bsd_to_linux_sigaction(osa, linux_osa); - - return (0); -} - - #ifndef __alpha__ int linux_signal(struct linux_signal_args *args) { - l_sigaction_t nsa, osa; + l_sigaction_t linux_nsa, linux_osa; + struct sigaction nsa, osa; int error; - int dummy; #ifdef DEBUG if (ldebug(signal)) printf(ARGS(signal, "%d, %p"), args->sig, (void *)args->handler); #endif + linux_nsa.lsa_handler = args->handler; + linux_nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; + LINUX_SIGEMPTYSET(linux_nsa.lsa_mask); + linux_to_bsd_sigaction(&linux_nsa, &nsa); - nsa.lsa_handler = args->handler; - nsa.lsa_flags = LINUX_SA_ONESHOT | LINUX_SA_NOMASK; - LINUX_SIGEMPTYSET(nsa.lsa_mask); - - error = linux_do_sigaction(args->sig, &nsa, &osa, &dummy); - args->sysmsg_result = (int)osa.lsa_handler; + error = kern_sigaction(args->sig, &nsa, &osa); + bsd_to_linux_sigaction(&osa, &linux_osa); + args->sysmsg_result = (int) linux_osa.lsa_handler; return (error); } #endif /*!__alpha__*/ @@ -204,7 +160,8 @@ linux_signal(struct linux_signal_args *args) int linux_rt_sigaction(struct linux_rt_sigaction_args *args) { - l_sigaction_t nsa, osa; + l_sigaction_t linux_nsa, linux_osa; + struct sigaction nsa, osa; int error; #ifdef DEBUG @@ -213,63 +170,40 @@ linux_rt_sigaction(struct linux_rt_sigaction_args *args) (long)args->sig, (void *)args->act, (void *)args->oact, (long)args->sigsetsize); #endif - if (args->sigsetsize != sizeof(l_sigset_t)) return (EINVAL); - if (args->act != NULL) { - error = copyin(args->act, &nsa, sizeof(l_sigaction_t)); + if (args->act) { + error = copyin(args->act, &linux_nsa, sizeof(linux_nsa)); if (error) return (error); + linux_to_bsd_sigaction(&linux_nsa, &nsa); } - error = linux_do_sigaction(args->sig, - args->act ? &nsa : NULL, - args->oact ? &osa : NULL, - &args->sysmsg_result); + error = kern_sigaction(args->sig, args->act ? &nsa : NULL, + args->oact ? &osa : NULL); - if (args->oact != NULL && !error) { - error = copyout(&osa, args->oact, sizeof(l_sigaction_t)); + if (error == 0 && args->oact) { + bsd_to_linux_sigaction(&osa, &linux_osa); + error = copyout(&linux_osa, args->oact, sizeof(linux_osa)); } return (error); } static int -linux_do_sigprocmask(int how, l_sigset_t *new, l_sigset_t *old, int *res) +linux_to_bsd_sigprocmask(int how) { - struct proc *p = curproc; - int error; - sigset_t mask; - - error = 0; - *res = 0; - - if (old != NULL) - bsd_to_linux_sigset(&p->p_sigmask, old); - - if (new != NULL) { - linux_to_bsd_sigset(new, &mask); - - switch (how) { - case LINUX_SIG_BLOCK: - SIGSETOR(p->p_sigmask, mask); - SIG_CANTMASK(p->p_sigmask); - break; - case LINUX_SIG_UNBLOCK: - SIGSETNAND(p->p_sigmask, mask); - break; - case LINUX_SIG_SETMASK: - p->p_sigmask = mask; - SIG_CANTMASK(p->p_sigmask); - break; - default: - error = EINVAL; - break; - } + switch (how) { + case LINUX_SIG_BLOCK: + return SIG_BLOCK; + case LINUX_SIG_UNBLOCK: + return SIG_UNBLOCK; + case LINUX_SIG_SETMASK: + return SIG_SETMASK; + default: + return (-1); } - - return (error); } #ifndef __alpha__ @@ -277,32 +211,33 @@ int linux_sigprocmask(struct linux_sigprocmask_args *args) { l_osigset_t mask; - l_sigset_t set, oset; - int error; + l_sigset_t linux_set, linux_oset; + sigset_t set, oset; + int error, how; #ifdef DEBUG if (ldebug(sigprocmask)) printf(ARGS(sigprocmask, "%d, *, *"), args->how); #endif - if (args->mask != NULL) { + if (args->mask) { error = copyin(args->mask, &mask, sizeof(l_osigset_t)); if (error) return (error); - LINUX_SIGEMPTYSET(set); - set.__bits[0] = mask; + LINUX_SIGEMPTYSET(linux_set); + linux_set.__bits[0] = mask; + linux_to_bsd_sigset(&linux_set, &set); } + how = linux_to_bsd_sigprocmask(args->how); - error = linux_do_sigprocmask(args->how, - args->mask ? &set : NULL, - args->omask ? &oset : NULL, - &args->sysmsg_result); + error = kern_sigprocmask(how, args->mask ? &set : NULL, + args->omask ? &oset : NULL); - if (args->omask != NULL && !error) { - mask = oset.__bits[0]; + if (error == 0 && args->omask) { + bsd_to_linux_sigset(&oset, &linux_oset); + mask = linux_oset.__bits[0]; error = copyout(&mask, args->omask, sizeof(l_osigset_t)); } - return (error); } #endif /*!__alpha__*/ @@ -310,8 +245,9 @@ linux_sigprocmask(struct linux_sigprocmask_args *args) int linux_rt_sigprocmask(struct linux_rt_sigprocmask_args *args) { - l_sigset_t set, oset; - int error; + l_sigset_t linux_set, linux_oset; + sigset_t set, oset; + int error, how; #ifdef DEBUG if (ldebug(rt_sigprocmask)) @@ -323,19 +259,20 @@ linux_rt_sigprocmask(struct linux_rt_sigprocmask_args *args) if (args->sigsetsize != sizeof(l_sigset_t)) return EINVAL; - if (args->mask != NULL) { - error = copyin(args->mask, &set, sizeof(l_sigset_t)); + if (args->mask) { + error = copyin(args->mask, &linux_set, sizeof(l_sigset_t)); if (error) return (error); + linux_to_bsd_sigset(&linux_set, &set); } + how = linux_to_bsd_sigprocmask(args->how); - error = linux_do_sigprocmask(args->how, - args->mask ? &set : NULL, - args->omask ? &oset : NULL, - &args->sysmsg_result); + error = kern_sigprocmask(how, args->mask ? &set : NULL, + args->omask ? &oset : NULL); - if (args->omask != NULL && !error) { - error = copyout(&oset, args->omask, sizeof(l_sigset_t)); + if (error == 0 && args->omask) { + bsd_to_linux_sigset(&oset, &linux_oset); + error = copyout(&linux_oset, args->omask, sizeof(l_sigset_t)); } return (error); @@ -383,29 +320,34 @@ linux_ssetmask(struct linux_ssetmask_args *args) int linux_sigpending(struct linux_sigpending_args *args) { - struct proc *p = curproc; - sigset_t bset; - l_sigset_t lset; + struct thread *td = curthread; + struct proc *p = td->td_proc; + sigset_t set; + l_sigset_t linux_set; l_osigset_t mask; + int error; #ifdef DEBUG if (ldebug(sigpending)) printf(ARGS(sigpending, "*")); #endif - bset = p->p_siglist; - SIGSETAND(bset, p->p_sigmask); - bsd_to_linux_sigset(&bset, &lset); - mask = lset.__bits[0]; - return (copyout(&mask, args->mask, sizeof(mask))); + error = kern_sigpending(&set); + + if (error == 0) { + SIGSETAND(set, p->p_sigmask); + bsd_to_linux_sigset(&set, &linux_set); + mask = linux_set.__bits[0]; + error = copyout(&mask, args->mask, sizeof(mask)); + } + return (error); } #endif /*!__alpha__*/ int linux_kill(struct linux_kill_args *args) { - struct kill_args ka; - int error; + int error, sig; #ifdef DEBUG if (ldebug(kill)) @@ -420,15 +362,13 @@ linux_kill(struct linux_kill_args *args) #ifndef __alpha__ if (args->signum > 0 && args->signum <= LINUX_SIGTBLSZ) - ka.signum = linux_to_bsd_signal[_SIG_IDX(args->signum)]; + sig = linux_to_bsd_signal[_SIG_IDX(args->signum)]; else #endif - ka.signum = args->signum; + sig = args->signum; + + error = kern_kill(sig, args->pid); - ka.pid = args->pid; - ka.sysmsg_result = 0; - error = kill(&ka); - args->sysmsg_result = ka.sysmsg_result; return(error); } diff --git a/sys/emulation/linux/linux_signal.h b/sys/emulation/linux/linux_signal.h index 07f7ed044b..f850c9c6e9 100644 --- a/sys/emulation/linux/linux_signal.h +++ b/sys/emulation/linux/linux_signal.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/compat/linux/linux_signal.h,v 1.2.2.3 2001/11/05 19:08:23 marcel Exp $ - * $DragonFly: src/sys/emulation/linux/linux_signal.h,v 1.5 2003/08/27 06:30:03 rob Exp $ + * $DragonFly: src/sys/emulation/linux/linux_signal.h,v 1.6 2003/10/24 14:10:45 daver Exp $ */ #ifndef _LINUX_SIGNAL_H_ @@ -34,6 +34,7 @@ void linux_to_bsd_sigset (l_sigset_t *, sigset_t *); void bsd_to_linux_sigset (sigset_t *, l_sigset_t *); -int linux_do_sigaction (int, l_sigaction_t *, l_sigaction_t *, int *); +void linux_to_bsd_sigaction(l_sigaction_t *, struct sigaction *); +void bsd_to_linux_sigaction(struct sigaction *, l_sigaction_t *); #endif /* _LINUX_SIGNAL_H_ */ diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index d803606712..d893087084 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.30 2003/10/02 22:26:56 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.31 2003/10/24 14:10:45 daver Exp $ */ #include "opt_user_ldt.h" @@ -163,12 +163,7 @@ ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); -ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); -ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); -ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); -ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); -ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(B_READ, B_READ); diff --git a/sys/i386/i386/locore.s b/sys/i386/i386/locore.s index 44b4975d03..89bb9dc2f3 100644 --- a/sys/i386/i386/locore.s +++ b/sys/i386/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.7 2003/07/31 19:56:59 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/locore.s,v 1.8 2003/10/24 14:10:45 daver Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -394,30 +394,13 @@ NON_GPROF_ENTRY(sigcode) int $0x80 /* enter kernel with args */ 0: jmp 0b - ALIGN_TEXT -osigcode: - call *SIGF_HANDLER(%esp) /* call signal handler */ - lea SIGF_SC(%esp),%eax /* get sigcontext */ - pushl %eax - testl $PSL_VM,SC_PS(%eax) - jne 9f - movl SC_GS(%eax),%gs /* restore %gs */ -9: - movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */ - movl $SYS_sigreturn,%eax - pushl %eax /* junk to fake return addr. */ - int $0x80 /* enter kernel with args */ -0: jmp 0b - ALIGN_TEXT esigcode: .data - .globl szsigcode, szosigcode + .globl szsigcode szsigcode: .long esigcode - sigcode -szosigcode: - .long esigcode - osigcode .text /********************************************************************** diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 906b34576e..515ecb920a 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.38 2003/10/19 00:23:21 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.39 2003/10/24 14:10:45 daver Exp $ */ #include "use_apm.h" @@ -466,119 +466,6 @@ again: * frame pointer, it returns to the user * specified pc, psl. */ -static void -osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) -{ - struct proc *p = curproc; - struct trapframe *regs; - struct osigframe *fp; - struct osigframe sf; - struct sigacts *psp = p->p_sigacts; - int oonstack; - - regs = p->p_md.md_regs; - oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0; - - /* Allocate and validate space for the signal handler context. */ - if ((p->p_flag & P_ALTSTACK) && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct osigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - sizeof(struct osigframe)); - p->p_sigstk.ss_flags |= SS_ONSTACK; - } - else - fp = (struct osigframe *)regs->tf_esp - 1; - - /* Translate the signal if appropriate */ - if (p->p_sysent->sv_sigtbl) { - if (sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - } - - /* Build the argument list for the signal handler. */ - sf.sf_signum = sig; - sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; - if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - sf.sf_arg2 = (register_t)&fp->sf_siginfo; - sf.sf_siginfo.si_signo = sig; - sf.sf_siginfo.si_code = code; - sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher; - } - else { - /* Old FreeBSD-style arguments. */ - sf.sf_arg2 = code; - sf.sf_addr = regs->tf_err; - sf.sf_ahu.sf_handler = catcher; - } - - /* save scratch registers */ - sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax; - sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx; - sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx; - sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx; - sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi; - sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi; - sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; - sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; - sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; - sf.sf_siginfo.si_sc.sc_es = regs->tf_es; - sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; - sf.sf_siginfo.si_sc.sc_gs = rgs(); - sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; - - /* Build the signal context to be used by sigreturn. */ - sf.sf_siginfo.si_sc.sc_onstack = oonstack; - SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); - sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp; - sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp; - sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip; - sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags; - sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; - sf.sf_siginfo.si_sc.sc_err = regs->tf_err; - - /* - * If we're a vm86 process, we want to save the segment registers. - * We also change eflags to be our emulated eflags, not the actual - * eflags. - */ - if (regs->tf_eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; - - sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; - sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; - sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es; - sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds; - - if (vm86->vm86_has_vme == 0) - sf.sf_siginfo.si_sc.sc_ps = - (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) - | (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); - /* see sendsig for comment */ - tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); - } - - /* Copy the sigframe out to the user's stack. */ - if (copyout(&sf, fp, sizeof(struct osigframe)) != 0) { - /* - * Something is wrong with the stack pointer. - * ...Kill the process. - */ - sigexit(p, SIGILL); - } - - regs->tf_esp = (int)fp; - regs->tf_eip = PS_STRINGS - szosigcode; - regs->tf_eflags &= ~PSL_T; - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - load_gs(_udatasel); - regs->tf_ss = _udatasel; -} - void sendsig(catcher, sig, mask, code) sig_t catcher; @@ -592,11 +479,6 @@ sendsig(catcher, sig, mask, code) struct sigframe sf, *sfp; int oonstack; - if (SIGISMEMBER(psp->ps_osigset, sig)) { - osendsig(catcher, sig, mask, code); - return; - } - regs = p->p_md.md_regs; oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0; @@ -696,7 +578,7 @@ sendsig(catcher, sig, mask, code) } /* - * osigreturn_args(struct osigcontext *sigcntxp) + * sigreturn(ucontext_t *sigcntxp) * * System call to cleanup state after a signal * has been taken. Reset signal mask and @@ -709,112 +591,6 @@ sendsig(catcher, sig, mask, code) #define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) #define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) -int -osigreturn(struct osigreturn_args *uap) -{ - struct proc *p = curproc; - struct osigcontext *scp; - struct trapframe *regs = p->p_md.md_regs; - int eflags; - - scp = uap->sigcntxp; - - if (!useracc((caddr_t)scp, sizeof (struct osigcontext), VM_PROT_READ)) - return(EFAULT); - - eflags = scp->sc_ps; - if (eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86; - - /* - * if pcb_ext == 0 or vm86_inited == 0, the user hasn't - * set up the vm86 area, and we can't enter vm86 mode. - */ - if (p->p_thread->td_pcb->pcb_ext == 0) - return (EINVAL); - vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; - if (vm86->vm86_inited == 0) - return (EINVAL); - - /* go back to user mode if both flags are set */ - if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) - trapsignal(p, SIGBUS, 0); - - if (vm86->vm86_has_vme) { - eflags = (tf->tf_eflags & ~VME_USERCHANGE) | - (eflags & VME_USERCHANGE) | PSL_VM; - } else { - vm86->vm86_eflags = eflags; /* save VIF, VIP */ - eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM; - } - tf->tf_vm86_ds = scp->sc_ds; - tf->tf_vm86_es = scp->sc_es; - tf->tf_vm86_fs = scp->sc_fs; - tf->tf_vm86_gs = scp->sc_gs; - tf->tf_ds = _udatasel; - tf->tf_es = _udatasel; - tf->tf_fs = _udatasel; - } else { - /* - * Don't allow users to change privileged or reserved flags. - */ - /* - * XXX do allow users to change the privileged flag PSL_RF. - * The cpu sets PSL_RF in tf_eflags for faults. Debuggers - * should sometimes set it there too. tf_eflags is kept in - * the signal context during signal handling and there is no - * other place to remember it, so the PSL_RF bit may be - * corrupted by the signal handler without us knowing. - * Corruption of the PSL_RF bit at worst causes one more or - * one less debugger trap, so allowing it is fairly harmless. - */ - if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - return(EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ - if (!CS_SECURE(scp->sc_cs)) { - trapsignal(p, SIGBUS, T_PROTFLT); - return(EINVAL); - } - regs->tf_ds = scp->sc_ds; - regs->tf_es = scp->sc_es; - regs->tf_fs = scp->sc_fs; - } - - /* restore scratch registers */ - regs->tf_eax = scp->sc_eax; - regs->tf_ebx = scp->sc_ebx; - regs->tf_ecx = scp->sc_ecx; - regs->tf_edx = scp->sc_edx; - regs->tf_esi = scp->sc_esi; - regs->tf_edi = scp->sc_edi; - regs->tf_cs = scp->sc_cs; - regs->tf_ss = scp->sc_ss; - regs->tf_isp = scp->sc_isp; - - if (scp->sc_onstack & 01) - p->p_sigstk.ss_flags |= SS_ONSTACK; - else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; - - SIGSETOLD(p->p_sigmask, scp->sc_mask); - SIG_CANTMASK(p->p_sigmask); - regs->tf_ebp = scp->sc_fp; - regs->tf_esp = scp->sc_sp; - regs->tf_eip = scp->sc_pc; - regs->tf_eflags = eflags; - return(EJUSTRETURN); -} - -/* - * sigreturn(ucontext_t *sigcntxp) - */ int sigreturn(struct sigreturn_args *uap) { @@ -825,18 +601,6 @@ sigreturn(struct sigreturn_args *uap) ucp = uap->sigcntxp; - if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ)) - return (EFAULT); - if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516) - return (osigreturn((struct osigreturn_args *)uap)); - - /* - * Since ucp is not an osigcontext but a ucontext_t, we have to - * check again if all of it is accessible. A ucontext_t is - * much larger, so instead of just checking for the pointer - * being valid for the size of an osigcontext, now check for - * it being valid for a whole, new-style ucontext_t. - */ if (!useracc((caddr_t)ucp, sizeof(ucontext_t), VM_PROT_READ)) return (EFAULT); diff --git a/sys/i386/include/md_var.h b/sys/i386/include/md_var.h index 94f9020f10..9ab2c93bfb 100644 --- a/sys/i386/include/md_var.h +++ b/sys/i386/include/md_var.h @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/md_var.h,v 1.35.2.4 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/i386/include/Attic/md_var.h,v 1.10 2003/08/26 21:42:18 rob Exp $ + * $DragonFly: src/sys/i386/include/Attic/md_var.h,v 1.11 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_MD_VAR_H_ @@ -61,7 +61,7 @@ extern int need_post_dma_flush; extern int nfs_diskless_valid; extern void (*ovbcopy_vector) (const void *from, void *to, size_t len); extern char sigcode[]; -extern int szsigcode, szosigcode; +extern int szsigcode; typedef void alias_for_inthand_t (u_int cs, u_int ef, u_int esp, u_int ss); struct proc; diff --git a/sys/i386/include/sigframe.h b/sys/i386/include/sigframe.h index 0c47ed7bf7..d6ab62fddf 100644 --- a/sys/i386/include/sigframe.h +++ b/sys/i386/include/sigframe.h @@ -26,7 +26,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/sigframe.h,v 1.5 1999/12/04 10:40:24 marcel Exp $ - * $DragonFly: src/sys/i386/include/Attic/sigframe.h,v 1.2 2003/06/17 04:28:36 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/sigframe.h,v 1.3 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_SIGFRAME_H_ @@ -36,41 +36,6 @@ * Signal frames, arguments passed to application signal handlers. */ -struct osigframe { - /* - * The first four members may be used by applications. - */ - - register_t sf_signum; - - /* - * Either 'int' for old-style FreeBSD handler or 'siginfo_t *' - * pointing to sf_siginfo for SA_SIGINFO handlers. - */ - register_t sf_arg2; - - /* Points to sf_siginfo.si_sc. */ - register_t sf_scp; - - register_t sf_addr; - - /* - * The following arguments are not constrained by the - * function call protocol. - * Applications are not supposed to access these members, - * except using the pointers we provide in the first three - * arguments. - */ - - union { - __osiginfohandler_t *sf_action; - __sighandler_t *sf_handler; - } sf_ahu; - - /* In the SA_SIGINFO case, sf_arg2 points here. */ - osiginfo_t sf_siginfo; -}; - struct sigframe { /* * The first four members may be used by applications. diff --git a/sys/i386/include/signal.h b/sys/i386/include/signal.h index 8c915c404b..793e1749d3 100644 --- a/sys/i386/include/signal.h +++ b/sys/i386/include/signal.h @@ -32,7 +32,7 @@ * * @(#)signal.h 8.1 (Berkeley) 6/11/93 * $FreeBSD: src/sys/i386/include/signal.h,v 1.12 1999/11/12 13:52:11 marcel Exp $ - * $DragonFly: src/sys/i386/include/Attic/signal.h,v 1.4 2003/08/20 23:05:33 dillon Exp $ + * $DragonFly: src/sys/i386/include/Attic/signal.h,v 1.5 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_SIGNAL_H_ @@ -60,34 +60,7 @@ typedef int sig_atomic_t; * execution of the signal handler. It is also made available * to the handler to allow it to restore state properly if * a non-standard exit is performed. - */ -typedef unsigned int osigset_t; - -struct osigcontext { - int sc_onstack; /* sigstack state to restore */ - osigset_t sc_mask; /* signal mask to restore */ - int sc_esp; /* machine state follows: */ - int sc_ebp; - int sc_isp; - int sc_eip; - int sc_efl; - int sc_es; - int sc_ds; - int sc_cs; - int sc_ss; - int sc_edi; - int sc_esi; - int sc_ebx; - int sc_edx; - int sc_ecx; - int sc_eax; - int sc_gs; - int sc_fs; - int sc_trapno; - int sc_err; -}; - -/* + * * The sequence of the fields/registers in struct sigcontext should match * those in mcontext_t. */ diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 3be78f3195..8c1804ff50 100644 --- a/sys/kern/init_sysent.c +++ b/sys/kern/init_sysent.c @@ -2,8 +2,8 @@ * System call switch table. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/kern/init_sysent.c,v 1.8 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/kern/init_sysent.c,v 1.9 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ #include "opt_compat.h" @@ -68,13 +68,13 @@ struct sysent sysent[] = { { 0, (sy_call_t *)getegid }, /* 43 = getegid */ { AS(profil_args), (sy_call_t *)profil }, /* 44 = profil */ { AS(ktrace_args), (sy_call_t *)ktrace }, /* 45 = ktrace */ - { compat(AS(osigaction_args),sigaction) }, /* 46 = old sigaction */ + { 0, (sy_call_t *)nosys }, /* 46 = obsolete freebsd3_sigaction */ { SYF_MPSAFE | 0, (sy_call_t *)getgid }, /* 47 = getgid */ - { compat(SYF_MPSAFE | AS(osigprocmask_args),sigprocmask) }, /* 48 = old sigprocmask */ + { 0, (sy_call_t *)nosys }, /* 48 = obsolete freebsd3_sigprocmask */ { AS(getlogin_args), (sy_call_t *)getlogin }, /* 49 = getlogin */ { AS(setlogin_args), (sy_call_t *)setlogin }, /* 50 = setlogin */ { AS(acct_args), (sy_call_t *)acct }, /* 51 = acct */ - { compat(0,sigpending) }, /* 52 = old sigpending */ + { 0, (sy_call_t *)nosys }, /* 52 = obsolete freebsd3_sigpending */ { AS(sigaltstack_args), (sy_call_t *)sigaltstack }, /* 53 = sigaltstack */ { AS(ioctl_args), (sy_call_t *)ioctl }, /* 54 = ioctl */ { AS(reboot_args), (sy_call_t *)reboot }, /* 55 = reboot */ @@ -125,7 +125,7 @@ struct sysent sysent[] = { { AS(getpriority_args), (sy_call_t *)getpriority }, /* 100 = getpriority */ { compat(AS(osend_args),send) }, /* 101 = old send */ { compat(AS(orecv_args),recv) }, /* 102 = old recv */ - { compat(AS(osigreturn_args),sigreturn) }, /* 103 = old sigreturn */ + { 0, (sy_call_t *)nosys }, /* 103 = obsolete freebsd3_sigreturn */ { AS(bind_args), (sy_call_t *)bind }, /* 104 = bind */ { AS(setsockopt_args), (sy_call_t *)setsockopt }, /* 105 = setsockopt */ { AS(listen_args), (sy_call_t *)listen }, /* 106 = listen */ @@ -133,7 +133,7 @@ struct sysent sysent[] = { { compat(AS(osigvec_args),sigvec) }, /* 108 = old sigvec */ { compat(AS(osigblock_args),sigblock) }, /* 109 = old sigblock */ { compat(AS(osigsetmask_args),sigsetmask) }, /* 110 = old sigsetmask */ - { compat(AS(osigsuspend_args),sigsuspend) }, /* 111 = old sigsuspend */ + { 0, (sy_call_t *)nosys }, /* 111 = obsolete freebsd3_sigsuspend */ { compat(AS(osigstack_args),sigstack) }, /* 112 = old sigstack */ { compat(AS(orecvmsg_args),recvmsg) }, /* 113 = old recvmsg */ { compat(AS(osendmsg_args),sendmsg) }, /* 114 = old sendmsg */ diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c index b91d1a8ae2..2d1c26ef5d 100644 --- a/sys/kern/kern_sig.c +++ b/sys/kern/kern_sig.c @@ -37,10 +37,9 @@ * * @(#)kern_sig.c 8.7 (Berkeley) 4/18/94 * $FreeBSD: src/sys/kern/kern_sig.c,v 1.72.2.17 2003/05/16 16:34:34 obrien Exp $ - * $DragonFly: src/sys/kern/kern_sig.c,v 1.22 2003/10/13 21:16:42 dillon Exp $ + * $DragonFly: src/sys/kern/kern_sig.c,v 1.23 2003/10/24 14:10:46 daver Exp $ */ -#include "opt_compat.h" #include "opt_ktrace.h" #include @@ -65,21 +64,16 @@ #include #include #include +#include #include #include #include -#define ONSIG 32 /* NSIG for osig* syscalls. XXX. */ - static int coredump (struct proc *); -static int do_sigaction (int sig, struct sigaction *act, - struct sigaction *oact, int old); -static int do_sigprocmask (int how, sigset_t *set, - sigset_t *oset, int old); static char *expand_name (const char *, uid_t, pid_t); -static int killpg1 (int sig, int pgid, int all); +static int killpg (int sig, int pgid, int all); static int sig_ffs (sigset_t *set); static int sigprop (int sig); static void stop (struct proc *); @@ -227,15 +221,11 @@ sig_ffs(sigset_t *set) return (0); } -/* - * do_sigaction - * sigaction - * osigaction - */ -static int -do_sigaction(int sig, struct sigaction *act, struct sigaction *oact, int old) +int +kern_sigaction(int sig, struct sigaction *act, struct sigaction *oact) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct sigacts *ps = p->p_sigacts; if (sig <= 0 || sig > _SIG_MAXSIG) @@ -296,12 +286,6 @@ do_sigaction(int sig, struct sigaction *act, struct sigaction *oact, int old) SIGADDSET(ps->ps_signodefer, sig); else SIGDELSET(ps->ps_signodefer, sig); -#ifdef COMPAT_SUNOS - if (act->sa_flags & SA_USERTRAMP) - SIGADDSET(ps->ps_usertramp, sig); - else - SIGDELSET(ps->ps_usertramp, seg); -#endif if (sig == SIGCHLD) { if (act->sa_flags & SA_NOCLDSTOP) p->p_procsig->ps_flag |= PS_NOCLDSTOP; @@ -343,18 +327,12 @@ do_sigaction(int sig, struct sigaction *act, struct sigaction *oact, int old) else SIGADDSET(p->p_sigcatch, sig); } - if (ps->ps_sigact[_SIG_IDX(sig)] == SIG_IGN || - ps->ps_sigact[_SIG_IDX(sig)] == SIG_DFL || !old) - SIGDELSET(ps->ps_osigset, sig); - else - SIGADDSET(ps->ps_osigset, sig); (void) spl0(); } return (0); } -/* ARGSUSED */ int sigaction(struct sigaction_args *uap) { @@ -369,44 +347,13 @@ sigaction(struct sigaction_args *uap) if (error) return (error); } - error = do_sigaction(uap->sig, actp, oactp, 0); + error = kern_sigaction(uap->sig, actp, oactp); if (oactp && !error) { error = copyout(oactp, uap->oact, sizeof(oact)); } return (error); } -/* ARGSUSED */ -int -osigaction(struct osigaction_args *uap) -{ - struct osigaction sa; - struct sigaction nsa, osa; - struct sigaction *nsap, *osap; - int error; - - if (uap->signum <= 0 || uap->signum >= ONSIG) - return (EINVAL); - nsap = (uap->nsa != NULL) ? &nsa : NULL; - osap = (uap->osa != NULL) ? &osa : NULL; - if (nsap) { - error = copyin(uap->nsa, &sa, sizeof(sa)); - if (error) - return (error); - nsap->sa_handler = sa.sa_handler; - nsap->sa_flags = sa.sa_flags; - OSIG2SIG(sa.sa_mask, nsap->sa_mask); - } - error = do_sigaction(uap->signum, nsap, osap, 1); - if (osap && !error) { - sa.sa_handler = osap->sa_handler; - sa.sa_flags = osap->sa_flags; - SIG2OSIG(osap->sa_mask, sa.sa_mask); - error = copyout(&sa, uap->osa, sizeof(sa)); - } - return (error); -} - /* * Initialize signal state for process 0; * set to ignore signals that are ignored by default. @@ -462,16 +409,17 @@ execsigs(p) } /* - * do_sigprocmask() - MP SAFE ONLY IF p == curproc + * kern_sigprocmask() - MP SAFE ONLY IF p == curproc * * Manipulate signal mask. This routine is MP SAFE *ONLY* if * p == curproc. Also remember that in order to remain MP SAFE * no spl*() calls may be made. */ -static int -do_sigprocmask(int how, sigset_t *set, sigset_t *oset, int old) +int +kern_sigprocmask(int how, sigset_t *set, sigset_t *oset) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; int error; if (oset != NULL) @@ -489,10 +437,7 @@ do_sigprocmask(int how, sigset_t *set, sigset_t *oset, int old) break; case SIG_SETMASK: SIG_CANTMASK(*set); - if (old) - SIGSETLO(p->p_sigmask, *set); - else - p->p_sigmask = *set; + p->p_sigmask = *set; break; default: error = EINVAL; @@ -519,139 +464,47 @@ sigprocmask(struct sigprocmask_args *uap) if (error) return (error); } - error = do_sigprocmask(uap->how, setp, osetp, 0); + error = kern_sigprocmask(uap->how, setp, osetp); if (osetp && !error) { error = copyout(osetp, uap->oset, sizeof(oset)); } return (error); } -/* - * osigprocmask() - MP SAFE - */ -int -osigprocmask(struct osigprocmask_args *uap) -{ - sigset_t set, oset; - int error; - - OSIG2SIG(uap->mask, set); - error = do_sigprocmask(uap->how, &set, &oset, 1); - SIG2OSIG(oset, uap->sysmsg_result); - return (error); -} - -/* ARGSUSED */ int -sigpending(struct sigpending_args *uap) +kern_sigpending(struct __sigset *set) { - struct proc *p = curproc; + struct thread *td = curthread; + struct proc *p = td->td_proc; - return (copyout(&p->p_siglist, uap->set, sizeof(sigset_t))); -} - -/* ARGSUSED */ -int -osigpending(struct osigpending_args *uap) -{ - struct proc *p = curproc; + *set = p->p_siglist; - SIG2OSIG(p->p_siglist, uap->sysmsg_result); return (0); } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) -/* - * Generalized interface signal handler, 4.3-compatible. - */ -/* ARGSUSED */ -int -osigvec(struct osigvec_args *uap) -{ - struct sigvec vec; - struct sigaction nsa, osa; - struct sigaction *nsap, *osap; - int error; - - if (uap->signum <= 0 || uap->signum >= ONSIG) - return (EINVAL); - nsap = (uap->nsv != NULL) ? &nsa : NULL; - osap = (uap->osv != NULL) ? &osa : NULL; - if (nsap) { - error = copyin(uap->nsv, &vec, sizeof(vec)); - if (error) - return (error); - nsap->sa_handler = vec.sv_handler; - OSIG2SIG(vec.sv_mask, nsap->sa_mask); - nsap->sa_flags = vec.sv_flags; - nsap->sa_flags ^= SA_RESTART; /* opposite of SV_INTERRUPT */ -#ifdef COMPAT_SUNOS - nsap->sa_flags |= SA_USERTRAMP; -#endif - } - error = do_sigaction(uap->signum, nsap, osap, 1); - if (osap && !error) { - vec.sv_handler = osap->sa_handler; - SIG2OSIG(osap->sa_mask, vec.sv_mask); - vec.sv_flags = osap->sa_flags; - vec.sv_flags &= ~SA_NOCLDWAIT; - vec.sv_flags ^= SA_RESTART; -#ifdef COMPAT_SUNOS - vec.sv_flags &= ~SA_NOCLDSTOP; -#endif - error = copyout(&vec, uap->osv, sizeof(vec)); - } - return (error); -} - int -osigblock(struct osigblock_args *uap) +sigpending(struct sigpending_args *uap) { - struct proc *p = curproc; sigset_t set; + int error; - OSIG2SIG(uap->mask, set); - SIG_CANTMASK(set); - (void) splhigh(); - SIG2OSIG(p->p_sigmask, uap->sysmsg_result); - SIGSETOR(p->p_sigmask, set); - (void) spl0(); - return (0); -} + error = kern_sigpending(&set); -int -osigsetmask(struct osigsetmask_args *uap) -{ - struct proc *p = curproc; - sigset_t set; - - OSIG2SIG(uap->mask, set); - SIG_CANTMASK(set); - (void) splhigh(); - SIG2OSIG(p->p_sigmask, uap->sysmsg_result); - SIGSETLO(p->p_sigmask, set); - (void) spl0(); - return (0); + if (error == 0) + error = copyout(&set, uap->set, sizeof(set)); + return (error); } -#endif /* COMPAT_43 || COMPAT_SUNOS */ /* * Suspend process until signal, providing mask to be set - * in the meantime. Note nonstandard calling convention: - * libc stub passes mask, not pointer, to save a copyin. + * in the meantime. */ -/* ARGSUSED */ int -sigsuspend(struct sigsuspend_args *uap) +kern_sigsuspend(struct __sigset *set) { - struct proc *p = curproc; - sigset_t mask; + struct thread *td = curthread; + struct proc *p = td->td_proc; struct sigacts *ps = p->p_sigacts; - int error; - - error = copyin(uap->sigmask, &mask, sizeof(mask)); - if (error) - return (error); /* * When returning from sigsuspend, we want @@ -663,94 +516,88 @@ sigsuspend(struct sigsuspend_args *uap) p->p_oldsigmask = p->p_sigmask; p->p_flag |= P_OLDMASK; - SIG_CANTMASK(mask); - p->p_sigmask = mask; - while (tsleep((caddr_t) ps, PCATCH, "pause", 0) == 0) + SIG_CANTMASK(*set); + p->p_sigmask = *set; + while (tsleep(ps, PCATCH, "pause", 0) == 0) /* void */; /* always return EINTR rather than ERESTART... */ return (EINTR); } -/* ARGSUSED */ +/* + * Note nonstandard calling convention: libc stub passes mask, not + * pointer, to save a copyin. + */ int -osigsuspend(struct osigsuspend_args *uap) +sigsuspend(struct sigsuspend_args *uap) { sigset_t mask; - struct proc *p = curproc; - struct sigacts *ps = p->p_sigacts; + int error; - p->p_oldsigmask = p->p_sigmask; - p->p_flag |= P_OLDMASK; - OSIG2SIG(uap->mask, mask); - SIG_CANTMASK(mask); - SIGSETLO(p->p_sigmask, mask); - while (tsleep((caddr_t) ps, PCATCH, "opause", 0) == 0) - /* void */; - /* always return EINTR rather than ERESTART... */ - return (EINTR); + error = copyin(uap->sigmask, &mask, sizeof(mask)); + if (error) + return (error); + + error = kern_sigsuspend(&mask); + + return (error); } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) -/* ARGSUSED */ int -osigstack(struct osigstack_args *uap) +kern_sigaltstack(struct sigaltstack *ss, struct sigaltstack *oss) { - struct proc *p = curproc; - struct sigstack ss; - int error = 0; + struct thread *td = curthread; + struct proc *p = td->td_proc; - ss.ss_sp = p->p_sigstk.ss_sp; - ss.ss_onstack = p->p_sigstk.ss_flags & SS_ONSTACK; - if (uap->oss && (error = copyout(&ss, uap->oss, - sizeof(struct sigstack)))) - return (error); - if (uap->nss && (error = copyin(uap->nss, &ss, sizeof(ss))) == 0) { - p->p_sigstk.ss_sp = ss.ss_sp; - p->p_sigstk.ss_size = 0; - p->p_sigstk.ss_flags |= ss.ss_onstack & SS_ONSTACK; - p->p_flag |= P_ALTSTACK; + if ((p->p_flag & P_ALTSTACK) == 0) + p->p_sigstk.ss_flags |= SS_DISABLE; + + if (oss) + *oss = p->p_sigstk; + + if (ss) { + if (ss->ss_flags & SS_DISABLE) { + if (p->p_sigstk.ss_flags & SS_ONSTACK) + return (EINVAL); + p->p_flag &= ~P_ALTSTACK; + p->p_sigstk.ss_flags = ss->ss_flags; + } else { + if (ss->ss_size < p->p_sysent->sv_minsigstksz) + return (ENOMEM); + p->p_flag |= P_ALTSTACK; + p->p_sigstk = *ss; + } } - return (error); + + return (0); } -#endif /* COMPAT_43 || COMPAT_SUNOS */ -/* ARGSUSED */ int sigaltstack(struct sigaltstack_args *uap) { - struct proc *p = curproc; - stack_t ss; + stack_t ss, oss; int error; - if ((p->p_flag & P_ALTSTACK) == 0) - p->p_sigstk.ss_flags |= SS_DISABLE; - if (uap->oss && (error = copyout(&p->p_sigstk, uap->oss, - sizeof(stack_t)))) - return (error); - if (uap->ss == 0) - return (0); - if ((error = copyin(uap->ss, &ss, sizeof(ss)))) - return (error); - if (ss.ss_flags & SS_DISABLE) { - if (p->p_sigstk.ss_flags & SS_ONSTACK) - return (EINVAL); - p->p_flag &= ~P_ALTSTACK; - p->p_sigstk.ss_flags = ss.ss_flags; - return (0); + if (uap->ss) { + error = copyin(uap->ss, &ss, sizeof(ss)); + if (error) + return (error); } - if (ss.ss_size < p->p_sysent->sv_minsigstksz) - return (ENOMEM); - p->p_flag |= P_ALTSTACK; - p->p_sigstk = ss; - return (0); + + error = kern_sigaltstack(uap->ss ? &ss : NULL, + uap->oss ? &oss : NULL); + + if (error == 0 && uap->oss) + error = copyout(&oss, uap->oss, sizeof(*uap->oss)); + return (error); } /* * Common code for kill process group/broadcast kill. * cp is calling process. */ -int -killpg1(int sig, int pgid, int all) +static int +killpg(int sig, int pgid, int all) { struct proc *cp = curproc; struct proc *p; @@ -793,45 +640,44 @@ killpg1(int sig, int pgid, int all) return (nfound ? 0 : ESRCH); } -/* ARGSUSED */ int -kill(struct kill_args *uap) +kern_kill(int sig, int pid) { - struct proc *p; + struct thread *td = curthread; + struct proc *p = td->td_proc; - if ((u_int)uap->signum > _SIG_MAXSIG) + if ((u_int)sig > _SIG_MAXSIG) return (EINVAL); - if (uap->pid > 0) { + if (pid > 0) { /* kill single process */ - if ((p = pfind(uap->pid)) == NULL) + if ((p = pfind(pid)) == NULL) return (ESRCH); - if (!CANSIGNAL(p, uap->signum)) + if (!CANSIGNAL(p, sig)) return (EPERM); - if (uap->signum) - psignal(p, uap->signum); + if (sig) + psignal(p, sig); return (0); } - switch (uap->pid) { + switch (pid) { case -1: /* broadcast signal */ - return (killpg1(uap->signum, 0, 1)); + return (killpg(sig, 0, 1)); case 0: /* signal own process group */ - return (killpg1(uap->signum, 0, 0)); + return (killpg(sig, 0, 0)); default: /* negative explicit process group */ - return (killpg1(uap->signum, -uap->pid, 0)); + return (killpg(sig, -pid, 0)); } /* NOTREACHED */ } -#if defined(COMPAT_43) || defined(COMPAT_SUNOS) -/* ARGSUSED */ int -okillpg(struct okillpg_args *uap) +kill(struct kill_args *uap) { - if ((u_int)uap->signum > _SIG_MAXSIG) - return (EINVAL); - return (killpg1(uap->signum, uap->pgid, 0)); + int error; + + error = kern_kill(uap->signum, uap->pid); + + return (error); } -#endif /* COMPAT_43 || COMPAT_SUNOS */ /* * Send a signal to a process group. @@ -890,7 +736,7 @@ trapsignal(p, sig, code) SIGADDSET(p->p_sigmask, sig); if (SIGISMEMBER(ps->ps_sigreset, sig)) { /* - * See do_sigaction() for origin of this code. + * See kern_sigaction() for origin of this code. */ SIGDELSET(p->p_sigcatch, sig); if (sig != SIGCONT && @@ -1403,7 +1249,7 @@ postsig(sig) if (SIGISMEMBER(ps->ps_sigreset, sig)) { /* - * See do_sigaction() for origin of this code. + * See kern_sigaction() for origin of this code. */ SIGDELSET(p->p_sigcatch, sig); if (sig != SIGCONT && diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 3cccce9c7e..1906874eee 100644 --- a/sys/kern/syscalls.c +++ b/sys/kern/syscalls.c @@ -2,8 +2,8 @@ * System call names. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/kern/syscalls.c,v 1.8 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/kern/syscalls.c,v 1.9 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ char *syscallnames[] = { @@ -53,13 +53,13 @@ char *syscallnames[] = { "getegid", /* 43 = getegid */ "profil", /* 44 = profil */ "ktrace", /* 45 = ktrace */ - "old.sigaction", /* 46 = old sigaction */ + "obs_freebsd3_sigaction", /* 46 = obsolete freebsd3_sigaction */ "getgid", /* 47 = getgid */ - "old.sigprocmask", /* 48 = old sigprocmask */ + "obs_freebsd3_sigprocmask", /* 48 = obsolete freebsd3_sigprocmask */ "getlogin", /* 49 = getlogin */ "setlogin", /* 50 = setlogin */ "acct", /* 51 = acct */ - "old.sigpending", /* 52 = old sigpending */ + "obs_freebsd3_sigpending", /* 52 = obsolete freebsd3_sigpending */ "sigaltstack", /* 53 = sigaltstack */ "ioctl", /* 54 = ioctl */ "reboot", /* 55 = reboot */ @@ -110,7 +110,7 @@ char *syscallnames[] = { "getpriority", /* 100 = getpriority */ "old.send", /* 101 = old send */ "old.recv", /* 102 = old recv */ - "old.sigreturn", /* 103 = old sigreturn */ + "obs_freebsd3_sigreturn", /* 103 = obsolete freebsd3_sigreturn */ "bind", /* 104 = bind */ "setsockopt", /* 105 = setsockopt */ "listen", /* 106 = listen */ @@ -118,7 +118,7 @@ char *syscallnames[] = { "old.sigvec", /* 108 = old sigvec */ "old.sigblock", /* 109 = old sigblock */ "old.sigsetmask", /* 110 = old sigsetmask */ - "old.sigsuspend", /* 111 = old sigsuspend */ + "obs_freebsd3_sigsuspend", /* 111 = obsolete freebsd3_sigsuspend */ "old.sigstack", /* 112 = old sigstack */ "old.recvmsg", /* 113 = old recvmsg */ "old.sendmsg", /* 114 = old sendmsg */ diff --git a/sys/kern/syscalls.master b/sys/kern/syscalls.master index cb5a93c0fb..e2e2613768 100644 --- a/sys/kern/syscalls.master +++ b/sys/kern/syscalls.master @@ -1,4 +1,4 @@ - $DragonFly: src/sys/kern/syscalls.master,v 1.5 2003/10/23 00:04:58 daver Exp $ + $DragonFly: src/sys/kern/syscalls.master,v 1.6 2003/10/24 14:10:46 daver Exp $ ; @(#)syscalls.master 8.2 (Berkeley) 1/13/94 ; $FreeBSD: src/sys/kern/syscalls.master,v 1.72.2.10 2002/07/12 08:22:46 alfred Exp $ @@ -96,17 +96,16 @@ size_t offset, u_int scale); } 45 STD BSD { int ktrace(const char *fname, int ops, int facs, \ int pid); } -46 COMPAT POSIX { int sigaction(int signum, struct osigaction *nsa, \ - struct osigaction *osa); } +46 OBSOL NOHIDE freebsd3_sigaction 47 MPSAFE STD POSIX { gid_t getgid(void); } -48 MPSAFE COMPAT POSIX { int sigprocmask(int how, osigset_t mask); } +48 OBSOL NOHIDE freebsd3_sigprocmask ; XXX note nonstandard (bogus) calling convention - the libc stub passes ; us the mask, not a pointer to it, and we return the old mask as the ; (int) return value. 49 STD BSD { int getlogin(char *namebuf, u_int namelen); } 50 STD BSD { int setlogin(char *namebuf); } 51 STD BSD { int acct(char *path); } -52 COMPAT POSIX { int sigpending(void); } +52 OBSOL NOHIDE freebsd3_sigpending 53 STD BSD { int sigaltstack(stack_t *ss, stack_t *oss); } 54 STD POSIX { int ioctl(int fd, u_long com, caddr_t data); } 55 STD BSD { int reboot(int opt); } @@ -169,7 +168,7 @@ 100 STD BSD { int getpriority(int which, int who); } 101 COMPAT BSD { int send(int s, caddr_t buf, int len, int flags); } 102 COMPAT BSD { int recv(int s, caddr_t buf, int len, int flags); } -103 COMPAT BSD { int sigreturn(struct osigcontext *sigcntxp); } +103 OBSOL NOHIDE freebsd3_sigreturn 104 STD BSD { int bind(int s, caddr_t name, int namelen); } 105 STD BSD { int setsockopt(int s, int level, int name, \ caddr_t val, int valsize); } @@ -179,7 +178,7 @@ struct sigvec *osv); } 109 COMPAT BSD { int sigblock(int mask); } 110 COMPAT BSD { int sigsetmask(int mask); } -111 COMPAT POSIX { int sigsuspend(osigset_t mask); } +111 OBSOL NOHIDE freebsd3_sigsuspend ; XXX note nonstandard (bogus) calling convention - the libc stub passes ; us the mask, not a pointer to it. 112 COMPAT BSD { int sigstack(struct sigstack *nss, \ diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index d4bf1a77ec..666db5fe0a 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.30 2003/10/02 22:26:56 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.31 2003/10/24 14:10:45 daver Exp $ */ #include "opt_user_ldt.h" @@ -163,12 +163,7 @@ ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); -ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); -ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); -ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); -ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); -ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(B_READ, B_READ); diff --git a/sys/platform/pc32/i386/locore.s b/sys/platform/pc32/i386/locore.s index 489f29d5c7..24c7045577 100644 --- a/sys/platform/pc32/i386/locore.s +++ b/sys/platform/pc32/i386/locore.s @@ -35,7 +35,7 @@ * * from: @(#)locore.s 7.3 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/locore.s,v 1.132.2.10 2003/02/03 20:54:49 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.7 2003/07/31 19:56:59 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/locore.s,v 1.8 2003/10/24 14:10:45 daver Exp $ * * originally from: locore.s, by William F. Jolitz * @@ -394,30 +394,13 @@ NON_GPROF_ENTRY(sigcode) int $0x80 /* enter kernel with args */ 0: jmp 0b - ALIGN_TEXT -osigcode: - call *SIGF_HANDLER(%esp) /* call signal handler */ - lea SIGF_SC(%esp),%eax /* get sigcontext */ - pushl %eax - testl $PSL_VM,SC_PS(%eax) - jne 9f - movl SC_GS(%eax),%gs /* restore %gs */ -9: - movl $0x01d516,SC_TRAPNO(%eax) /* magic: 0ldSiG */ - movl $SYS_sigreturn,%eax - pushl %eax /* junk to fake return addr. */ - int $0x80 /* enter kernel with args */ -0: jmp 0b - ALIGN_TEXT esigcode: .data - .globl szsigcode, szosigcode + .globl szsigcode szsigcode: .long esigcode - sigcode -szosigcode: - .long esigcode - osigcode .text /********************************************************************** diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 17efab2125..2eb401c7ed 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.38 2003/10/19 00:23:21 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.39 2003/10/24 14:10:45 daver Exp $ */ #include "use_apm.h" @@ -466,119 +466,6 @@ again: * frame pointer, it returns to the user * specified pc, psl. */ -static void -osendsig(sig_t catcher, int sig, sigset_t *mask, u_long code) -{ - struct proc *p = curproc; - struct trapframe *regs; - struct osigframe *fp; - struct osigframe sf; - struct sigacts *psp = p->p_sigacts; - int oonstack; - - regs = p->p_md.md_regs; - oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0; - - /* Allocate and validate space for the signal handler context. */ - if ((p->p_flag & P_ALTSTACK) && !oonstack && - SIGISMEMBER(psp->ps_sigonstack, sig)) { - fp = (struct osigframe *)(p->p_sigstk.ss_sp + - p->p_sigstk.ss_size - sizeof(struct osigframe)); - p->p_sigstk.ss_flags |= SS_ONSTACK; - } - else - fp = (struct osigframe *)regs->tf_esp - 1; - - /* Translate the signal if appropriate */ - if (p->p_sysent->sv_sigtbl) { - if (sig <= p->p_sysent->sv_sigsize) - sig = p->p_sysent->sv_sigtbl[_SIG_IDX(sig)]; - } - - /* Build the argument list for the signal handler. */ - sf.sf_signum = sig; - sf.sf_scp = (register_t)&fp->sf_siginfo.si_sc; - if (SIGISMEMBER(p->p_sigacts->ps_siginfo, sig)) { - /* Signal handler installed with SA_SIGINFO. */ - sf.sf_arg2 = (register_t)&fp->sf_siginfo; - sf.sf_siginfo.si_signo = sig; - sf.sf_siginfo.si_code = code; - sf.sf_ahu.sf_action = (__osiginfohandler_t *)catcher; - } - else { - /* Old FreeBSD-style arguments. */ - sf.sf_arg2 = code; - sf.sf_addr = regs->tf_err; - sf.sf_ahu.sf_handler = catcher; - } - - /* save scratch registers */ - sf.sf_siginfo.si_sc.sc_eax = regs->tf_eax; - sf.sf_siginfo.si_sc.sc_ebx = regs->tf_ebx; - sf.sf_siginfo.si_sc.sc_ecx = regs->tf_ecx; - sf.sf_siginfo.si_sc.sc_edx = regs->tf_edx; - sf.sf_siginfo.si_sc.sc_esi = regs->tf_esi; - sf.sf_siginfo.si_sc.sc_edi = regs->tf_edi; - sf.sf_siginfo.si_sc.sc_cs = regs->tf_cs; - sf.sf_siginfo.si_sc.sc_ds = regs->tf_ds; - sf.sf_siginfo.si_sc.sc_ss = regs->tf_ss; - sf.sf_siginfo.si_sc.sc_es = regs->tf_es; - sf.sf_siginfo.si_sc.sc_fs = regs->tf_fs; - sf.sf_siginfo.si_sc.sc_gs = rgs(); - sf.sf_siginfo.si_sc.sc_isp = regs->tf_isp; - - /* Build the signal context to be used by sigreturn. */ - sf.sf_siginfo.si_sc.sc_onstack = oonstack; - SIG2OSIG(*mask, sf.sf_siginfo.si_sc.sc_mask); - sf.sf_siginfo.si_sc.sc_sp = regs->tf_esp; - sf.sf_siginfo.si_sc.sc_fp = regs->tf_ebp; - sf.sf_siginfo.si_sc.sc_pc = regs->tf_eip; - sf.sf_siginfo.si_sc.sc_ps = regs->tf_eflags; - sf.sf_siginfo.si_sc.sc_trapno = regs->tf_trapno; - sf.sf_siginfo.si_sc.sc_err = regs->tf_err; - - /* - * If we're a vm86 process, we want to save the segment registers. - * We also change eflags to be our emulated eflags, not the actual - * eflags. - */ - if (regs->tf_eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; - - sf.sf_siginfo.si_sc.sc_gs = tf->tf_vm86_gs; - sf.sf_siginfo.si_sc.sc_fs = tf->tf_vm86_fs; - sf.sf_siginfo.si_sc.sc_es = tf->tf_vm86_es; - sf.sf_siginfo.si_sc.sc_ds = tf->tf_vm86_ds; - - if (vm86->vm86_has_vme == 0) - sf.sf_siginfo.si_sc.sc_ps = - (tf->tf_eflags & ~(PSL_VIF | PSL_VIP)) - | (vm86->vm86_eflags & (PSL_VIF | PSL_VIP)); - /* see sendsig for comment */ - tf->tf_eflags &= ~(PSL_VM | PSL_NT | PSL_VIF | PSL_VIP); - } - - /* Copy the sigframe out to the user's stack. */ - if (copyout(&sf, fp, sizeof(struct osigframe)) != 0) { - /* - * Something is wrong with the stack pointer. - * ...Kill the process. - */ - sigexit(p, SIGILL); - } - - regs->tf_esp = (int)fp; - regs->tf_eip = PS_STRINGS - szosigcode; - regs->tf_eflags &= ~PSL_T; - regs->tf_cs = _ucodesel; - regs->tf_ds = _udatasel; - regs->tf_es = _udatasel; - regs->tf_fs = _udatasel; - load_gs(_udatasel); - regs->tf_ss = _udatasel; -} - void sendsig(catcher, sig, mask, code) sig_t catcher; @@ -592,11 +479,6 @@ sendsig(catcher, sig, mask, code) struct sigframe sf, *sfp; int oonstack; - if (SIGISMEMBER(psp->ps_osigset, sig)) { - osendsig(catcher, sig, mask, code); - return; - } - regs = p->p_md.md_regs; oonstack = (p->p_sigstk.ss_flags & SS_ONSTACK) ? 1 : 0; @@ -696,7 +578,7 @@ sendsig(catcher, sig, mask, code) } /* - * osigreturn_args(struct osigcontext *sigcntxp) + * sigreturn(ucontext_t *sigcntxp) * * System call to cleanup state after a signal * has been taken. Reset signal mask and @@ -709,112 +591,6 @@ sendsig(catcher, sig, mask, code) #define EFL_SECURE(ef, oef) ((((ef) ^ (oef)) & ~PSL_USERCHANGE) == 0) #define CS_SECURE(cs) (ISPL(cs) == SEL_UPL) -int -osigreturn(struct osigreturn_args *uap) -{ - struct proc *p = curproc; - struct osigcontext *scp; - struct trapframe *regs = p->p_md.md_regs; - int eflags; - - scp = uap->sigcntxp; - - if (!useracc((caddr_t)scp, sizeof (struct osigcontext), VM_PROT_READ)) - return(EFAULT); - - eflags = scp->sc_ps; - if (eflags & PSL_VM) { - struct trapframe_vm86 *tf = (struct trapframe_vm86 *)regs; - struct vm86_kernel *vm86; - - /* - * if pcb_ext == 0 or vm86_inited == 0, the user hasn't - * set up the vm86 area, and we can't enter vm86 mode. - */ - if (p->p_thread->td_pcb->pcb_ext == 0) - return (EINVAL); - vm86 = &p->p_thread->td_pcb->pcb_ext->ext_vm86; - if (vm86->vm86_inited == 0) - return (EINVAL); - - /* go back to user mode if both flags are set */ - if ((eflags & PSL_VIP) && (eflags & PSL_VIF)) - trapsignal(p, SIGBUS, 0); - - if (vm86->vm86_has_vme) { - eflags = (tf->tf_eflags & ~VME_USERCHANGE) | - (eflags & VME_USERCHANGE) | PSL_VM; - } else { - vm86->vm86_eflags = eflags; /* save VIF, VIP */ - eflags = (tf->tf_eflags & ~VM_USERCHANGE) | (eflags & VM_USERCHANGE) | PSL_VM; - } - tf->tf_vm86_ds = scp->sc_ds; - tf->tf_vm86_es = scp->sc_es; - tf->tf_vm86_fs = scp->sc_fs; - tf->tf_vm86_gs = scp->sc_gs; - tf->tf_ds = _udatasel; - tf->tf_es = _udatasel; - tf->tf_fs = _udatasel; - } else { - /* - * Don't allow users to change privileged or reserved flags. - */ - /* - * XXX do allow users to change the privileged flag PSL_RF. - * The cpu sets PSL_RF in tf_eflags for faults. Debuggers - * should sometimes set it there too. tf_eflags is kept in - * the signal context during signal handling and there is no - * other place to remember it, so the PSL_RF bit may be - * corrupted by the signal handler without us knowing. - * Corruption of the PSL_RF bit at worst causes one more or - * one less debugger trap, so allowing it is fairly harmless. - */ - if (!EFL_SECURE(eflags & ~PSL_RF, regs->tf_eflags & ~PSL_RF)) { - return(EINVAL); - } - - /* - * Don't allow users to load a valid privileged %cs. Let the - * hardware check for invalid selectors, excess privilege in - * other selectors, invalid %eip's and invalid %esp's. - */ - if (!CS_SECURE(scp->sc_cs)) { - trapsignal(p, SIGBUS, T_PROTFLT); - return(EINVAL); - } - regs->tf_ds = scp->sc_ds; - regs->tf_es = scp->sc_es; - regs->tf_fs = scp->sc_fs; - } - - /* restore scratch registers */ - regs->tf_eax = scp->sc_eax; - regs->tf_ebx = scp->sc_ebx; - regs->tf_ecx = scp->sc_ecx; - regs->tf_edx = scp->sc_edx; - regs->tf_esi = scp->sc_esi; - regs->tf_edi = scp->sc_edi; - regs->tf_cs = scp->sc_cs; - regs->tf_ss = scp->sc_ss; - regs->tf_isp = scp->sc_isp; - - if (scp->sc_onstack & 01) - p->p_sigstk.ss_flags |= SS_ONSTACK; - else - p->p_sigstk.ss_flags &= ~SS_ONSTACK; - - SIGSETOLD(p->p_sigmask, scp->sc_mask); - SIG_CANTMASK(p->p_sigmask); - regs->tf_ebp = scp->sc_fp; - regs->tf_esp = scp->sc_sp; - regs->tf_eip = scp->sc_pc; - regs->tf_eflags = eflags; - return(EJUSTRETURN); -} - -/* - * sigreturn(ucontext_t *sigcntxp) - */ int sigreturn(struct sigreturn_args *uap) { @@ -825,18 +601,6 @@ sigreturn(struct sigreturn_args *uap) ucp = uap->sigcntxp; - if (!useracc((caddr_t)ucp, sizeof(struct osigcontext), VM_PROT_READ)) - return (EFAULT); - if (((struct osigcontext *)ucp)->sc_trapno == 0x01d516) - return (osigreturn((struct osigreturn_args *)uap)); - - /* - * Since ucp is not an osigcontext but a ucontext_t, we have to - * check again if all of it is accessible. A ucontext_t is - * much larger, so instead of just checking for the pointer - * being valid for the size of an osigcontext, now check for - * it being valid for a whole, new-style ucontext_t. - */ if (!useracc((caddr_t)ucp, sizeof(ucontext_t), VM_PROT_READ)) return (EFAULT); diff --git a/sys/platform/pc32/include/md_var.h b/sys/platform/pc32/include/md_var.h index 3449fb941c..9164249423 100644 --- a/sys/platform/pc32/include/md_var.h +++ b/sys/platform/pc32/include/md_var.h @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/include/md_var.h,v 1.35.2.4 2003/01/22 20:14:53 jhb Exp $ - * $DragonFly: src/sys/platform/pc32/include/md_var.h,v 1.10 2003/08/26 21:42:18 rob Exp $ + * $DragonFly: src/sys/platform/pc32/include/md_var.h,v 1.11 2003/10/24 14:10:45 daver Exp $ */ #ifndef _MACHINE_MD_VAR_H_ @@ -61,7 +61,7 @@ extern int need_post_dma_flush; extern int nfs_diskless_valid; extern void (*ovbcopy_vector) (const void *from, void *to, size_t len); extern char sigcode[]; -extern int szsigcode, szosigcode; +extern int szsigcode; typedef void alias_for_inthand_t (u_int cs, u_int ef, u_int esp, u_int ss); struct proc; diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 991e040e55..869d015978 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.30 2003/10/02 22:26:56 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.31 2003/10/24 14:10:45 daver Exp $ */ #include "opt_user_ldt.h" @@ -163,12 +163,7 @@ ASSYM(TF_ERR, offsetof(struct trapframe, tf_err)); ASSYM(TF_CS, offsetof(struct trapframe, tf_cs)); ASSYM(TF_EFLAGS, offsetof(struct trapframe, tf_eflags)); ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); -ASSYM(SIGF_SC, offsetof(struct osigframe, sf_siginfo.si_sc)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); -ASSYM(SC_PS, offsetof(struct osigcontext, sc_ps)); -ASSYM(SC_FS, offsetof(struct osigcontext, sc_fs)); -ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); -ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(B_READ, B_READ); diff --git a/sys/sys/kern_syscall.h b/sys/sys/kern_syscall.h index 641cfced3f..3e95476258 100644 --- a/sys/sys/kern_syscall.h +++ b/sys/sys/kern_syscall.h @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/sys/kern_syscall.h,v 1.8 2003/10/21 01:05:09 daver Exp $ + * $DragonFly: src/sys/sys/kern_syscall.h,v 1.9 2003/10/24 14:10:46 daver Exp $ */ #ifndef _SYS_KERN_SYSCALL_H_ @@ -35,10 +35,14 @@ enum dup_type {DUP_FIXED, DUP_VARIABLE}; union fcntl_dat; struct mbuf; struct msghdr; +struct sigaction; +struct sigaltstack; +struct __sigset; struct sf_hdtr; struct sockaddr; struct socket; struct sockopt; +struct stat; struct uio; struct vnode; @@ -49,6 +53,16 @@ int kern_dup(enum dup_type type, int old, int new, int *res); int kern_fcntl(int fd, int cmd, union fcntl_dat *dat); int kern_fstat(int fd, struct stat *st); +/* + * Prototypes for syscalls in kern/kern_sig.c + */ +int kern_sigaction(int sig, struct sigaction *act, struct sigaction *oact); +int kern_sigprocmask(int how, struct __sigset *set, struct __sigset *oset); +int kern_sigpending(struct __sigset *set); +int kern_sigsuspend(struct __sigset *mask); +int kern_sigaltstack(struct sigaltstack *ss, struct sigaltstack *oss); +int kern_kill(int sig, int id); + /* * Prototypes for syscalls in kern/sys_generic.c */ diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 401ee166a9..29e2595391 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -32,7 +32,7 @@ * * @(#)signalvar.h 8.6 (Berkeley) 2/19/95 * $FreeBSD: src/sys/sys/signalvar.h,v 1.34.2.1 2000/05/16 06:58:05 dillon Exp $ - * $DragonFly: src/sys/sys/signalvar.h,v 1.6 2003/10/13 18:12:07 dillon Exp $ + * $DragonFly: src/sys/sys/signalvar.h,v 1.7 2003/10/24 14:10:46 daver Exp $ */ #ifndef _SYS_SIGNALVAR_H_ /* tmp for user.h */ @@ -59,31 +59,9 @@ struct sigacts { sigset_t ps_sigreset; /* signals that reset when caught */ sigset_t ps_signodefer; /* signals not masked while handled */ sigset_t ps_siginfo; /* signals that want SA_SIGINFO args */ - sigset_t ps_osigset; /* signals that use osigset_t */ sigset_t ps_usertramp; /* SunOS compat; libc sigtramp XXX */ }; -/* - * Compatibility. - */ -typedef struct { - struct osigcontext si_sc; - int si_signo; - int si_code; - union sigval si_value; -} osiginfo_t; - -struct osigaction { - union { - void (*__sa_handler) (int); - void (*__sa_sigaction) (int, osiginfo_t *, void *); - } __sigaction_u; /* signal handler */ - osigset_t sa_mask; /* signal mask to apply */ - int sa_flags; /* see signal options below */ -}; - -typedef void __osiginfohandler_t (int, osiginfo_t *, void *); - /* additional signal action values, used only temporarily/internally */ #define SIG_CATCH ((__sighandler_t *)2) #define SIG_HOLD ((__sighandler_t *)3) @@ -146,9 +124,6 @@ typedef void __osiginfohandler_t (int, osiginfo_t *, void *); (set1).__bits[__i] &= ~(set2).__bits[__i]; \ } while (0) -#define SIGSETLO(set1, set2) ((set1).__bits[0] = (set2).__bits[0]) -#define SIGSETOLD(set, oset) ((set).__bits[0] = (oset)) - #define SIG_CANTMASK(set) \ SIGDELSET(set, SIGKILL), SIGDELSET(set, SIGSTOP) @@ -161,9 +136,6 @@ typedef void __osiginfohandler_t (int, osiginfo_t *, void *); #define sigcantmask (sigmask(SIGKILL) | sigmask(SIGSTOP)) -#define SIG2OSIG(sig, osig) osig = (sig).__bits[0] -#define OSIG2SIG(osig, sig) SIGEMPTYSET(sig); (sig).__bits[0] = osig - static __inline int __sigisempty(sigset_t *set) { diff --git a/sys/sys/syscall-hide.h b/sys/sys/syscall-hide.h index 8ec08b4df2..b47ef648dc 100644 --- a/sys/sys/syscall-hide.h +++ b/sys/sys/syscall-hide.h @@ -2,8 +2,8 @@ * System call hiders. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/syscall-hide.h,v 1.9 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/sys/syscall-hide.h,v 1.10 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ HIDE_POSIX(fork) @@ -49,13 +49,10 @@ HIDE_POSIX(pipe) HIDE_POSIX(getegid) HIDE_BSD(profil) HIDE_BSD(ktrace) -HIDE_POSIX(sigaction) HIDE_POSIX(getgid) -HIDE_POSIX(sigprocmask) HIDE_BSD(getlogin) HIDE_BSD(setlogin) HIDE_BSD(acct) -HIDE_POSIX(sigpending) HIDE_BSD(sigaltstack) HIDE_POSIX(ioctl) HIDE_BSD(reboot) @@ -102,14 +99,12 @@ HIDE_BSD(accept) HIDE_BSD(getpriority) HIDE_BSD(send) HIDE_BSD(recv) -HIDE_BSD(sigreturn) HIDE_BSD(bind) HIDE_BSD(setsockopt) HIDE_BSD(listen) HIDE_BSD(sigvec) HIDE_BSD(sigblock) HIDE_BSD(sigsetmask) -HIDE_POSIX(sigsuspend) HIDE_BSD(sigstack) HIDE_BSD(recvmsg) HIDE_BSD(sendmsg) diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 6b0934d5dd..404be43102 100644 --- a/sys/sys/syscall.h +++ b/sys/sys/syscall.h @@ -2,8 +2,8 @@ * System call numbers. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/syscall.h,v 1.9 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/sys/syscall.h,v 1.10 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ #define SYS_syscall 0 @@ -52,13 +52,13 @@ #define SYS_getegid 43 #define SYS_profil 44 #define SYS_ktrace 45 - /* 46 is old sigaction */ + /* 46 is obsolete freebsd3_sigaction */ #define SYS_getgid 47 - /* 48 is old sigprocmask */ + /* 48 is obsolete freebsd3_sigprocmask */ #define SYS_getlogin 49 #define SYS_setlogin 50 #define SYS_acct 51 - /* 52 is old sigpending */ + /* 52 is obsolete freebsd3_sigpending */ #define SYS_sigaltstack 53 #define SYS_ioctl 54 #define SYS_reboot 55 @@ -107,7 +107,7 @@ #define SYS_getpriority 100 /* 101 is old send */ /* 102 is old recv */ - /* 103 is old sigreturn */ + /* 103 is obsolete freebsd3_sigreturn */ #define SYS_bind 104 #define SYS_setsockopt 105 #define SYS_listen 106 @@ -115,7 +115,7 @@ /* 108 is old sigvec */ /* 109 is old sigblock */ /* 110 is old sigsetmask */ - /* 111 is old sigsuspend */ + /* 111 is obsolete freebsd3_sigsuspend */ /* 112 is old sigstack */ /* 113 is old recvmsg */ /* 114 is old sendmsg */ diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index 00a1dc83b6..28b2810251 100644 --- a/sys/sys/syscall.mk +++ b/sys/sys/syscall.mk @@ -1,7 +1,7 @@ # DragonFly system call names. # DO NOT EDIT-- this file is automatically generated. -# $DragonFly: src/sys/sys/syscall.mk,v 1.9 2003/10/08 01:30:32 daver Exp $ -# created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp +# $DragonFly: src/sys/sys/syscall.mk,v 1.10 2003/10/24 14:10:46 daver Exp $ +# created from DragonFly MIASM = \ syscall.o \ exit.o \ diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index e7aee857f2..0d7067c953 100644 --- a/sys/sys/sysproto.h +++ b/sys/sys/sysproto.h @@ -2,8 +2,8 @@ * System call prototypes. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/sysproto.h,v 1.9 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/sys/sysproto.h,v 1.10 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ #ifndef _SYS_SYSPROTO_H_ @@ -385,13 +385,6 @@ struct acct_args { union usrmsg usrmsg; char * path; char path_[PAD_(char *)]; }; -struct osigpending_args { -#ifdef _KERNEL - union sysmsg sysmsg; -#endif - union usrmsg usrmsg; - register_t dummy; -}; struct sigaltstack_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -2235,23 +2228,6 @@ struct olstat_args { char * path; char path_[PAD_(char *)]; struct ostat * ub; char ub_[PAD_(struct ostat *)]; }; -struct osigaction_args { -#ifdef _KERNEL - union sysmsg sysmsg; -#endif - union usrmsg usrmsg; - int signum; char signum_[PAD_(int)]; - struct osigaction * nsa; char nsa_[PAD_(struct osigaction *)]; - struct osigaction * osa; char osa_[PAD_(struct osigaction *)]; -}; -struct osigprocmask_args { -#ifdef _KERNEL - union sysmsg sysmsg; -#endif - union usrmsg usrmsg; - int how; char how_[PAD_(int)]; - osigset_t mask; char mask_[PAD_(osigset_t)]; -}; struct ofstat_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -2318,13 +2294,6 @@ struct orecv_args { int len; char len_[PAD_(int)]; int flags; char flags_[PAD_(int)]; }; -struct osigreturn_args { -#ifdef _KERNEL - union sysmsg sysmsg; -#endif - union usrmsg usrmsg; - struct osigcontext * sigcntxp; char sigcntxp_[PAD_(struct osigcontext *)]; -}; struct osigvec_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -2348,13 +2317,6 @@ struct osigsetmask_args { union usrmsg usrmsg; int mask; char mask_[PAD_(int)]; }; -struct osigsuspend_args { -#ifdef _KERNEL - union sysmsg sysmsg; -#endif - union usrmsg usrmsg; - osigset_t mask; char mask_[PAD_(osigset_t)]; -}; struct osigstack_args { #ifdef _KERNEL union sysmsg sysmsg; @@ -2454,9 +2416,6 @@ int ocreat (struct ocreat_args *); int olseek (struct olseek_args *); int ostat (struct ostat_args *); int olstat (struct olstat_args *); -int osigaction (struct osigaction_args *); -int osigprocmask (struct osigprocmask_args *); -int osigpending (struct osigpending_args *); int ofstat (struct ofstat_args *); int ogetkerninfo (struct getkerninfo_args *); int ogetpagesize (struct getpagesize_args *); @@ -2467,11 +2426,9 @@ int osethostname (struct sethostname_args *); int oaccept (struct accept_args *); int osend (struct osend_args *); int orecv (struct orecv_args *); -int osigreturn (struct osigreturn_args *); int osigvec (struct osigvec_args *); int osigblock (struct osigblock_args *); int osigsetmask (struct osigsetmask_args *); -int osigsuspend (struct osigsuspend_args *); int osigstack (struct osigstack_args *); int orecvmsg (struct orecvmsg_args *); int osendmsg (struct osendmsg_args *); diff --git a/sys/sys/sysunion.h b/sys/sys/sysunion.h index fbe6779f6e..8f031193d5 100644 --- a/sys/sys/sysunion.h +++ b/sys/sys/sysunion.h @@ -2,8 +2,8 @@ * Union of syscall args for messaging. * * DO NOT EDIT-- this file is automatically generated. - * $DragonFly: src/sys/sys/sysunion.h,v 1.6 2003/10/08 01:30:32 daver Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.2 2003/06/17 04:28:41 dillon Exp + * $DragonFly: src/sys/sys/sysunion.h,v 1.7 2003/10/24 14:10:46 daver Exp $ + * created from DragonFly */ union sysunion { @@ -64,17 +64,10 @@ union sysunion { struct getegid_args getegid; struct profil_args profil; struct ktrace_args ktrace; -#ifdef COMPAT_43 - struct osigaction_args osigaction; -#endif struct getgid_args getgid; -#ifdef COMPAT_43 - struct osigprocmask_args osigprocmask; -#endif struct getlogin_args getlogin; struct setlogin_args setlogin; struct acct_args acct; - struct osigpending_args osigpending; struct sigaltstack_args sigaltstack; struct ioctl_args ioctl; struct reboot_args reboot; @@ -131,9 +124,6 @@ union sysunion { #endif #ifdef COMPAT_43 struct orecv_args orecv; -#endif -#ifdef COMPAT_43 - struct osigreturn_args osigreturn; #endif struct bind_args bind; struct setsockopt_args setsockopt; @@ -147,9 +137,6 @@ union sysunion { #ifdef COMPAT_43 struct osigsetmask_args osigsetmask; #endif -#ifdef COMPAT_43 - struct osigsuspend_args osigsuspend; -#endif #ifdef COMPAT_43 struct osigstack_args osigstack; #endif -- 2.41.0