From f495cd9dc643b90d222f9f2d0c1edcfc88b864fc Mon Sep 17 00:00:00 2001 From: mycroft Date: Mon, 11 Dec 2000 05:28:59 +0000 Subject: [PATCH] Introduce 2 new flags in types.h: * __HAVE_SYSCALL_INTERN. If this is defined, e_syscall is replaced by e_syscall_intern, which is called at key places in the kernel. This can be used to set a MD syscall handler pointer. This obsoletes and replaces the *_HAS_SEPARATED_SYSCALL flags. * __HAVE_MINIMAL_EMUL. If this is defined, certain (deprecated) elements in struct emul are omitted. --- sys/arch/i386/conf/files.i386 | 3 +- sys/arch/i386/i386/genassym.cf | 7 +- sys/arch/i386/i386/ibcs2_syscall.c | 23 +- sys/arch/i386/i386/linux_syscall.c | 27 +- sys/arch/i386/i386/locore.s | 6 +- sys/arch/i386/i386/svr4_syscall.c | 18 +- sys/arch/i386/i386/syscall.c | 308 +++++++++++++++++++++ sys/arch/i386/i386/trap.c | 136 +-------- sys/arch/i386/include/ibcs2_machdep.h | 8 +- sys/arch/i386/include/proc.h | 4 +- sys/arch/i386/include/svr4_machdep.h | 5 +- sys/arch/i386/include/types.h | 4 +- sys/compat/aout/aout_exec.c | 20 +- sys/compat/aoutm68k/aoutm68k_exec.c | 6 +- sys/compat/freebsd/freebsd_exec.c | 18 +- sys/compat/hpux/hpux_exec.c | 6 +- sys/compat/ibcs2/ibcs2_exec.c | 17 +- sys/compat/linux/arch/i386/linux_errno.h | 4 +- sys/compat/linux/arch/i386/linux_machdep.h | 9 +- sys/compat/linux/common/linux_exec.c | 21 +- sys/compat/osf1/osf1_exec.c | 6 +- sys/compat/pecoff/pecoff_exec.c | 18 +- sys/compat/sunos/sunos_exec.c | 6 +- sys/compat/svr4/svr4_exec.c | 17 +- sys/kern/exec_elf32.c | 15 +- sys/kern/init_main.c | 5 +- sys/kern/kern_exec.c | 22 +- sys/kern/kern_fork.c | 5 +- sys/sys/proc.h | 15 +- 29 files changed, 504 insertions(+), 255 deletions(-) create mode 100644 sys/arch/i386/i386/syscall.c diff --git a/sys/arch/i386/conf/files.i386 b/sys/arch/i386/conf/files.i386 index c6514e0af860..6d58269be47c 100644 --- a/sys/arch/i386/conf/files.i386 +++ b/sys/arch/i386/conf/files.i386 @@ -1,4 +1,4 @@ -# $NetBSD: files.i386,v 1.177 2000/12/09 06:30:54 mycroft Exp $ +# $NetBSD: files.i386,v 1.178 2000/12/11 05:28:59 mycroft Exp $ # # new style config file for i386 architecture # @@ -72,6 +72,7 @@ file netns/ns_cksum.c ns file arch/i386/i386/pmap.c file arch/i386/i386/process_machdep.c file arch/i386/i386/sys_machdep.c +file arch/i386/i386/syscall.c file arch/i386/i386/trap.c file arch/i386/i386/vm_machdep.c file dev/cons.c diff --git a/sys/arch/i386/i386/genassym.cf b/sys/arch/i386/i386/genassym.cf index 2b728a84bd91..65e0c7d95192 100644 --- a/sys/arch/i386/i386/genassym.cf +++ b/sys/arch/i386/i386/genassym.cf @@ -1,4 +1,4 @@ -# $NetBSD: genassym.cf,v 1.23 2000/12/09 13:20:04 jdolecek Exp $ +# $NetBSD: genassym.cf,v 1.24 2000/12/11 05:28:59 mycroft Exp $ # # Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -142,12 +142,11 @@ define P_STAT offsetof(struct proc, p_stat) define P_WCHAN offsetof(struct proc, p_wchan) define P_FLAG offsetof(struct proc, p_flag) define P_MD_TSS_SEL offsetof(struct proc, p_md.md_tss_sel) -define P_EMUL offsetof(struct proc, p_emul) +define P_MD_REGS offsetof(struct proc, p_md.md_regs) +define P_MD_SYSCALL offsetof(struct proc, p_md.md_syscall) define P_SYSTEM P_SYSTEM -define E_SYSCALL offsetof(struct emul, e_syscall) - define M_DATA offsetof(struct mbuf, m_data) define M_LEN offsetof(struct mbuf, m_len) define M_NEXT offsetof(struct mbuf, m_next) diff --git a/sys/arch/i386/i386/ibcs2_syscall.c b/sys/arch/i386/i386/ibcs2_syscall.c index 4d95fd0ea315..e30c2872bc21 100644 --- a/sys/arch/i386/i386/ibcs2_syscall.c +++ b/sys/arch/i386/i386/ibcs2_syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibcs2_syscall.c,v 1.6 2000/12/10 19:29:30 mycroft Exp $ */ +/* $NetBSD: ibcs2_syscall.c,v 1.7 2000/12/11 05:28:59 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -107,8 +107,19 @@ #include #include +#include +#include void ibcs2_syscall __P((struct trapframe)); +extern struct sysent ibcs2_sysent[]; + +void +ibcs2_syscall_intern(p) + struct proc *p; +{ + + p->p_md.md_syscall = ibcs2_syscall; +} /* * syscall(frame): @@ -134,12 +145,11 @@ ibcs2_syscall(frame) #endif p = curproc; - p->p_md.md_regs = &frame; code = frame.tf_eax; if (IBCS2_HIGH_SYSCALL(code)) code = IBCS2_CVT_HIGH_SYSCALL(code); - callp = p->p_emul->e_sysent; + callp = ibcs2_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); #ifdef VM86 @@ -165,10 +175,7 @@ ibcs2_syscall(frame) break; } - if ((u_int)code >= (u_int)p->p_emul->e_nsysent) - callp += p->p_emul->e_nosys; /* illegal */ - else - callp += code; + callp += (code & (IBCS2_SYS_NSYSENT - 1)); argsize = callp->sy_argsize; if (argsize) { error = copyin(params, (caddr_t)args, argsize); @@ -204,7 +211,7 @@ ibcs2_syscall(frame) break; default: bad: - error = p->p_emul->e_errno[error]; + error = native_to_ibcs2_errno[error]; frame.tf_eax = error; frame.tf_eflags |= PSL_C; /* carry bit */ break; diff --git a/sys/arch/i386/i386/linux_syscall.c b/sys/arch/i386/i386/linux_syscall.c index 69bef9168ed7..4279e4c7a5ed 100644 --- a/sys/arch/i386/i386/linux_syscall.c +++ b/sys/arch/i386/i386/linux_syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: linux_syscall.c,v 1.6 2000/12/10 19:29:30 mycroft Exp $ */ +/* $NetBSD: linux_syscall.c,v 1.7 2000/12/11 05:28:59 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -105,10 +105,21 @@ #include #include -#include -#include +#include +#include +#include +#include void linux_syscall __P((struct trapframe)); +extern struct sysent linux_sysent[]; + +void +linux_syscall_intern(p) + struct proc *p; +{ + + p->p_md.md_syscall = linux_syscall; +} /* * syscall(frame): @@ -133,10 +144,9 @@ linux_syscall(frame) #endif p = curproc; - p->p_md.md_regs = &frame; code = frame.tf_eax; - callp = p->p_emul->e_sysent; + callp = linux_sysent; #ifdef VM86 /* @@ -149,10 +159,7 @@ linux_syscall(frame) else #endif /* VM86 */ - if ((u_int)code >= (u_int)p->p_emul->e_nsysent) - callp += p->p_emul->e_nosys; /* illegal */ - else - callp += code; + callp += (code & (LINUX_SYS_NSYSENT - 1)); argsize = callp->sy_argsize; if (argsize) { /* @@ -204,7 +211,7 @@ linux_syscall(frame) /* nothing to do */ break; default: - error = p->p_emul->e_errno[error]; + error = native_to_linux_errno[error]; frame.tf_eax = error; frame.tf_eflags |= PSL_C; /* carry bit */ break; diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s index b80fb4e796f5..4c809af8c9ec 100644 --- a/sys/arch/i386/i386/locore.s +++ b/sys/arch/i386/i386/locore.s @@ -1,4 +1,4 @@ -/* $NetBSD: locore.s,v 1.230 2000/12/11 02:48:07 mycroft Exp $ */ +/* $NetBSD: locore.s,v 1.231 2000/12/11 05:28:59 mycroft Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -2361,8 +2361,8 @@ syscall1: movl _C_LABEL(cpl),%ebx #endif /* DIAGNOSTIC */ movl _C_LABEL(curproc),%edx # get pointer to curproc - movl P_EMUL(%edx),%edx # get pointer to emul struct - call E_SYSCALL(%edx) # get pointer to syscall() function + movl %esp,P_MD_REGS(%edx) # save pointer to frame + call P_MD_SYSCALL(%edx) # get pointer to syscall() function 2: /* Check for ASTs on exit to user mode. */ cli cmpb $0,_C_LABEL(astpending) diff --git a/sys/arch/i386/i386/svr4_syscall.c b/sys/arch/i386/i386/svr4_syscall.c index 57b454c08497..c505d708fb84 100644 --- a/sys/arch/i386/i386/svr4_syscall.c +++ b/sys/arch/i386/i386/svr4_syscall.c @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_syscall.c,v 1.5 2000/12/10 19:29:30 mycroft Exp $ */ +/* $NetBSD: svr4_syscall.c,v 1.6 2000/12/11 05:29:00 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -105,9 +105,20 @@ #include #include +#include #include +#include void svr4_syscall __P((struct trapframe)); +extern struct sysent svr4_sysent[]; + +void +svr4_syscall_intern(p) + struct proc *p; +{ + + p->p_md.md_syscall = svr4_syscall; +} /* * syscall(frame): @@ -133,10 +144,9 @@ svr4_syscall(frame) #endif p = curproc; - p->p_md.md_regs = &frame; code = frame.tf_eax; - callp = p->p_emul->e_sysent; + callp = svr4_sysent; params = (caddr_t)frame.tf_esp + sizeof(int); #ifdef VM86 @@ -197,7 +207,7 @@ svr4_syscall(frame) break; default: bad: - error = p->p_emul->e_errno[error]; + error = native_to_svr4_errno[error]; frame.tf_eax = error; frame.tf_eflags |= PSL_C; /* carry bit */ break; diff --git a/sys/arch/i386/i386/syscall.c b/sys/arch/i386/i386/syscall.c new file mode 100644 index 000000000000..4d8b17a89794 --- /dev/null +++ b/sys/arch/i386/i386/syscall.c @@ -0,0 +1,308 @@ +/* $NetBSD: syscall.c,v 1.1 2000/12/11 05:29:00 mycroft Exp $ */ + +/*- + * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Charles M. Hannum. + * + * 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 NetBSD + * Foundation, Inc. and its contributors. + * 4. Neither the name of The NetBSD Foundation 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 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. + */ + +/*- + * Copyright (c) 1990 The Regents of the University of California. + * All rights reserved. + * + * This code is derived from software contributed to Berkeley by + * the University of Utah, and William Jolitz. + * + * 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. + * + * @(#)trap.c 7.4 (Berkeley) 5/13/91 + */ + +/* + * 386 Trap and System call handling + */ + +#include "opt_syscall_debug.h" +#include "opt_vm86.h" +#include "opt_ktrace.h" + +#include +#include +#include +#include +#include +#include +#include +#ifdef KTRACE +#include +#endif +#include + +#include + +#include +#include +#include +#include +#include +#include + +void syscall_intern __P((struct proc *)); +void syscall __P((struct trapframe)); + +void +syscall_intern(p) + struct proc *p; +{ + + p->p_md.md_syscall = syscall; +} + +/* + * syscall(frame): + * System call request from POSIX system call gate interface to kernel. + * Like trap(), argument is call by reference. + */ +#if 0 +/*ARGSUSED*/ +void +syscall(frame) + struct trapframe frame; +{ + register caddr_t params; + register const struct sysent *callp; + register struct proc *p; + int error; + size_t argsize; + register_t code, args[8], rval[2]; + + uvmexp.syscalls++; +#ifdef DEBUG + if (!USERMODE(frame.tf_cs, frame.tf_eflags)) + panic("syscall"); +#endif + + p = curproc; + + code = frame.tf_eax; + callp = p->p_emul->e_sysent; + params = (caddr_t)frame.tf_esp + sizeof(int); + + callp += (code & (SYS_NSYSENT - 1)); + argsize = callp->sy_argsize; + if (argsize) { + error = copyin(params, (caddr_t)args, argsize); + if (error) + goto bad; + } + rval[0] = 0; + rval[1] = 0; + error = (*callp->sy_call)(p, args, rval); + switch (error) { + case 0: + frame.tf_eax = rval[0]; + frame.tf_edx = rval[1]; + frame.tf_eflags &= ~PSL_C; /* carry bit */ + break; + case ERESTART: + /* + * The offset to adjust the PC by depends on whether we entered + * the kernel through the trap or call gate. We pushed the + * size of the instruction into tf_err on entry. + */ + frame.tf_eip -= frame.tf_err; + break; + case EJUSTRETURN: + /* nothing to do */ + break; + default: + bad: + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ + break; + } + + userret(p); +} +#endif + +#if 1 +/*ARGSUSED*/ +void +syscall(frame) + struct trapframe frame; +{ + register caddr_t params; + register const struct sysent *callp; + register struct proc *p; + int error; + size_t argsize; + register_t code, args[8], rval[2]; + + uvmexp.syscalls++; +#ifdef DEBUG + if (!USERMODE(frame.tf_cs, frame.tf_eflags)) + panic("syscall"); +#endif + + p = curproc; + + code = frame.tf_eax; + callp = p->p_emul->e_sysent; + params = (caddr_t)frame.tf_esp + sizeof(int); + +#ifdef VM86 + /* + * VM86 mode application found our syscall trap gate by accident; let + * it get a SIGSYS and have the VM86 handler in the process take care + * of it. + */ + if (frame.tf_eflags & PSL_VM) + code = -1; + else +#endif /* VM86 */ + + switch (code) { + case SYS_syscall: + /* + * Code is first argument, followed by actual args. + */ + code = fuword(params); + params += sizeof(int); + break; + case SYS___syscall: + /* + * Like syscall, but code is a quad, so as to maintain + * quad alignment for the rest of the arguments. + */ + code = fuword(params + _QUAD_LOWWORD * sizeof(int)); + params += sizeof(quad_t); + break; + default: + break; + } + + callp += (code & (SYS_NSYSENT - 1)); + argsize = callp->sy_argsize; + if (argsize) { + error = copyin(params, (caddr_t)args, argsize); + if (error) + goto bad; + } +#ifdef SYSCALL_DEBUG + scdebug_call(p, code, args); +#endif /* SYSCALL_DEBUG */ +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSCALL)) + ktrsyscall(p, code, argsize, args); +#endif /* KTRACE */ + rval[0] = 0; + rval[1] = 0; + error = (*callp->sy_call)(p, args, rval); + switch (error) { + case 0: + frame.tf_eax = rval[0]; + frame.tf_edx = rval[1]; + frame.tf_eflags &= ~PSL_C; /* carry bit */ + break; + case ERESTART: + /* + * The offset to adjust the PC by depends on whether we entered + * the kernel through the trap or call gate. We pushed the + * size of the instruction into tf_err on entry. + */ + frame.tf_eip -= frame.tf_err; + break; + case EJUSTRETURN: + /* nothing to do */ + break; + default: + bad: + frame.tf_eax = error; + frame.tf_eflags |= PSL_C; /* carry bit */ + break; + } + +#ifdef SYSCALL_DEBUG + scdebug_ret(p, code, error, rval); +#endif /* SYSCALL_DEBUG */ + userret(p); +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSRET)) + ktrsysret(p, code, error, rval[0]); +#endif /* KTRACE */ +} +#endif + +void +child_return(arg) + void *arg; +{ + struct proc *p = arg; + struct trapframe *tf = p->p_md.md_regs; + + tf->tf_eax = 0; + tf->tf_eflags &= ~PSL_C; + + userret(p); +#ifdef KTRACE + if (KTRPOINT(p, KTR_SYSRET)) + ktrsysret(p, SYS_fork, 0, 0); +#endif +} diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c index 0a4a9104cb9f..ad50cac3fff7 100644 --- a/sys/arch/i386/i386/trap.c +++ b/sys/arch/i386/i386/trap.c @@ -1,4 +1,4 @@ -/* $NetBSD: trap.c,v 1.152 2000/12/10 19:29:30 mycroft Exp $ */ +/* $NetBSD: trap.c,v 1.153 2000/12/11 05:29:00 mycroft Exp $ */ /*- * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. @@ -79,10 +79,8 @@ */ #include "opt_ddb.h" -#include "opt_syscall_debug.h" #include "opt_math_emulate.h" #include "opt_vm86.h" -#include "opt_ktrace.h" #include "opt_cputype.h" #include @@ -92,9 +90,6 @@ #include #include #include -#ifdef KTRACE -#include -#endif #include #include @@ -126,7 +121,6 @@ void trap __P((struct trapframe)); #if defined(I386_CPU) int trapwrite __P((unsigned)); #endif -void syscall __P((struct trapframe)); const char *trap_type[] = { "privileged instruction fault", /* 0 T_PRIVINFLT */ @@ -530,131 +524,3 @@ trapwrite(addr) return 0; } #endif /* I386_CPU */ - -/* - * syscall(frame): - * System call request from POSIX system call gate interface to kernel. - * Like trap(), argument is call by reference. - */ -/*ARGSUSED*/ -void -syscall(frame) - struct trapframe frame; -{ - register caddr_t params; - register const struct sysent *callp; - register struct proc *p; - int error; - size_t argsize; - register_t code, args[8], rval[2]; - - uvmexp.syscalls++; -#ifdef DEBUG - if (!USERMODE(frame.tf_cs, frame.tf_eflags)) - panic("syscall"); -#endif - - p = curproc; - p->p_md.md_regs = &frame; - - code = frame.tf_eax; - callp = p->p_emul->e_sysent; - params = (caddr_t)frame.tf_esp + sizeof(int); - -#ifdef VM86 - /* - * VM86 mode application found our syscall trap gate by accident; let - * it get a SIGSYS and have the VM86 handler in the process take care - * of it. - */ - if (frame.tf_eflags & PSL_VM) - code = -1; - else -#endif /* VM86 */ - - switch (code) { - case SYS_syscall: - /* - * Code is first argument, followed by actual args. - */ - code = fuword(params); - params += sizeof(int); - break; - case SYS___syscall: - /* - * Like syscall, but code is a quad, so as to maintain - * quad alignment for the rest of the arguments. - */ - code = fuword(params + _QUAD_LOWWORD * sizeof(int)); - params += sizeof(quad_t); - break; - default: - break; - } - callp += (code & (SYS_NSYSENT - 1)); - argsize = callp->sy_argsize; - if (argsize) { - error = copyin(params, (caddr_t)args, argsize); - if (error) - goto bad; - } -#ifdef SYSCALL_DEBUG - scdebug_call(p, code, args); -#endif /* SYSCALL_DEBUG */ -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSCALL)) - ktrsyscall(p, code, argsize, args); -#endif /* KTRACE */ - rval[0] = 0; - rval[1] = 0; - error = (*callp->sy_call)(p, args, rval); - switch (error) { - case 0: - frame.tf_eax = rval[0]; - frame.tf_edx = rval[1]; - frame.tf_eflags &= ~PSL_C; /* carry bit */ - break; - case ERESTART: - /* - * The offset to adjust the PC by depends on whether we entered - * the kernel through the trap or call gate. We pushed the - * size of the instruction into tf_err on entry. - */ - frame.tf_eip -= frame.tf_err; - break; - case EJUSTRETURN: - /* nothing to do */ - break; - default: - bad: - frame.tf_eax = error; - frame.tf_eflags |= PSL_C; /* carry bit */ - break; - } - -#ifdef SYSCALL_DEBUG - scdebug_ret(p, code, error, rval); -#endif /* SYSCALL_DEBUG */ - userret(p); -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p, code, error, rval[0]); -#endif /* KTRACE */ -} - -void -child_return(arg) - void *arg; -{ - struct proc *p = arg; - struct trapframe *tf = p->p_md.md_regs; - - tf->tf_eax = 0; - tf->tf_eflags &= ~PSL_C; - - userret(p); -#ifdef KTRACE - if (KTRPOINT(p, KTR_SYSRET)) - ktrsysret(p, SYS_fork, 0, 0); -#endif -} diff --git a/sys/arch/i386/include/ibcs2_machdep.h b/sys/arch/i386/include/ibcs2_machdep.h index 9ebc8d505a19..bc1db4d920d1 100644 --- a/sys/arch/i386/include/ibcs2_machdep.h +++ b/sys/arch/i386/include/ibcs2_machdep.h @@ -1,7 +1,7 @@ -/* $NetBSD: ibcs2_machdep.h,v 1.9 2000/12/09 12:45:44 jdolecek Exp $ */ +/* $NetBSD: ibcs2_machdep.h,v 1.10 2000/12/11 05:29:00 mycroft Exp $ */ /*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. + * Copyright (c) 1997, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -51,9 +51,7 @@ void ibcs2_setregs __P((struct proc *, struct exec_package *, u_long)); void ibcs2_sendsig __P((sig_t, int, sigset_t *, u_long)); int ibcs2_sys_sysmachine __P((struct proc *, void *, register_t *retval)); +void ibcs2_syscall_intern __P((struct proc *)); #endif /* _KERNEL */ -/* i386 has separated ibcs2_syscall() from syscall() */ -#define IBCS2_MACHDEP_HAS_SEPARATED_SYSCALL - #endif /* !_I386_IBCS2_MACHDEP_H_ */ diff --git a/sys/arch/i386/include/proc.h b/sys/arch/i386/include/proc.h index 8fd941903121..b4370603e64c 100644 --- a/sys/arch/i386/include/proc.h +++ b/sys/arch/i386/include/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.11 2000/08/16 04:44:37 thorpej Exp $ */ +/* $NetBSD: proc.h,v 1.12 2000/12/11 05:29:00 mycroft Exp $ */ /* * Copyright (c) 1991 Regents of the University of California. @@ -42,6 +42,8 @@ struct mdproc { struct trapframe *md_regs; /* registers on current frame */ int md_flags; /* machine-dependent flags */ int md_tss_sel; /* TSS selector */ + /* Syscall handling function */ + void (*md_syscall) __P((struct trapframe)); }; /* md_flags */ diff --git a/sys/arch/i386/include/svr4_machdep.h b/sys/arch/i386/include/svr4_machdep.h index 384d1d06226a..6ba911aa8167 100644 --- a/sys/arch/i386/include/svr4_machdep.h +++ b/sys/arch/i386/include/svr4_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: svr4_machdep.h,v 1.11 2000/12/09 12:44:26 jdolecek Exp $ */ +/* $NetBSD: svr4_machdep.h,v 1.12 2000/12/11 05:29:00 mycroft Exp $ */ /*- * Copyright (c) 1994 The NetBSD Foundation, Inc. @@ -125,7 +125,6 @@ struct svr4_ssd { #define SVR4_TRAP_GETHRVTIME 4 #define SVR4_TRAP_CLOCK_SETTIME 5 -/* i386 has separated svr4_syscall() from syscall() */ -#define SVR4_MACHDEP_HAS_SEPARATED_SYSCALL +void svr4_syscall_intern __P((struct proc *)); #endif /* !_I386_SVR4_MACHDEP_H_ */ diff --git a/sys/arch/i386/include/types.h b/sys/arch/i386/include/types.h index 7201364868d3..3e46c495f8f3 100644 --- a/sys/arch/i386/include/types.h +++ b/sys/arch/i386/include/types.h @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.24 2000/06/06 01:33:17 sommerfeld Exp $ */ +/* $NetBSD: types.h,v 1.25 2000/12/11 05:29:00 mycroft Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -78,5 +78,7 @@ typedef int32_t register_t; #define __HAVE_DEVICE_REGISTER #define __HAVE_NWSCONS #define __HAVE_CPU_COUNTER +#define __HAVE_SYSCALL_INTERN +#define __HAVE_MINIMAL_EMUL #endif /* _MACHTYPES_H_ */ diff --git a/sys/compat/aout/aout_exec.c b/sys/compat/aout/aout_exec.c index b1003482e3d7..ca8c27ef52b1 100644 --- a/sys/compat/aout/aout_exec.c +++ b/sys/compat/aout/aout_exec.c @@ -1,7 +1,7 @@ -/* $NetBSD: aout_exec.c,v 1.8 2000/12/09 12:38:23 jdolecek Exp $ */ +/* $NetBSD: aout_exec.c,v 1.9 2000/12/11 05:29:00 mycroft Exp $ */ /*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1998, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -53,26 +53,36 @@ extern struct sysent aout_sysent[]; extern const char * const aout_syscallnames[]; #endif extern char sigcode[], esigcode[]; +#ifdef __HAVE_SYSCALL_INTERN +void syscall_intern __P((struct proc *)); +#else void syscall __P((void)); +#endif struct emul emul_netbsd_aout = { "netbsd", "/emul/aout", +#ifndef __HAVE_MINIMAL_EMUL + EMUL_HAS_SYS___syscall, NULL, - sendsig, AOUT_SYS_syscall, AOUT_SYS_MAXSYSCALL, +#endif aout_sysent, #ifdef SYSCALL_DEBUG aout_syscallnames, #else NULL, #endif + sendsig, sigcode, esigcode, NULL, NULL, NULL, - EMUL_HAS_SYS___syscall, - syscall +#ifdef __HAVE_SYSCALL_INTERN + syscall_intern, +#else + syscall, +#endif }; diff --git a/sys/compat/aoutm68k/aoutm68k_exec.c b/sys/compat/aoutm68k/aoutm68k_exec.c index 0801c9a90940..b754561002f9 100644 --- a/sys/compat/aoutm68k/aoutm68k_exec.c +++ b/sys/compat/aoutm68k/aoutm68k_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: aoutm68k_exec.c,v 1.3 2000/12/09 12:38:24 jdolecek Exp $ */ +/* $NetBSD: aoutm68k_exec.c,v 1.4 2000/12/11 05:29:00 mycroft Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -59,8 +59,8 @@ void syscall __P((void)); struct emul emul_netbsd_aoutm68k = { "aoutm68k", "/emul/aout", + EMUL_HAS_SYS___syscall, NULL, - sendsig, AOUTM68K_SYS_syscall, AOUTM68K_SYS_MAXSYSCALL, aoutm68k_sysent, @@ -69,11 +69,11 @@ struct emul emul_netbsd_aoutm68k = { #else NULL, #endif + sendsig, sigcode, esigcode, NULL, NULL, NULL, - EMUL_HAS_SYS___syscall, syscall }; diff --git a/sys/compat/freebsd/freebsd_exec.c b/sys/compat/freebsd/freebsd_exec.c index ef3318460fd1..3fd2d3b8172c 100644 --- a/sys/compat/freebsd/freebsd_exec.c +++ b/sys/compat/freebsd/freebsd_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: freebsd_exec.c,v 1.12 2000/12/09 12:38:24 jdolecek Exp $ */ +/* $NetBSD: freebsd_exec.c,v 1.13 2000/12/11 05:29:00 mycroft Exp $ */ /* * Copyright (c) 1993, 1994 Christopher G. Demetriou @@ -41,22 +41,32 @@ extern struct sysent freebsd_sysent[]; extern const char * const freebsd_syscallnames[]; +#ifdef __HAVE_SYSCALL_INTERN +void syscall_intern __P((struct proc *)); +#else void syscall __P((void)); +#endif const struct emul emul_freebsd = { "freebsd", "/emul/freebsd", +#ifndef __HAVE_MINIMAL_EMUL + EMUL_HAS_SYS___syscall, NULL, - freebsd_sendsig, FREEBSD_SYS_syscall, FREEBSD_SYS_MAXSYSCALL, +#endif freebsd_sysent, freebsd_syscallnames, + freebsd_sendsig, freebsd_sigcode, freebsd_esigcode, NULL, NULL, NULL, - EMUL_HAS_SYS___syscall, - syscall +#ifdef __HAVE_SYSCALL_INTERN + syscall_intern, +#else + syscall, +#endif }; diff --git a/sys/compat/hpux/hpux_exec.c b/sys/compat/hpux/hpux_exec.c index 508113b5121e..76ea845562c4 100644 --- a/sys/compat/hpux/hpux_exec.c +++ b/sys/compat/hpux/hpux_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: hpux_exec.c,v 1.21 2000/12/09 12:38:24 jdolecek Exp $ */ +/* $NetBSD: hpux_exec.c,v 1.22 2000/12/11 05:29:01 mycroft Exp $ */ /*- * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. @@ -103,10 +103,11 @@ void syscall __P((void)); const struct emul emul_hpux = { "hpux", "/emul/hpux", + 0, native_to_hpux_errno, - hpux_sendsig, HPUX_SYS_syscall, HPUX_SYS_MAXSYSCALL, + hpux_sendsig, hpux_sysent, hpux_syscallnames, sigcode, @@ -114,7 +115,6 @@ const struct emul emul_hpux = { NULL, NULL, NULL, - 0, syscall }; diff --git a/sys/compat/ibcs2/ibcs2_exec.c b/sys/compat/ibcs2/ibcs2_exec.c index d3f6c3f4cefb..474a3066a99f 100644 --- a/sys/compat/ibcs2/ibcs2_exec.c +++ b/sys/compat/ibcs2/ibcs2_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: ibcs2_exec.c,v 1.43 2000/12/09 12:45:44 jdolecek Exp $ */ +/* $NetBSD: ibcs2_exec.c,v 1.44 2000/12/11 05:29:01 mycroft Exp $ */ /* * Copyright (c) 1994, 1995, 1998 Scott Bartram @@ -56,8 +56,9 @@ static void ibcs2_e_proc_exec __P((struct proc *, struct exec_package *)); extern struct sysent ibcs2_sysent[]; extern const char * const ibcs2_syscallnames[]; extern char ibcs2_sigcode[], ibcs2_esigcode[]; -void ibcs2_syscall __P((void)); +#ifndef __HAVE_SYSCALL_INTERN void syscall __P((void)); +#endif #ifdef IBCS2_DEBUG int ibcs2_debug = 1; @@ -68,20 +69,22 @@ int ibcs2_debug = 0; const struct emul emul_ibcs2 = { "ibcs2", "/emul/ibcs2", - native_to_ibcs2_errno, - ibcs2_sendsig, +#ifndef __HAVE_MINIMAL_EMUL 0, + native_to_ibcs2_errno, + IBCS2_SYS_syscall, IBCS2_SYS_MAXSYSCALL, +#endif ibcs2_sysent, ibcs2_syscallnames, + ibcs2_sendsig, ibcs2_sigcode, ibcs2_esigcode, ibcs2_e_proc_exec, NULL, NULL, - 0, -#ifdef IBCS2_MACHDEP_HAS_SEPARATED_SYSCALL - ibcs2_syscall, +#ifdef __HAVE_SYSCALL_INTERN + ibcs2_syscall_intern, #else syscall, #endif diff --git a/sys/compat/linux/arch/i386/linux_errno.h b/sys/compat/linux/arch/i386/linux_errno.h index b39341353870..e26fff929ef6 100644 --- a/sys/compat/linux/arch/i386/linux_errno.h +++ b/sys/compat/linux/arch/i386/linux_errno.h @@ -1,4 +1,4 @@ -/* $NetBSD: linux_errno.h,v 1.3 1998/10/04 00:02:25 fvdl Exp $ */ +/* $NetBSD: linux_errno.h,v 1.4 2000/12/11 05:29:01 mycroft Exp $ */ /*- * Copyright (c) 1995, 1998 The NetBSD Foundation, Inc. @@ -128,4 +128,6 @@ #define LINUX_EREMOTEIO 121 #define LINUX_EDQUOT 122 +extern int native_to_linux_errno[]; + #endif /* !_I386_LINUX_ERRNO_H */ diff --git a/sys/compat/linux/arch/i386/linux_machdep.h b/sys/compat/linux/arch/i386/linux_machdep.h index f598bc4df607..7c28bb47ede1 100644 --- a/sys/compat/linux/arch/i386/linux_machdep.h +++ b/sys/compat/linux/arch/i386/linux_machdep.h @@ -1,7 +1,7 @@ -/* $NetBSD: linux_machdep.h,v 1.15 2000/12/10 14:09:59 fvdl Exp $ */ +/* $NetBSD: linux_machdep.h,v 1.16 2000/12/11 05:29:01 mycroft Exp $ */ /*- - * Copyright (c) 1995 The NetBSD Foundation, Inc. + * Copyright (c) 1995, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -127,9 +127,6 @@ __END_DECLS #define LINUX_VT_WAITACTIVE 0x5607 #define LINUX_VT_DISALLOCATE 0x5608 -/* - * Does the port have separated linux_syscall() ? - */ -#define LINUX_MACHDEP_HAS_SEPARATED_SYSCALL +void linux_syscall_intern __P((struct proc *)); #endif /* _I386_LINUX_MACHDEP_H */ diff --git a/sys/compat/linux/common/linux_exec.c b/sys/compat/linux/common/linux_exec.c index 2916801db8fd..0d2d8f8b873d 100644 --- a/sys/compat/linux/common/linux_exec.c +++ b/sys/compat/linux/common/linux_exec.c @@ -1,7 +1,7 @@ -/* $NetBSD: linux_exec.c,v 1.43 2000/12/09 12:38:24 jdolecek Exp $ */ +/* $NetBSD: linux_exec.c,v 1.44 2000/12/11 05:29:01 mycroft Exp $ */ /*- - * Copyright (c) 1994, 1995, 1998 The NetBSD Foundation, Inc. + * Copyright (c) 1994, 1995, 1998, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -69,8 +69,9 @@ extern struct sysent linux_sysent[]; extern const char * const linux_syscallnames[]; extern char linux_sigcode[], linux_esigcode[]; -void linux_syscall __P((void)); +#ifndef __HAVE_SYSCALL_INTERN void syscall __P((void)); +#endif static void linux_e_proc_exec __P((struct proc *, struct exec_package *)); static void linux_e_proc_fork __P((struct proc *, struct proc *)); @@ -110,24 +111,22 @@ linux_sys_execve(p, v, retval) const struct emul emul_linux = { "linux", "/emul/linux", +#ifndef __HAVE_MINIMAL_EMUL + 0, native_to_linux_errno, - linux_sendsig, LINUX_SYS_syscall, LINUX_SYS_MAXSYSCALL, +#endif linux_sysent, linux_syscallnames, + linux_sendsig, linux_sigcode, linux_esigcode, linux_e_proc_exec, linux_e_proc_fork, linux_e_proc_exit, -#ifdef LINUX_MACHDEP_PASS_PPID_AND_EUID - EMUL_GETPID_PASS_PPID|EMUL_GETID_PASS_EID, -#else - 0, -#endif -#ifdef LINUX_MACHDEP_HAS_SEPARATED_SYSCALL - linux_syscall, +#ifdef __HAVE_SYSCALL_INTERN + linux_syscall_intern, #else syscall, #endif diff --git a/sys/compat/osf1/osf1_exec.c b/sys/compat/osf1/osf1_exec.c index 405e31a29f38..d98940bd8ac1 100644 --- a/sys/compat/osf1/osf1_exec.c +++ b/sys/compat/osf1/osf1_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: osf1_exec.c,v 1.19 2000/12/09 12:38:25 jdolecek Exp $ */ +/* $NetBSD: osf1_exec.c,v 1.20 2000/12/11 05:29:01 mycroft Exp $ */ /* * Copyright (c) 1999 Christopher G. Demetriou. All rights reserved. @@ -47,17 +47,17 @@ void syscall __P((void)); const struct emul emul_osf1 = { "osf1", "/emul/osf1", + 0, (int *)osf1_errno_rxlist, - sendsig, OSF1_SYS_syscall, OSF1_SYS_MAXSYSCALL, osf1_sysent, osf1_syscallnames, + sendsig, osf1_sigcode, osf1_esigcode, NULL, NULL, NULL, - 0, syscall }; diff --git a/sys/compat/pecoff/pecoff_exec.c b/sys/compat/pecoff/pecoff_exec.c index 40ac5b2faee6..57b3eba3f9b9 100644 --- a/sys/compat/pecoff/pecoff_exec.c +++ b/sys/compat/pecoff/pecoff_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: pecoff_exec.c,v 1.6 2000/12/09 12:38:25 jdolecek Exp $ */ +/* $NetBSD: pecoff_exec.c,v 1.7 2000/12/11 05:29:02 mycroft Exp $ */ /* * Copyright (c) 2000 Masaru OKI @@ -82,29 +82,39 @@ int pecoff_read_from __P((struct proc *p, struct vnode *vp, int pos, extern char sigcode[], esigcode[]; +#ifdef __HAVE_SYSCALL_INTERN +void syscall_intern __P((void)); +#else void syscall __P((void)); +#endif #if notyet const struct emul emul_pecoff = { "pecoff", "/emul/pecoff", +#ifndef __HAVE_MINIMAL_EMUL + 0, 0, - sendsig, SYS_syscall, SYS_MAXSYSCALL, +#endif sysent, #ifdef SYSCALL_DEBUG syscallnames, #else 0, #endif + sendsig, sigcode, esigcode, NULL, NULL, NULL, - 0, - syscall +#ifdef __HAVE_SYSCALL_INTERN + syscall_intern, +#else + syscall, +#endif }; #endif diff --git a/sys/compat/sunos/sunos_exec.c b/sys/compat/sunos/sunos_exec.c index 858336af5060..806791bda77a 100644 --- a/sys/compat/sunos/sunos_exec.c +++ b/sys/compat/sunos/sunos_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: sunos_exec.c,v 1.28 2000/12/09 12:38:25 jdolecek Exp $ */ +/* $NetBSD: sunos_exec.c,v 1.29 2000/12/11 05:29:02 mycroft Exp $ */ /* * Copyright (c) 1993 Theo de Raadt @@ -52,8 +52,8 @@ void syscall __P((void)); struct emul emul_sunos = { "sunos", "/emul/sunos", + 0, NULL, - sunos_sendsig, SUNOS_SYS_syscall, SUNOS_SYS_MAXSYSCALL, sunos_sysent, @@ -62,11 +62,11 @@ struct emul emul_sunos = { #else NULL, #endif + sunos_sendsig, sunos_sigcode, sunos_esigcode, NULL, NULL, NULL, - 0, syscall }; diff --git a/sys/compat/svr4/svr4_exec.c b/sys/compat/svr4/svr4_exec.c index 391940757f46..6747a8a97458 100644 --- a/sys/compat/svr4/svr4_exec.c +++ b/sys/compat/svr4/svr4_exec.c @@ -1,7 +1,7 @@ -/* $NetBSD: svr4_exec.c,v 1.40 2000/12/09 12:44:26 jdolecek Exp $ */ +/* $NetBSD: svr4_exec.c,v 1.41 2000/12/11 05:29:02 mycroft Exp $ */ /*- - * Copyright (c) 1994 The NetBSD Foundation, Inc. + * Copyright (c) 1994, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -52,26 +52,29 @@ extern char svr4_sigcode[], svr4_esigcode[]; extern struct sysent svr4_sysent[]; extern const char * const svr4_syscallnames[]; -void svr4_syscall __P((void)); +#ifndef __HAVE_SYSCALL_INTERN void syscall __P((void)); +#endif const struct emul emul_svr4 = { "svr4", "/emul/svr4", +#ifndef __HAVE_MINIMAL_EMUL + 0, native_to_svr4_errno, - svr4_sendsig, SVR4_SYS_syscall, SVR4_SYS_MAXSYSCALL, +#endif svr4_sysent, svr4_syscallnames, + svr4_sendsig, svr4_sigcode, svr4_esigcode, NULL, NULL, NULL, - 0, -#ifdef SVR4_MACHDEP_HAS_SEPARATED_SYSCALL - svr4_syscall, +#ifdef __HAVE_SYSCALL_INTERN + svr4_syscall_intern, #else syscall, #endif diff --git a/sys/kern/exec_elf32.c b/sys/kern/exec_elf32.c index 881d0e9e183a..de142e4ec8be 100644 --- a/sys/kern/exec_elf32.c +++ b/sys/kern/exec_elf32.c @@ -1,7 +1,7 @@ -/* $NetBSD: exec_elf32.c,v 1.59 2000/11/28 13:10:41 mrg Exp $ */ +/* $NetBSD: exec_elf32.c,v 1.60 2000/12/11 05:29:02 mycroft Exp $ */ /*- - * Copyright (c) 1994 The NetBSD Foundation, Inc. + * Copyright (c) 1994, 2000 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation @@ -68,8 +68,6 @@ #define ELFSIZE 32 #endif -#include "opt_compat_ibcs2.h" /* XXX quirk for PT_SHLIB section */ - #include #include #include @@ -514,7 +512,6 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp) * interp[] with a changed path (/emul/xxx/). */ if (!epp->ep_esch->u.elf_probe_func) { - p->p_emul = epp->ep_esch->es_emul; pos = ELFDEFNNAME(NO_ADDR); } else { error = (*epp->ep_esch->u.elf_probe_func)(p, epp, eh, interp, @@ -563,13 +560,9 @@ ELFNAME2(exec,makecmds)(struct proc *p, struct exec_package *epp) break; case PT_SHLIB: -#ifndef COMPAT_IBCS2 /* SCO has these sections */ - error = ENOEXEC; - goto bad; -#endif - + /* SCO has these sections. */ case PT_INTERP: - /* Already did this one */ + /* Already did this one. */ case PT_DYNAMIC: case PT_NOTE: break; diff --git a/sys/kern/init_main.c b/sys/kern/init_main.c index 4a78fdffb0a8..c37163d9be25 100644 --- a/sys/kern/init_main.c +++ b/sys/kern/init_main.c @@ -1,4 +1,4 @@ -/* $NetBSD: init_main.c,v 1.186 2000/12/08 22:07:36 jdolecek Exp $ */ +/* $NetBSD: init_main.c,v 1.187 2000/12/11 05:29:02 mycroft Exp $ */ /* * Copyright (c) 1995 Christopher G. Demetriou. All rights reserved. @@ -246,6 +246,9 @@ main(void) p->p_stat = SONPROC; p->p_nice = NZERO; p->p_emul = &emul_netbsd; +#ifdef __HAVE_SYSCALL_INTERN + (*p->p_emul->e_syscall_intern)(p); +#endif strncpy(p->p_comm, "swapper", MAXCOMLEN); callout_init(&p->p_realit_ch); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 27b4db4a4cae..79c62415c1a7 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.132 2000/12/10 12:42:30 jdolecek Exp $ */ +/* $NetBSD: kern_exec.c,v 1.133 2000/12/11 05:29:02 mycroft Exp $ */ /*- * Copyright (C) 1993, 1994, 1996 Christopher G. Demetriou @@ -108,28 +108,38 @@ extern char sigcode[], esigcode[]; #ifdef SYSCALL_DEBUG extern const char * const syscallnames[]; #endif +#ifdef __HAVE_SYSCALL_INTERN +void syscall_intern __P((struct proc *)); +#else void syscall __P((void)); +#endif const struct emul emul_netbsd = { "netbsd", NULL, /* emulation path */ +#ifndef __HAVE_MINIMAL_EMUL + EMUL_HAS_SYS___syscall, NULL, - sendsig, SYS_syscall, SYS_MAXSYSCALL, +#endif sysent, #ifdef SYSCALL_DEBUG syscallnames, #else NULL, #endif + sendsig, sigcode, esigcode, NULL, NULL, NULL, - EMUL_HAS_SYS___syscall, - syscall +#ifdef __HAVE_SYSCALL_INTERN + syscall_intern, +#else + syscall, +#endif }; /* @@ -632,7 +642,9 @@ sys_execve(struct proc *p, void *v, register_t *retval) /* update p_emul, the old value is no longer needed */ p->p_emul = pack.ep_es->es_emul; - +#ifdef __HAVE_SYSCALL_INTERN + (*p->p_emul->e_syscall_intern)(p); +#endif #ifdef KTRACE if (KTRPOINT(p, KTR_EMUL)) ktremul(p); diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 932277980f6d..44c28339893b 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_fork.c,v 1.78 2000/12/10 11:41:20 jdolecek Exp $ */ +/* $NetBSD: kern_fork.c,v 1.79 2000/12/11 05:29:02 mycroft Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1991, 1993 @@ -193,6 +193,9 @@ fork1(struct proc *p1, int flags, int exitsig, void *stack, size_t stacksize, */ p2->p_flag = P_INMEM | (p1->p_flag & P_SUGID); p2->p_emul = p1->p_emul; +#ifdef __HAVE_SYSCALL_INTERN + (*p2->p_emul->e_syscall_intern)(p2); +#endif if (p1->p_flag & P_PROFIL) startprofclock(p2); p2->p_cred = pool_get(&pcred_pool, PR_WAITOK); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index 15f1d9f0805f..0657e2b2d2dd 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -1,4 +1,4 @@ -/* $NetBSD: proc.h,v 1.115 2000/12/09 12:34:14 jdolecek Exp $ */ +/* $NetBSD: proc.h,v 1.116 2000/12/11 05:29:03 mycroft Exp $ */ /*- * Copyright (c) 1986, 1989, 1991, 1993 @@ -87,13 +87,17 @@ struct ps_strings; struct emul { char e_name[8]; /* Symbolic name */ const char *e_path; /* Extra emulation path (NULL if none)*/ +#ifndef __HAVE_MINIMAL_EMUL + int e_flags; /* Miscellaneous flags */ + /* Syscall handling function */ int *e_errno; /* Errno array */ /* Signal sending function */ - void (*e_sendsig) __P((sig_t, int, sigset_t *, u_long)); int e_nosys; /* Offset of the nosys() syscall */ int e_nsysent; /* Number of system call entries */ +#endif const struct sysent *e_sysent; /* System call array */ const char * const *e_syscallnames; /* System call name array */ + void (*e_sendsig) __P((sig_t, int, sigset_t *, u_long)); char *e_sigcode; /* Start of sigcode */ char *e_esigcode; /* End of sigcode */ @@ -102,10 +106,11 @@ struct emul { void (*e_proc_fork) __P((struct proc *p, struct proc *parent)); void (*e_proc_exit) __P((struct proc *)); - int e_flags; /* Miscellaneous flags */ - /* Syscall handling function */ +#ifdef __HAVE_SYSCALL_INTERN + void (*e_syscall_intern) __P((struct proc *)); +#else void (*e_syscall) __P((void)); - +#endif }; #define EMUL_HAS_SYS___syscall 0x001 /* has SYS___syscall */