From 7062f5b4c5b8eec746572528f80eb6e374d7975e Mon Sep 17 00:00:00 2001 From: Eirik Nygaard Date: Thu, 12 Aug 2004 19:59:31 +0000 Subject: [PATCH] Add message passed syscall's. Split up sendsys2() into two parts, sendsys2() and waitsys2(). sendsys2() will take care of the synchronous syscall's and initate asynchronous syscall's, and waitsys2() will wait for a asynchronous syscall to finish. Asynchronous syscall's can currently only be issued by the root user, but this limitation will be removed when the code becomes more stable and better tested. Add userland support for the synchronous and asynchronous sysmsg's to libcr. Libcr defaults to the use of synchronous sysmsg's now, but this will be changes as soon as we allow every user to do asynchronous sysmsg's. Add a limitation to the number of sysmsg's one proc can have running at any given time. This defaults to unlimited and can be changed with the kern.max_sysmsg sysctl. --- lib/libcr/Makefile | 4 +- lib/libcr/i386/SYS.h | 6 +- lib/libcr/i386/sys/Makefile.inc | 7 +- lib/libcr/i386/sys/__syscall.S | 4 + lib/libcr/include/syscall.h | 100 +++++++++ lib/libcr/sys/Makefile.inc | 9 +- lib/libcr/sys/gensyscall.awk | 138 +++++++++++++ sys/cpu/i386/include/segments.h | 4 +- sys/i386/i386/exception.s | 38 +++- sys/i386/i386/genassym.c | 3 +- sys/i386/i386/machdep.c | 7 +- sys/i386/i386/trap.c | 296 ++++++++++++++++++--------- sys/i386/include/segments.h | 4 +- sys/kern/init_sysent.c | 4 +- sys/kern/kern_sysmsg.c | 11 +- sys/kern/makesyscalls.sh | 18 +- sys/kern/syscalls.c | 4 +- sys/platform/pc32/i386/exception.s | 38 +++- sys/platform/pc32/i386/genassym.c | 3 +- sys/platform/pc32/i386/machdep.c | 7 +- sys/platform/pc32/i386/trap.c | 296 ++++++++++++++++++--------- sys/platform/vkernel/i386/genassym.c | 3 +- sys/sys/proc.h | 3 +- sys/sys/syscall-args | 256 +++++++++++++++++++++++ sys/sys/syscall-hide.h | 4 +- sys/sys/syscall.h | 4 +- sys/sys/syscall.mk | 4 +- sys/sys/sysmsg.h | 3 +- sys/sys/sysproto.h | 4 +- sys/sys/sysunion.h | 4 +- sys/sys/vmmeter.h | 5 +- usr.bin/truss/i386.conf | 3 +- usr.bin/truss/i386linux.conf | 3 +- 33 files changed, 1044 insertions(+), 253 deletions(-) create mode 100644 lib/libcr/i386/sys/__syscall.S create mode 100644 lib/libcr/include/syscall.h create mode 100644 lib/libcr/sys/gensyscall.awk create mode 100644 sys/sys/syscall-args diff --git a/lib/libcr/Makefile b/lib/libcr/Makefile index 4df0541e89..ccbfec20a3 100644 --- a/lib/libcr/Makefile +++ b/lib/libcr/Makefile @@ -1,6 +1,6 @@ # @(#)Makefile 8.2 (Berkeley) 2/3/94 # $FreeBSD: src/lib/libc/Makefile,v 1.24 1999/09/29 15:18:29 marcel Exp $ -# $DragonFly: src/lib/libcr/Attic/Makefile,v 1.3 2003/07/24 21:41:43 dillon Exp $ +# $DragonFly: src/lib/libcr/Attic/Makefile,v 1.4 2004/08/12 19:59:29 eirikn Exp $ # # All library objects contain rcsid strings by default; they may be # excluded as a space-saving measure. To produce a library that does @@ -16,6 +16,8 @@ CLEANFILES+=tags INSTALL_PIC_ARCHIVE= yes PRECIOUSLIB= yes +CFLAGS+=-g + # # Don't bother hiding any syscalls (like libc_r does). # diff --git a/lib/libcr/i386/SYS.h b/lib/libcr/i386/SYS.h index 775dd4acb4..105a44d8bd 100644 --- a/lib/libcr/i386/SYS.h +++ b/lib/libcr/i386/SYS.h @@ -36,7 +36,7 @@ * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 * * $FreeBSD: src/lib/libc/i386/SYS.h,v 1.17.2.2 2002/10/15 19:46:46 fjoe Exp $ - * $DragonFly: src/lib/libcr/i386/Attic/SYS.h,v 1.3 2004/04/25 12:40:48 joerg Exp $ + * $DragonFly: src/lib/libcr/i386/Attic/SYS.h,v 1.4 2004/08/12 19:59:29 eirikn Exp $ */ #include @@ -46,7 +46,9 @@ ENTRY(__CONCAT(_,x)); \ .weak CNAME(x); \ .set CNAME(x),CNAME(__CONCAT(_,x)); \ - lea __CONCAT(SYS_,x),%eax; KERNCALL; jb 2b + lea __CONCAT(SYS_,x),%eax; \ + KERNCALL; \ + jb 2b #define RSYSCALL(x) SYSCALL(x); ret diff --git a/lib/libcr/i386/sys/Makefile.inc b/lib/libcr/i386/sys/Makefile.inc index a611fd5cb1..995b002d32 100644 --- a/lib/libcr/i386/sys/Makefile.inc +++ b/lib/libcr/i386/sys/Makefile.inc @@ -1,19 +1,20 @@ # from: Makefile.inc,v 1.1 1993/09/03 19:04:23 jtc Exp # $FreeBSD: src/lib/libc/i386/sys/Makefile.inc,v 1.17.2.3 2002/10/15 19:46:46 fjoe Exp $ -# $DragonFly: src/lib/libcr/i386/sys/Attic/Makefile.inc,v 1.2 2003/06/17 04:26:43 dillon Exp $ +# $DragonFly: src/lib/libcr/i386/sys/Attic/Makefile.inc,v 1.3 2004/08/12 19:59:30 eirikn Exp $ SRCS+= i386_clr_watch.c i386_get_ioperm.c i386_get_ldt.c i386_set_ioperm.c \ i386_set_ldt.c i386_set_watch.c i386_vm86.c MDASM= Ovfork.S brk.S cerror.S exect.S fork.S pipe.S ptrace.S reboot.S \ - rfork.S sbrk.S setlogin.S sigreturn.S syscall.S + rfork.S sbrk.S setlogin.S sigreturn.S syscall.S __syscall.S # Don't generate default code for these syscalls: NOASM= __semctl.o break.o exit.o ftruncate.o getdomainname.o getlogin.o \ lseek.o mlockall.o mmap.o msgctl.o msgget.o msgrcv.o msgsnd.o \ munlockall.o openbsd_poll.o pread.o pwrite.o semconfig.o semget.o \ semop.o setdomainname.o shmat.o shmctl.o shmdt.o shmget.o sstk.o \ - thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o + thr_sleep.o thr_wakeup.o truncate.o uname.o vfork.o yield.o \ + __syscall.o PSEUDO= _getlogin.o diff --git a/lib/libcr/i386/sys/__syscall.S b/lib/libcr/i386/sys/__syscall.S new file mode 100644 index 0000000000..e29b792d33 --- /dev/null +++ b/lib/libcr/i386/sys/__syscall.S @@ -0,0 +1,4 @@ +/* $DragonFly: src/lib/libcr/i386/sys/Attic/__syscall.S,v 1.1 2004/08/12 19:59:30 eirikn Exp $ */ + +#include "SYS.h" +RSYSCALL(__syscall) diff --git a/lib/libcr/include/syscall.h b/lib/libcr/include/syscall.h new file mode 100644 index 0000000000..f5fbd34afb --- /dev/null +++ b/lib/libcr/include/syscall.h @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2004 Eirik Nygaard. All rights reserved. + * + * 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. Neither the name of The DragonFly Project 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 COPYRIGHT HOLDERS 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 + * COPYRIGHT HOLDERS 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/lib/libcr/include/Attic/syscall.h,v 1.1 2004/08/12 19:59:30 eirikn Exp $ + */ + +/* XXX: eirik */ +#define _MMAP_DECLARED +#define _LSEEK_DECLARED +#define _TRUNCATE_DECLARED +#define _FTRUNCATE_DECLARED + +#define __syscall_args nosys_args + +#include +#include +#include +#include + +#include +#include + +#define INITMSGSYSCALL(name, flags) do { \ + bzero(&__CONCAT(name, msg), sizeof(__CONCAT(name, msg))); \ + (__CONCAT(name, msg)).usrmsg.umsg.ms_cmd.cm_op = \ + (__CONCAT(SYS_,name)); \ + (__CONCAT(name, msg)).usrmsg.umsg.ms_flags = (flags); \ +} while (0) + +#define DOMSGSYSCALL(name) do { \ + error = sendsys(NULL, &__CONCAT(name,msg).usrmsg, \ + sizeof(__CONCAT(name,msg))); \ +} while (0) + +#define FINISHMSGSYSCALL(name, error) do { \ + if (__CONCAT(name,msg).usrmsg.umsg.ms_error == EASYNC) { \ + for (;;) { \ + int rmsg; \ + rmsg = waitsys(NULL, (void *)error, 0); \ + if (error == rmsg) \ + break; \ + else if (rmsg != 0) { \ + errno = rmsg; \ + return(-1); \ + } \ + } \ + } \ + else if (__CONCAT(name,msg).usrmsg.umsg.ms_error) { \ + errno = __CONCAT(name,msg).usrmsg.umsg.ms_error; \ + return(-1); \ + } \ + else \ + return(__CONCAT(name,msg).usrmsg.umsg.u.ms_result); \ +} while(0) + +static __inline int +sendsys(void *port, void *msg, int msgsize) +{ + int error; + + __asm __volatile("int $0x81" : "=a"(error), "=c"(msg), "=d"(msgsize) : + "0"(port), "1"(msg), "2"(msgsize) : "memory"); + return(error); +} + +static __inline int +waitsys(void *port, void *msg, int msgsize) +{ + int error; + + __asm __volatile("int $0x82" : "=a"(error), "=c"(msg), + "=d"(msgsize) : "0"(port), "1"(msg), "2"(msgsize) : + "memory"); + return(error); +} diff --git a/lib/libcr/sys/Makefile.inc b/lib/libcr/sys/Makefile.inc index 3161646570..8bf43eff62 100644 --- a/lib/libcr/sys/Makefile.inc +++ b/lib/libcr/sys/Makefile.inc @@ -1,6 +1,6 @@ # @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 # $FreeBSD: src/lib/libc/sys/Makefile.inc,v 1.75.2.7 2003/04/22 17:31:18 trhodes Exp $ -# $DragonFly: src/lib/libcr/sys/Attic/Makefile.inc,v 1.5 2004/01/22 12:01:18 eirikn Exp $ +# $DragonFly: src/lib/libcr/sys/Attic/Makefile.inc,v 1.6 2004/08/12 19:59:30 eirikn Exp $ # sys sources .PATH: ${.CURDIR}/../libcr/${MACHINE_ARCH}/sys ${.CURDIR}/../libcr/sys @@ -20,7 +20,7 @@ SRCS+= ftruncate.c lseek.c mmap.c pread.c pwrite.c truncate.c # Build __error() into libc, but not libc_r which has its own: -.if ${LIB} == "c" +.if ${LIB} == "c" || ${LIB} == "cr" SRCS+= __error.c .endif @@ -49,7 +49,7 @@ ASMR+=$(_asm) OBJS+= ${ASM} ${ASMR} ${PSEUDO} ${PSEUDOR} -SASM= ${ASM:S/.o/.S/} +SASM= ${ASM:S/.o/.c/} SASMR= ${ASMR:S/.o/.S/} @@ -64,7 +64,8 @@ CLEANFILES+= ${SASM} ${SASMR} ${SPSEUDO} ${SPSEUDOR} # Generate the syscalls source-files ${SASM}: - printf '#include "SYS.h"\nRSYSCALL(${.PREFIX})\n' > ${.TARGET} + awk -f ${.CURDIR}/sys/gensyscall.awk -v syscall=${.PREFIX} \ + ${.CURDIR}/../../sys/sys/syscall-args ${SASMR}: printf '#include "SYS.h"\nPRSYSCALL(${.PREFIX})\n' > ${.TARGET} diff --git a/lib/libcr/sys/gensyscall.awk b/lib/libcr/sys/gensyscall.awk new file mode 100644 index 0000000000..bc114df5e9 --- /dev/null +++ b/lib/libcr/sys/gensyscall.awk @@ -0,0 +1,138 @@ +# Copyright (c) 2004 Eirik Nygaard. All rights reserved. +# +# 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. Neither the name of The DragonFly Project 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 COPYRIGHT HOLDERS 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 +# COPYRIGHT HOLDERS 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/lib/libcr/sys/Attic/gensyscall.awk,v 1.1 2004/08/12 19:59:30 eirikn Exp $ + +BEGIN { + FS = "[\t]*"; + linenum = 0; +} +NF == 0 || $1 ~ /^;/ { + linenum++; + next; +} +$1 ~ /^#.*/ || $1 ~ /^[ ]*$/ || $1 ~ /^;/ { + linenum++; + next; +} +$2 == syscall { + outputfile = $2 ".c" + linenum++; + + fields = NF + functype = $1 + funcname = $2 + usefuncname = $3 + argalias = $4 + numargs = 0 + for (i = 5; i <= fields; i++) { + argtype[numargs] = $i + if (debug) { + printf "Argtype found: %s\n", $i + } + i++ + argname[numargs] = $i + if (debuf) { + printf "Argname found: %s\n", $i + } + numargs++ + } + if (usefuncname == "o" funcname) # Compat code + realfuncname = usefuncname + else + realfuncname = funcname + +# printf "Processing %s.c\n", realfuncname + if (NF < 2) { + printf "<#> Error in input file at line %d\n", linenum + exit 1 + } + print "/*" > outputfile + print " * Automatically generated and so on..." > outputfile + printf " * Userland part of syscall: %s()\n", realfuncname > outputfile + print " */\n" > outputfile + + print "#include \n" > outputfile + +# Actual syscall + printf "%s\n", functype > outputfile + printf "_%s", realfuncname > outputfile + printf "(" > outputfile + if (fields == 2) { + printf "void" > outputfile + } + else { + for (i = 0; i < numargs; i++) { + printf "%s ", argtype[i] > outputfile + printf "%s", argname[i] > outputfile + if (i != numargs - 1) + printf(", ") > outputfile + } + } + print ")" > outputfile + print "{" > outputfile + printf "\tstruct %s %smsg;\n", argalias, funcname > outputfile + print "\tint error;\n" > outputfile + printf "\tINITMSGSYSCALL(%s, 0);\n", funcname > outputfile + if (fields > 2) { + for (i = 0; i < numargs; i++) { + printf "\t%smsg.%s = %s;\n", funcname, argname[i], argname[i] > outputfile + } + } + printf "\tDOMSGSYSCALL(%s);\n", funcname > outputfile + printf "\tFINISHMSGSYSCALL(%s, error);\n", funcname > outputfile + print "}" > outputfile + +# Weak function + printf "__attribute__((weak))\n" > outputfile + printf "%s\n", functype > outputfile + printf "%s", realfuncname > outputfile + printf "(" > outputfile + if (fields == 2) { + printf "void" > outputfile + } + else { + for (i = 0; i < numargs; i++) { + printf "%s ", argtype[i] > outputfile + printf "%s", argname[i] > outputfile + if (i != numargs - 1) + printf(", ") > outputfile + } + } + print ")" > outputfile + print "{" > outputfile + printf "\treturn(_%s(", realfuncname > outputfile + for (i = 0; i < numargs; i++) { + printf "%s", argname[i] > outputfile + if (i != numargs - 1) + printf(", ") > outputfile + } + printf "));\n" > outputfile + print "}\n" > outputfile + + close(outputfile) +} diff --git a/sys/cpu/i386/include/segments.h b/sys/cpu/i386/include/segments.h index 4234209b52..b91d7bdb8e 100644 --- a/sys/cpu/i386/include/segments.h +++ b/sys/cpu/i386/include/segments.h @@ -36,7 +36,7 @@ * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/segments.h,v 1.24 1999/12/29 04:33:07 peter Exp $ - * $DragonFly: src/sys/cpu/i386/include/segments.h,v 1.6 2003/08/26 21:42:18 rob Exp $ + * $DragonFly: src/sys/cpu/i386/include/segments.h,v 1.7 2004/08/12 19:59:30 eirikn Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -198,7 +198,7 @@ struct region_descriptor { #if defined(SMP) || defined(APIC_IO) #define NIDT 256 /* we use them all */ #else -#define NIDT 130 /* 32 reserved, 16 h/w, 0 s/w, 0x80, 0x81 */ +#define NIDT 131 /* 32 reserved, 16 h/w, 0 s/w, 0x80, 0x81, 0x82 */ #endif /* SMP || APIC_IO */ #define NRSVIDT 32 /* reserved entries for cpu exceptions */ diff --git a/sys/i386/i386/exception.s b/sys/i386/i386/exception.s index 08ac86c259..df76ac2ed1 100644 --- a/sys/i386/i386/exception.s +++ b/sys/i386/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.22 2004/02/21 06:37:07 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/exception.s,v 1.23 2004/08/12 19:59:30 eirikn Exp $ */ #include "use_npx.h" @@ -864,12 +864,12 @@ IDTVEC(int0x80_syscall) jmp doreti /* - * Trap gate entry for FreeBSD syscall messaging interface (int 0x81). + * Trap gate entry for syscall messaging interface (int 0x81). * Arguments are passed in registers, the return value is placed in %eax. * * eax:error = int0x81(eax:port, ecx:msg, edx:msgsize) * - * Performs message sending, message and port waiting, and flushing + * Performs message sending and flushing * functinos. */ SUPERALIGN_TEXT @@ -896,6 +896,38 @@ IDTVEC(int0x81_syscall) pushl $0 /* cpl to restore */ jmp doreti +/* + * Trap gate entry for syscall messaging interface (int 0x82). + * Arguments are passed in registers, the return value is placed in %eax. + * + * eax:error = int0x82(eax:port, ecx:msg, edx:msgsize) + * + * Performs message and port waiting functions. + */ + SUPERALIGN_TEXT +IDTVEC(int0x82_syscall) + subl $8,%esp /* skip over tf_trapno and tf_err */ + pushal + pushl %ds + pushl %es + pushl %fs + mov $KDSEL,%ax /* switch to kernel segments */ + mov %ax,%ds + mov %ax,%es + mov $KPSEL,%ax + mov %ax,%fs + /* note: tf_err is not used */ + FAKE_MCOUNT(13*4(%esp)) + incl PCPU(cnt)+V_WAITSYS + /* warning, trap frame dummy arg, no extra reg pushes */ + call waitsys2 + MEXITCOUNT + cli /* atomic reqflags interlock w/irq */ + cmpl $0,PCPU(reqflags) + je doreti_syscall_ret + pushl $0 /* cpl to restore */ + jmp doreti + /* * This function is what cpu_heavy_restore jumps to after a new process * is created. The LWKT subsystem switches while holding a critical diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index df2af3d226..5b16edee3e 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.39 2004/05/05 19:26:38 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.40 2004/08/12 19:59:30 eirikn Exp $ */ #include @@ -108,6 +108,7 @@ ASSYM(SZOMB, SZOMB); ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys)); +ASSYM(V_WAITSYS, offsetof(struct vmmeter, v_waitsys)); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints)); ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits)); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 6bd5074297..7f1deb6f4a 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.64 2004/07/31 07:52:43 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.65 2004/08/12 19:59:30 eirikn Exp $ */ #include "use_apm.h" @@ -1284,7 +1284,8 @@ extern inthand_t IDTVEC(xmm), IDTVEC(syscall), IDTVEC(rsvd0); extern inthand_t - IDTVEC(int0x80_syscall), IDTVEC(int0x81_syscall); + IDTVEC(int0x80_syscall), IDTVEC(int0x81_syscall), + IDTVEC(int0x82_syscall); #ifdef DEBUG_INTERRUPTS extern inthand_t *Xrsvdary[256]; @@ -1904,6 +1905,8 @@ init386(int first) SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); setidt(0x81, &IDTVEC(int0x81_syscall), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); + setidt(0x82, &IDTVEC(int0x82_syscall), + SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); r_idt.rd_limit = sizeof(idt0) - 1; r_idt.rd_base = (int) idt; diff --git a/sys/i386/i386/trap.c b/sys/i386/i386/trap.c index c22ac3af28..c510bd56c1 100644 --- a/sys/i386/i386/trap.c +++ b/sys/i386/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.54 2004/07/24 20:21:33 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/trap.c,v 1.55 2004/08/12 19:59:30 eirikn Exp $ */ /* @@ -110,6 +110,7 @@ extern void trap (struct trapframe frame); extern int trapwrite (unsigned addr); extern void syscall2 (struct trapframe frame); extern void sendsys2 (struct trapframe frame); +extern void waitsys2 (struct trapframe frame); static int trap_pfault (struct trapframe *, int, vm_offset_t); static void trap_fatal (struct trapframe *, vm_offset_t); @@ -170,6 +171,7 @@ SYSCTL_INT(_machdep, OID_AUTO, slow_release, CTLFLAG_RW, &slow_release, 0, "Passive Release was nonoptimal"); MALLOC_DEFINE(M_SYSMSG, "sysmsg", "sysmsg structure"); +extern int max_sysmsg; /* * Passive USER->KERNEL transition. This only occurs if we block in the @@ -1291,10 +1293,10 @@ syscall2(struct trapframe frame) } code &= p->p_sysent->sv_mask; - if (code >= p->p_sysent->sv_size) - callp = &p->p_sysent->sv_table[0]; - else - callp = &p->p_sysent->sv_table[code]; + if (code >= p->p_sysent->sv_size) + callp = &p->p_sysent->sv_table[0]; + else + callp = &p->p_sysent->sv_table[code]; narg = callp->sy_narg & SYF_ARGMASK; @@ -1374,11 +1376,11 @@ syscall2(struct trapframe frame) panic("Unexpected EASYNC return value (for now)"); default: bad: - if (p->p_sysent->sv_errsize) { - if (error >= p->p_sysent->sv_errsize) - error = -1; /* XXX */ - else - error = p->p_sysent->sv_errtbl[error]; + if (p->p_sysent->sv_errsize) { + if (error >= p->p_sysent->sv_errsize) + error = -1; /* XXX */ + else + error = p->p_sysent->sv_errtbl[error]; } frame.tf_eax = error; frame.tf_eflags |= PSL_C; @@ -1421,6 +1423,20 @@ bad: #endif } +/* + * free_sysun - Put an unused sysun on the free list. + */ +static __inline void +free_sysun(struct thread *td, union sysunion *sysun) +{ + struct globaldata *gd = td->td_gd; + + crit_enter_quick(td); + sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; + gd->gd_freesysun = sysun; + crit_exit_quick(td); +} + /* * sendsys2 - MP aware system message request C handler */ @@ -1432,7 +1448,7 @@ sendsys2(struct trapframe frame) struct proc *p = td->td_proc; register_t orig_tf_eflags; struct sysent *callp; - union sysunion *sysun; + union sysunion *sysun = NULL; lwkt_msg_t umsg; int sticks; int error; @@ -1444,7 +1460,7 @@ sendsys2(struct trapframe frame) #ifdef DIAGNOSTIC if (ISPL(frame.tf_cs) != SEL_UPL) { get_mplock(); - panic("syscall"); + panic("sendsys"); /* NOT REACHED */ } #endif @@ -1465,65 +1481,6 @@ sendsys2(struct trapframe frame) orig_tf_eflags = frame.tf_eflags; result = 0; - /* - * Handle the waitport/waitmsg/checkport/checkmsg case - * - * YYY MOVE THIS TO INT 0x82! We don't really need to combine it - * with sendsys(). - */ - if ((msgsize = frame.tf_edx) <= 0) { - if (frame.tf_ecx) { - printf("waitmsg/checkmsg not yet supported: %08x\n", - frame.tf_ecx); - error = ENOTSUP; - goto bad2; - } - if (frame.tf_eax) { - printf("waitport/checkport only the default port is supported at the moment\n"); - error = ENOTSUP; - goto bad2; - } - switch(msgsize) { - case 0: - sysun = (void *)sysmsg_wait(p, NULL, 0); - break; - case -1: - sysun = (void *)sysmsg_wait(p, NULL, 1); - break; - default: - error = ENOSYS; - goto bad2; - } - if (sysun) { - gd = td->td_gd; - umsg = sysun->lmsg.opaque.ms_umsg; - frame.tf_eax = (register_t)umsg; - if (sysun->sysmsg_copyout) - sysun->sysmsg_copyout(sysun); - sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; - sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; - sysun->nosys.usrmsg.umsg.ms_error = sysun->lmsg.ms_error; - error = sysun->lmsg.ms_error; - result = sysun->lmsg.u.ms_fds[0]; /* for ktrace */ - if (error != 0 || code != SYS_execve) { - error = copyout( - &sysun->nosys.usrmsg.umsg.ms_copyout_start, - &umsg->ms_copyout_start, - ms_copyout_size); - } - crit_enter_quick(td); - sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; - gd->gd_freesysun = sysun; - crit_exit_quick(td); - } else { - frame.tf_eax = 0; - } - frame.tf_edx = 0; - code = 0; - error = 0; - goto good; - } - /* * Extract the system call message. If msgsize is zero we are * blocking on a message and/or message port. If msgsize is -1 @@ -1539,9 +1496,8 @@ sendsys2(struct trapframe frame) /* * Bad message size */ - if (msgsize < sizeof(struct lwkt_msg) || - msgsize > sizeof(union sysunion) - sizeof(struct sysmsg) - ) { + if ((msgsize = frame.tf_edx) < sizeof(struct lwkt_msg) || + msgsize > sizeof(union sysunion) - sizeof(struct sysmsg)) { error = ENOSYS; goto bad2; } @@ -1554,13 +1510,11 @@ sendsys2(struct trapframe frame) */ gd = td->td_gd; crit_enter_quick(td); - if ((sysun = gd->gd_freesysun) != NULL) { + if ((sysun = gd->gd_freesysun) != NULL) gd->gd_freesysun = sysun->lmsg.opaque.ms_sysunnext; - crit_exit_quick(td); - } else { - crit_exit_quick(td); + else sysun = malloc(sizeof(union sysunion), M_SYSMSG, M_WAITOK); - } + crit_exit_quick(td); /* * Copy the user request into the kernel copy of the user request. @@ -1569,10 +1523,15 @@ sendsys2(struct trapframe frame) error = copyin(umsg, &sysun->nosys.usrmsg, msgsize); if (error) goto bad1; - if ((sysun->nosys.usrmsg.umsg.ms_flags & MSGF_ASYNC) && - (error = suser(td)) != 0 - ) { - goto bad1; + if ((sysun->nosys.usrmsg.umsg.ms_flags & MSGF_ASYNC)) { + error = suser(td); + if (error) { + goto bad1; + } + if (max_sysmsg > 0 && p->p_num_sysmsg >= max_sysmsg) { + error = E2BIG; + goto bad1; + } } /* @@ -1595,8 +1554,15 @@ sendsys2(struct trapframe frame) * set the default return value. */ code = (u_int)sysun->lmsg.ms_cmd.cm_op; + /* We don't handle the syscall() syscall yet */ + if (code == 0) { + error = ENOTSUP; + free_sysun(td, sysun); + goto bad2; + } if (code >= p->p_sysent->sv_size) { error = ENOSYS; + free_sysun(td, sysun); goto bad1; } @@ -1634,6 +1600,18 @@ bad1: * * YYY Don't writeback message if execve() YYY */ + sysun->nosys.usrmsg.umsg.ms_error = error; + sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; + sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; + result = sysun->nosys.usrmsg.umsg.u.ms_fds[0]; /* for ktrace */ + if (error != 0 || code != SYS_execve) { + int error2; + error2 = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, + &umsg->ms_copyout_start, + ms_copyout_size); + if (error2 != 0) + error = error2; + } if (error == EASYNC) { /* * Since only the current process ever messes with msgq, @@ -1641,26 +1619,14 @@ bad1: * operation. */ TAILQ_INSERT_TAIL(&p->p_sysmsgq, &sysun->sysmsg, msgq); - } else { - sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; - sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; - result = sysun->nosys.usrmsg.umsg.u.ms_fds[0]; /* for ktrace */ - if (error != 0 || code != SYS_execve) { - int error2; - error2 = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, - &umsg->ms_copyout_start, - ms_copyout_size); - if (error == 0) - error2 = error; - } - crit_enter_quick(td); - sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; - gd->gd_freesysun = sysun; - crit_exit_quick(td); + p->p_num_sysmsg++; + error = (int)&sysun->sysmsg; + } + else { + free_sysun(td, sysun); } bad2: - frame.tf_eax = error; -good: + frame.tf_eax = (register_t)error; /* * Traced syscall. trapsignal() is not MP aware. @@ -1698,6 +1664,133 @@ good: #endif } +/* + * waitsys2 - MP aware system message wait C handler + */ +void +waitsys2(struct trapframe frame) +{ + struct globaldata *gd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + union sysunion *sysun = NULL; + lwkt_msg_t umsg; + register_t orig_tf_eflags; + int error = 0, result, sticks; + u_int code = 0; + +#ifdef DIAGNOSTIC + if (ISPL(frame.tf_cs) != SEL_UPL) { + get_mplock(); + panic("waitsys2"); + /* NOT REACHED */ + } +#endif + +#ifdef SMP + KASSERT(td->td_mpcount == 0, ("badmpcount syscall from %p", + (void *)frame.tf_eip)); + get_mplock(); +#endif + + /* + * access non-atomic field from critical section. p_sticks is + * updated by the clock interrupt. Also use this opportunity + * to lazy-raise our LWKT priority. + */ + userenter(td); + sticks = td->td_sticks; + + p->p_md.md_regs = &frame; + orig_tf_eflags = frame.tf_eflags; + result = 0; + + if (frame.tf_ecx) { + struct sysmsg *ptr; + int found = 0; + TAILQ_FOREACH(ptr, &p->p_sysmsgq, msgq) { + if ((void *)ptr == (void *)frame.tf_ecx) { + sysun = (void *)sysmsg_wait(p, + (void *)frame.tf_ecx, 1); + found = 1; + break; + } + } + if (!found) { + error = ENOENT; + goto bad; + } + } + else if (frame.tf_eax) { + printf("waitport/checkport only the default port is supported at the moment\n"); + error = ENOTSUP; + goto bad; + } + else { + switch(frame.tf_edx) { + case 0: + sysun = (void *)sysmsg_wait(p, NULL, 0); + break; + case -1: + sysun = (void *)sysmsg_wait(p, NULL, 1); + break; + default: + error = ENOSYS; + goto bad; + } + } + if (sysun) { + gd = td->td_gd; + umsg = sysun->lmsg.opaque.ms_umsg; + frame.tf_eax = (register_t)sysun; + sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; + sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; + sysun->nosys.usrmsg.umsg.ms_error = sysun->lmsg.ms_error; + error = sysun->lmsg.ms_error; + result = sysun->lmsg.u.ms_fds[0]; /* for ktrace */ + error = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, + &umsg->ms_copyout_start, ms_copyout_size); + free_sysun(td, sysun); + frame.tf_edx = 0; + code = (u_int)sysun->lmsg.ms_cmd.cm_op; + } +bad: + if (error) + frame.tf_eax = error; + /* + * Traced syscall. trapsignal() is not MP aware. + */ + if ((orig_tf_eflags & PSL_T) && !(orig_tf_eflags & PSL_VM)) { + frame.tf_eflags &= ~PSL_T; + trapsignal(p, SIGTRAP, 0); + } + + /* + * Handle reschedule and other end-of-syscall issues + */ + userret(p, &frame, sticks); + +#ifdef KTRACE + if (KTRPOINT(td, KTR_SYSRET)) { + ktrsysret(p->p_tracep, code, error, result); + } +#endif + + /* + * This works because errno is findable through the + * register set. If we ever support an emulation where this + * is not the case, this code will need to be revisited. + */ + STOPEVENT(p, S_SCX, code); + + userexit(p); +#ifdef SMP + KASSERT(td->td_mpcount == 1, ("badmpcount syscall from %p", + (void *)frame.tf_eip)); + rel_mplock(); +#endif +} + /* * Simplified back end of syscall(), used when returning from fork() * directly into user mode. MP lock is held on entry and should be @@ -1726,4 +1819,3 @@ fork_return(p, frame) rel_mplock(); #endif } - diff --git a/sys/i386/include/segments.h b/sys/i386/include/segments.h index e08ada6188..9e0d822857 100644 --- a/sys/i386/include/segments.h +++ b/sys/i386/include/segments.h @@ -36,7 +36,7 @@ * * from: @(#)segments.h 7.1 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/include/segments.h,v 1.24 1999/12/29 04:33:07 peter Exp $ - * $DragonFly: src/sys/i386/include/Attic/segments.h,v 1.6 2003/08/26 21:42:18 rob Exp $ + * $DragonFly: src/sys/i386/include/Attic/segments.h,v 1.7 2004/08/12 19:59:30 eirikn Exp $ */ #ifndef _MACHINE_SEGMENTS_H_ @@ -198,7 +198,7 @@ struct region_descriptor { #if defined(SMP) || defined(APIC_IO) #define NIDT 256 /* we use them all */ #else -#define NIDT 130 /* 32 reserved, 16 h/w, 0 s/w, 0x80, 0x81 */ +#define NIDT 131 /* 32 reserved, 16 h/w, 0 s/w, 0x80, 0x81, 0x82 */ #endif /* SMP || APIC_IO */ #define NRSVIDT 32 /* reserved entries for cpu exceptions */ diff --git a/sys/kern/init_sysent.c b/sys/kern/init_sysent.c index 4f9710cbc3..91c862e9f1 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.16 2004/03/06 22:14:09 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/kern/init_sysent.c,v 1.17 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ #include "opt_compat.h" diff --git a/sys/kern/kern_sysmsg.c b/sys/kern/kern_sysmsg.c index 18c71289b4..b3cbe1b20d 100644 --- a/sys/kern/kern_sysmsg.c +++ b/sys/kern/kern_sysmsg.c @@ -31,7 +31,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/Attic/kern_sysmsg.c,v 1.3 2004/07/16 05:51:10 dillon Exp $ + * $DragonFly: src/sys/kern/Attic/kern_sysmsg.c,v 1.4 2004/08/12 19:59:30 eirikn Exp $ */ /* @@ -81,6 +81,14 @@ #include #include +/* + * Sysctl to limit max in progress syscall messages per process. 0 for + * unlimited. + */ +int max_sysmsg = 0; +SYSCTL_INT(_kern, OID_AUTO, max_sysmsg, CTLFLAG_RW, &max_sysmsg, 0, + "Max sysmsg's a process can have running"); + /* * Wait for a system call message to be returned. If NULL is passed we * wait for the next ready sysmsg and return it. We return NULL if there @@ -116,6 +124,7 @@ sysmsg_wait(struct proc *p, struct sysmsg *sysmsg, int nonblock) * sysmsg is not NULL here */ TAILQ_REMOVE(&p->p_sysmsgq, sysmsg, msgq); + p->p_num_sysmsg--; return(sysmsg); } diff --git a/sys/kern/makesyscalls.sh b/sys/kern/makesyscalls.sh index d543765099..ae73c90ee1 100644 --- a/sys/kern/makesyscalls.sh +++ b/sys/kern/makesyscalls.sh @@ -1,7 +1,7 @@ #! /bin/sh - # @(#)makesyscalls.sh 8.1 (Berkeley) 6/10/93 # $FreeBSD: src/sys/kern/makesyscalls.sh,v 1.39.2.4 2001/10/20 09:01:24 marcel Exp $ -# $DragonFly: src/sys/kern/makesyscalls.sh,v 1.10 2003/11/20 06:05:30 dillon Exp $ +# $DragonFly: src/sys/kern/makesyscalls.sh,v 1.11 2004/08/12 19:59:30 eirikn Exp $ set -e @@ -17,6 +17,7 @@ syshdr="../sys/syscall.h" sysmk="../sys/syscall.mk" syssw="init_sysent.c" syshide="../sys/syscall-hide.h" +sysargs="../sys/syscall-args" syscallprefix="SYS_" switchname="sysent" namesname="syscallnames" @@ -77,6 +78,7 @@ s/\$//g switchname = \"$switchname\" namesname = \"$namesname\" infile = \"$1\" + sysargs = \"$sysargs\" "' printf "/*\n * System call switch table.\n *\n" > syssw @@ -108,6 +110,10 @@ s/\$//g printf " * \$\DragonFly\$\n" > sysun printf "\n#ifdef _KERNEL\n\n" > sysdcl printf "\n#ifdef _KERNEL\n\n" > syscompatdcl + + printf "# System call argument table.\n" > sysargs + printf "# DO NOT EDIT-- this file is automatically generated.\n" > sysargs + printf "# \$\DragonFly\$\n" > sysargs } NR == 1 { gsub("[$]DragonFly: ", "", $0) @@ -142,6 +148,8 @@ s/\$//g printf "\tstruct\tlwkt_msg lmsg;\n" > sysun printf "\tstruct\tsysmsg sysmsg;\n" > sysun printf "#endif\n" > sysun + + printf "\n# Created from%s\n\n", $0 > sysargs next } NF == 0 || $1 ~ /^;/ { @@ -352,6 +360,10 @@ s/\$//g printf("#define\t%s%s\t%d\n", syscallprefix, funcalias, syscall) > syshdr printf(" \\\n\t%s.o", funcalias) > sysmk + printf("%s\t%s\t%s\t%s", rettype, funcalias, usefuncname, argalias) > sysargs + for (i = 1; i <= argc; i++) + printf("\t%s\t%s", argtype[i], argname[i]) > sysargs + printf("\n") > sysargs } if ($3 != "NOHIDE") printf("HIDE_%s(%s)\n", $3, funcname) > syshide @@ -416,6 +428,10 @@ s/\$//g printf("#define\t%s%s\t%d\t/* compatibility; still used by libc */\n", syscallprefix, funcalias, syscall) > syshdr printf(" \\\n\t%s.o", funcalias) > sysmk + printf("%s\t%s\t%s\t%s", rettype, funcalias, usefuncname, argalias) > sysargs + for (i = 1; i <= argc; i++) + printf("\t%s\t%s", argtype[i], argname[i]) > sysargs + printf("\n") > sysargs if ($3 != "NOHIDE") printf("HIDE_%s(%s)\n", $3, funcname) > syshide syscall++ diff --git a/sys/kern/syscalls.c b/sys/kern/syscalls.c index 11cb1409db..18d51a5d74 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.16 2004/03/06 22:14:09 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/kern/syscalls.c,v 1.17 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ char *syscallnames[] = { diff --git a/sys/platform/pc32/i386/exception.s b/sys/platform/pc32/i386/exception.s index 030efa9039..ceeba40a5e 100644 --- a/sys/platform/pc32/i386/exception.s +++ b/sys/platform/pc32/i386/exception.s @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/i386/i386/exception.s,v 1.65.2.3 2001/08/15 01:23:49 peter Exp $ - * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.22 2004/02/21 06:37:07 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/exception.s,v 1.23 2004/08/12 19:59:30 eirikn Exp $ */ #include "use_npx.h" @@ -864,12 +864,12 @@ IDTVEC(int0x80_syscall) jmp doreti /* - * Trap gate entry for FreeBSD syscall messaging interface (int 0x81). + * Trap gate entry for syscall messaging interface (int 0x81). * Arguments are passed in registers, the return value is placed in %eax. * * eax:error = int0x81(eax:port, ecx:msg, edx:msgsize) * - * Performs message sending, message and port waiting, and flushing + * Performs message sending and flushing * functinos. */ SUPERALIGN_TEXT @@ -896,6 +896,38 @@ IDTVEC(int0x81_syscall) pushl $0 /* cpl to restore */ jmp doreti +/* + * Trap gate entry for syscall messaging interface (int 0x82). + * Arguments are passed in registers, the return value is placed in %eax. + * + * eax:error = int0x82(eax:port, ecx:msg, edx:msgsize) + * + * Performs message and port waiting functions. + */ + SUPERALIGN_TEXT +IDTVEC(int0x82_syscall) + subl $8,%esp /* skip over tf_trapno and tf_err */ + pushal + pushl %ds + pushl %es + pushl %fs + mov $KDSEL,%ax /* switch to kernel segments */ + mov %ax,%ds + mov %ax,%es + mov $KPSEL,%ax + mov %ax,%fs + /* note: tf_err is not used */ + FAKE_MCOUNT(13*4(%esp)) + incl PCPU(cnt)+V_WAITSYS + /* warning, trap frame dummy arg, no extra reg pushes */ + call waitsys2 + MEXITCOUNT + cli /* atomic reqflags interlock w/irq */ + cmpl $0,PCPU(reqflags) + je doreti_syscall_ret + pushl $0 /* cpl to restore */ + jmp doreti + /* * This function is what cpu_heavy_restore jumps to after a new process * is created. The LWKT subsystem switches while holding a critical diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index 9a40401d93..9ffb22ca4c 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.39 2004/05/05 19:26:38 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.40 2004/08/12 19:59:30 eirikn Exp $ */ #include @@ -108,6 +108,7 @@ ASSYM(SZOMB, SZOMB); ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys)); +ASSYM(V_WAITSYS, offsetof(struct vmmeter, v_waitsys)); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints)); ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits)); diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index db64cdcc92..fc07bd533b 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.64 2004/07/31 07:52:43 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.65 2004/08/12 19:59:30 eirikn Exp $ */ #include "use_apm.h" @@ -1284,7 +1284,8 @@ extern inthand_t IDTVEC(xmm), IDTVEC(syscall), IDTVEC(rsvd0); extern inthand_t - IDTVEC(int0x80_syscall), IDTVEC(int0x81_syscall); + IDTVEC(int0x80_syscall), IDTVEC(int0x81_syscall), + IDTVEC(int0x82_syscall); #ifdef DEBUG_INTERRUPTS extern inthand_t *Xrsvdary[256]; @@ -1904,6 +1905,8 @@ init386(int first) SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); setidt(0x81, &IDTVEC(int0x81_syscall), SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); + setidt(0x82, &IDTVEC(int0x82_syscall), + SDT_SYS386TGT, SEL_UPL, GSEL(GCODE_SEL, SEL_KPL)); r_idt.rd_limit = sizeof(idt0) - 1; r_idt.rd_base = (int) idt; diff --git a/sys/platform/pc32/i386/trap.c b/sys/platform/pc32/i386/trap.c index 30cc8019de..cbe77541b3 100644 --- a/sys/platform/pc32/i386/trap.c +++ b/sys/platform/pc32/i386/trap.c @@ -36,7 +36,7 @@ * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/i386/trap.c,v 1.147.2.11 2003/02/27 19:09:59 luoqi Exp $ - * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.54 2004/07/24 20:21:33 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/trap.c,v 1.55 2004/08/12 19:59:30 eirikn Exp $ */ /* @@ -110,6 +110,7 @@ extern void trap (struct trapframe frame); extern int trapwrite (unsigned addr); extern void syscall2 (struct trapframe frame); extern void sendsys2 (struct trapframe frame); +extern void waitsys2 (struct trapframe frame); static int trap_pfault (struct trapframe *, int, vm_offset_t); static void trap_fatal (struct trapframe *, vm_offset_t); @@ -170,6 +171,7 @@ SYSCTL_INT(_machdep, OID_AUTO, slow_release, CTLFLAG_RW, &slow_release, 0, "Passive Release was nonoptimal"); MALLOC_DEFINE(M_SYSMSG, "sysmsg", "sysmsg structure"); +extern int max_sysmsg; /* * Passive USER->KERNEL transition. This only occurs if we block in the @@ -1291,10 +1293,10 @@ syscall2(struct trapframe frame) } code &= p->p_sysent->sv_mask; - if (code >= p->p_sysent->sv_size) - callp = &p->p_sysent->sv_table[0]; - else - callp = &p->p_sysent->sv_table[code]; + if (code >= p->p_sysent->sv_size) + callp = &p->p_sysent->sv_table[0]; + else + callp = &p->p_sysent->sv_table[code]; narg = callp->sy_narg & SYF_ARGMASK; @@ -1374,11 +1376,11 @@ syscall2(struct trapframe frame) panic("Unexpected EASYNC return value (for now)"); default: bad: - if (p->p_sysent->sv_errsize) { - if (error >= p->p_sysent->sv_errsize) - error = -1; /* XXX */ - else - error = p->p_sysent->sv_errtbl[error]; + if (p->p_sysent->sv_errsize) { + if (error >= p->p_sysent->sv_errsize) + error = -1; /* XXX */ + else + error = p->p_sysent->sv_errtbl[error]; } frame.tf_eax = error; frame.tf_eflags |= PSL_C; @@ -1421,6 +1423,20 @@ bad: #endif } +/* + * free_sysun - Put an unused sysun on the free list. + */ +static __inline void +free_sysun(struct thread *td, union sysunion *sysun) +{ + struct globaldata *gd = td->td_gd; + + crit_enter_quick(td); + sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; + gd->gd_freesysun = sysun; + crit_exit_quick(td); +} + /* * sendsys2 - MP aware system message request C handler */ @@ -1432,7 +1448,7 @@ sendsys2(struct trapframe frame) struct proc *p = td->td_proc; register_t orig_tf_eflags; struct sysent *callp; - union sysunion *sysun; + union sysunion *sysun = NULL; lwkt_msg_t umsg; int sticks; int error; @@ -1444,7 +1460,7 @@ sendsys2(struct trapframe frame) #ifdef DIAGNOSTIC if (ISPL(frame.tf_cs) != SEL_UPL) { get_mplock(); - panic("syscall"); + panic("sendsys"); /* NOT REACHED */ } #endif @@ -1465,65 +1481,6 @@ sendsys2(struct trapframe frame) orig_tf_eflags = frame.tf_eflags; result = 0; - /* - * Handle the waitport/waitmsg/checkport/checkmsg case - * - * YYY MOVE THIS TO INT 0x82! We don't really need to combine it - * with sendsys(). - */ - if ((msgsize = frame.tf_edx) <= 0) { - if (frame.tf_ecx) { - printf("waitmsg/checkmsg not yet supported: %08x\n", - frame.tf_ecx); - error = ENOTSUP; - goto bad2; - } - if (frame.tf_eax) { - printf("waitport/checkport only the default port is supported at the moment\n"); - error = ENOTSUP; - goto bad2; - } - switch(msgsize) { - case 0: - sysun = (void *)sysmsg_wait(p, NULL, 0); - break; - case -1: - sysun = (void *)sysmsg_wait(p, NULL, 1); - break; - default: - error = ENOSYS; - goto bad2; - } - if (sysun) { - gd = td->td_gd; - umsg = sysun->lmsg.opaque.ms_umsg; - frame.tf_eax = (register_t)umsg; - if (sysun->sysmsg_copyout) - sysun->sysmsg_copyout(sysun); - sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; - sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; - sysun->nosys.usrmsg.umsg.ms_error = sysun->lmsg.ms_error; - error = sysun->lmsg.ms_error; - result = sysun->lmsg.u.ms_fds[0]; /* for ktrace */ - if (error != 0 || code != SYS_execve) { - error = copyout( - &sysun->nosys.usrmsg.umsg.ms_copyout_start, - &umsg->ms_copyout_start, - ms_copyout_size); - } - crit_enter_quick(td); - sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; - gd->gd_freesysun = sysun; - crit_exit_quick(td); - } else { - frame.tf_eax = 0; - } - frame.tf_edx = 0; - code = 0; - error = 0; - goto good; - } - /* * Extract the system call message. If msgsize is zero we are * blocking on a message and/or message port. If msgsize is -1 @@ -1539,9 +1496,8 @@ sendsys2(struct trapframe frame) /* * Bad message size */ - if (msgsize < sizeof(struct lwkt_msg) || - msgsize > sizeof(union sysunion) - sizeof(struct sysmsg) - ) { + if ((msgsize = frame.tf_edx) < sizeof(struct lwkt_msg) || + msgsize > sizeof(union sysunion) - sizeof(struct sysmsg)) { error = ENOSYS; goto bad2; } @@ -1554,13 +1510,11 @@ sendsys2(struct trapframe frame) */ gd = td->td_gd; crit_enter_quick(td); - if ((sysun = gd->gd_freesysun) != NULL) { + if ((sysun = gd->gd_freesysun) != NULL) gd->gd_freesysun = sysun->lmsg.opaque.ms_sysunnext; - crit_exit_quick(td); - } else { - crit_exit_quick(td); + else sysun = malloc(sizeof(union sysunion), M_SYSMSG, M_WAITOK); - } + crit_exit_quick(td); /* * Copy the user request into the kernel copy of the user request. @@ -1569,10 +1523,15 @@ sendsys2(struct trapframe frame) error = copyin(umsg, &sysun->nosys.usrmsg, msgsize); if (error) goto bad1; - if ((sysun->nosys.usrmsg.umsg.ms_flags & MSGF_ASYNC) && - (error = suser(td)) != 0 - ) { - goto bad1; + if ((sysun->nosys.usrmsg.umsg.ms_flags & MSGF_ASYNC)) { + error = suser(td); + if (error) { + goto bad1; + } + if (max_sysmsg > 0 && p->p_num_sysmsg >= max_sysmsg) { + error = E2BIG; + goto bad1; + } } /* @@ -1595,8 +1554,15 @@ sendsys2(struct trapframe frame) * set the default return value. */ code = (u_int)sysun->lmsg.ms_cmd.cm_op; + /* We don't handle the syscall() syscall yet */ + if (code == 0) { + error = ENOTSUP; + free_sysun(td, sysun); + goto bad2; + } if (code >= p->p_sysent->sv_size) { error = ENOSYS; + free_sysun(td, sysun); goto bad1; } @@ -1634,6 +1600,18 @@ bad1: * * YYY Don't writeback message if execve() YYY */ + sysun->nosys.usrmsg.umsg.ms_error = error; + sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; + sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; + result = sysun->nosys.usrmsg.umsg.u.ms_fds[0]; /* for ktrace */ + if (error != 0 || code != SYS_execve) { + int error2; + error2 = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, + &umsg->ms_copyout_start, + ms_copyout_size); + if (error2 != 0) + error = error2; + } if (error == EASYNC) { /* * Since only the current process ever messes with msgq, @@ -1641,26 +1619,14 @@ bad1: * operation. */ TAILQ_INSERT_TAIL(&p->p_sysmsgq, &sysun->sysmsg, msgq); - } else { - sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; - sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; - result = sysun->nosys.usrmsg.umsg.u.ms_fds[0]; /* for ktrace */ - if (error != 0 || code != SYS_execve) { - int error2; - error2 = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, - &umsg->ms_copyout_start, - ms_copyout_size); - if (error == 0) - error2 = error; - } - crit_enter_quick(td); - sysun->lmsg.opaque.ms_sysunnext = gd->gd_freesysun; - gd->gd_freesysun = sysun; - crit_exit_quick(td); + p->p_num_sysmsg++; + error = (int)&sysun->sysmsg; + } + else { + free_sysun(td, sysun); } bad2: - frame.tf_eax = error; -good: + frame.tf_eax = (register_t)error; /* * Traced syscall. trapsignal() is not MP aware. @@ -1698,6 +1664,133 @@ good: #endif } +/* + * waitsys2 - MP aware system message wait C handler + */ +void +waitsys2(struct trapframe frame) +{ + struct globaldata *gd; + struct thread *td = curthread; + struct proc *p = td->td_proc; + union sysunion *sysun = NULL; + lwkt_msg_t umsg; + register_t orig_tf_eflags; + int error = 0, result, sticks; + u_int code = 0; + +#ifdef DIAGNOSTIC + if (ISPL(frame.tf_cs) != SEL_UPL) { + get_mplock(); + panic("waitsys2"); + /* NOT REACHED */ + } +#endif + +#ifdef SMP + KASSERT(td->td_mpcount == 0, ("badmpcount syscall from %p", + (void *)frame.tf_eip)); + get_mplock(); +#endif + + /* + * access non-atomic field from critical section. p_sticks is + * updated by the clock interrupt. Also use this opportunity + * to lazy-raise our LWKT priority. + */ + userenter(td); + sticks = td->td_sticks; + + p->p_md.md_regs = &frame; + orig_tf_eflags = frame.tf_eflags; + result = 0; + + if (frame.tf_ecx) { + struct sysmsg *ptr; + int found = 0; + TAILQ_FOREACH(ptr, &p->p_sysmsgq, msgq) { + if ((void *)ptr == (void *)frame.tf_ecx) { + sysun = (void *)sysmsg_wait(p, + (void *)frame.tf_ecx, 1); + found = 1; + break; + } + } + if (!found) { + error = ENOENT; + goto bad; + } + } + else if (frame.tf_eax) { + printf("waitport/checkport only the default port is supported at the moment\n"); + error = ENOTSUP; + goto bad; + } + else { + switch(frame.tf_edx) { + case 0: + sysun = (void *)sysmsg_wait(p, NULL, 0); + break; + case -1: + sysun = (void *)sysmsg_wait(p, NULL, 1); + break; + default: + error = ENOSYS; + goto bad; + } + } + if (sysun) { + gd = td->td_gd; + umsg = sysun->lmsg.opaque.ms_umsg; + frame.tf_eax = (register_t)sysun; + sysun->nosys.usrmsg.umsg.u.ms_fds[0] = sysun->lmsg.u.ms_fds[0]; + sysun->nosys.usrmsg.umsg.u.ms_fds[1] = sysun->lmsg.u.ms_fds[1]; + sysun->nosys.usrmsg.umsg.ms_error = sysun->lmsg.ms_error; + error = sysun->lmsg.ms_error; + result = sysun->lmsg.u.ms_fds[0]; /* for ktrace */ + error = copyout(&sysun->nosys.usrmsg.umsg.ms_copyout_start, + &umsg->ms_copyout_start, ms_copyout_size); + free_sysun(td, sysun); + frame.tf_edx = 0; + code = (u_int)sysun->lmsg.ms_cmd.cm_op; + } +bad: + if (error) + frame.tf_eax = error; + /* + * Traced syscall. trapsignal() is not MP aware. + */ + if ((orig_tf_eflags & PSL_T) && !(orig_tf_eflags & PSL_VM)) { + frame.tf_eflags &= ~PSL_T; + trapsignal(p, SIGTRAP, 0); + } + + /* + * Handle reschedule and other end-of-syscall issues + */ + userret(p, &frame, sticks); + +#ifdef KTRACE + if (KTRPOINT(td, KTR_SYSRET)) { + ktrsysret(p->p_tracep, code, error, result); + } +#endif + + /* + * This works because errno is findable through the + * register set. If we ever support an emulation where this + * is not the case, this code will need to be revisited. + */ + STOPEVENT(p, S_SCX, code); + + userexit(p); +#ifdef SMP + KASSERT(td->td_mpcount == 1, ("badmpcount syscall from %p", + (void *)frame.tf_eip)); + rel_mplock(); +#endif +} + /* * Simplified back end of syscall(), used when returning from fork() * directly into user mode. MP lock is held on entry and should be @@ -1726,4 +1819,3 @@ fork_return(p, frame) rel_mplock(); #endif } - diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index abb7d7d5dd..5e0de8fd4b 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.39 2004/05/05 19:26:38 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.40 2004/08/12 19:59:30 eirikn Exp $ */ #include @@ -108,6 +108,7 @@ ASSYM(SZOMB, SZOMB); ASSYM(V_TRAP, offsetof(struct vmmeter, v_trap)); ASSYM(V_SYSCALL, offsetof(struct vmmeter, v_syscall)); ASSYM(V_SENDSYS, offsetof(struct vmmeter, v_sendsys)); +ASSYM(V_WAITSYS, offsetof(struct vmmeter, v_waitsys)); ASSYM(V_INTR, offsetof(struct vmmeter, v_intr)); ASSYM(V_FORWARDED_INTS, offsetof(struct vmmeter, v_forwarded_ints)); ASSYM(V_FORWARDED_HITS, offsetof(struct vmmeter, v_forwarded_hits)); diff --git a/sys/sys/proc.h b/sys/sys/proc.h index cc97a24963..ca1db50a7c 100644 --- a/sys/sys/proc.h +++ b/sys/sys/proc.h @@ -37,7 +37,7 @@ * * @(#)proc.h 8.15 (Berkeley) 5/19/95 * $FreeBSD: src/sys/sys/proc.h,v 1.99.2.9 2003/06/06 20:21:32 tegge Exp $ - * $DragonFly: src/sys/sys/proc.h,v 1.53 2004/07/24 20:21:35 dillon Exp $ + * $DragonFly: src/sys/sys/proc.h,v 1.54 2004/08/12 19:59:30 eirikn Exp $ */ #ifndef _SYS_PROC_H_ @@ -241,6 +241,7 @@ struct proc { struct sched *p_sched; /* work-in-progress / Peter Kadau */ int p_numposixlocks; /* number of POSIX locks */ TAILQ_HEAD(, sysmsg) p_sysmsgq; /* Recorded asynch system calls */ + int p_num_sysmsg; /* How many sysmsg's this proc has running */ }; #if defined(_KERNEL) diff --git a/sys/sys/syscall-args b/sys/sys/syscall-args new file mode 100644 index 0000000000..25d78ae4f7 --- /dev/null +++ b/sys/sys/syscall-args @@ -0,0 +1,256 @@ +# System call argument table. +# DO NOT EDIT-- this file is automatically generated. +# $DragonFly: src/sys/sys/Attic/syscall-args,v 1.1 2004/08/12 19:59:30 eirikn Exp $ + +# Created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp + +int syscall nosys nosys_args +void exit sys_exit sys_exit_args int rval +int fork fork fork_args +int read read read_args int fd void * buf size_t nbyte +int write write write_args int fd const void * buf size_t nbyte +int open open open_args char * path int flags int mode +int close close close_args int fd +int wait4 wait4 wait_args int pid int * status int options struct rusage * rusage +int link link link_args char * path char * link +int unlink unlink unlink_args char * path +int chdir chdir chdir_args char * path +int fchdir fchdir fchdir_args int fd +int mknod mknod mknod_args char * path int mode int dev +int chmod chmod chmod_args char * path int mode +int chown chown chown_args char * path int uid int gid +int break obreak obreak_args char * nsize +int getfsstat getfsstat getfsstat_args struct statfs * buf long bufsize int flags +int getpid getpid getpid_args +int mount mount mount_args char * type char * path int flags caddr_t data +int unmount unmount unmount_args char * path int flags +int setuid setuid setuid_args uid_t uid +int getuid getuid getuid_args +int geteuid geteuid geteuid_args +int ptrace ptrace ptrace_args int req pid_t pid caddr_t addr int data +int recvmsg recvmsg recvmsg_args int s struct msghdr * msg int flags +int sendmsg sendmsg sendmsg_args int s caddr_t msg int flags +int recvfrom recvfrom recvfrom_args int s caddr_t buf size_t len int flags caddr_t from int * fromlenaddr +int accept accept accept_args int s caddr_t name int * anamelen +int getpeername getpeername getpeername_args int fdes caddr_t asa int * alen +int getsockname getsockname getsockname_args int fdes caddr_t asa int * alen +int access access access_args char * path int flags +int chflags chflags chflags_args char * path int flags +int fchflags fchflags fchflags_args int fd int flags +int sync sync sync_args +int kill kill kill_args int pid int signum +int getppid getppid getppid_args +int dup dup dup_args u_int fd +int pipe pipe pipe_args +int getegid getegid getegid_args +int profil profil profil_args caddr_t samples size_t size size_t offset u_int scale +int ktrace ktrace ktrace_args const char * fname int ops int facs int pid +int getgid getgid getgid_args +int getlogin getlogin getlogin_args char * namebuf u_int namelen +int setlogin setlogin setlogin_args char * namebuf +int acct acct acct_args char * path +int sigaltstack sigaltstack sigaltstack_args stack_t * ss stack_t * oss +int ioctl ioctl ioctl_args int fd u_long com caddr_t data +int reboot reboot reboot_args int opt +int revoke revoke revoke_args char * path +int symlink symlink symlink_args char * path char * link +int readlink readlink readlink_args char * path char * buf int count +int execve execve execve_args char * fname char ** argv char ** envv +int umask umask umask_args int newmask +int chroot chroot chroot_args char * path +int msync msync msync_args void * addr size_t len int flags +int vfork vfork vfork_args +int sbrk sbrk sbrk_args int incr +int sstk sstk sstk_args int incr +int vadvise ovadvise ovadvise_args int anom +int munmap munmap munmap_args void * addr size_t len +int mprotect mprotect mprotect_args const void * addr size_t len int prot +int madvise madvise madvise_args void * addr size_t len int behav +int mincore mincore mincore_args const void * addr size_t len char * vec +int getgroups getgroups getgroups_args u_int gidsetsize gid_t * gidset +int setgroups setgroups setgroups_args u_int gidsetsize gid_t * gidset +int getpgrp getpgrp getpgrp_args +int setpgid setpgid setpgid_args int pid int pgid +int setitimer setitimer setitimer_args u_int which struct itimerval * itv struct itimerval * oitv +int swapon swapon swapon_args char * name +int getitimer getitimer getitimer_args u_int which struct itimerval * itv +int getdtablesize getdtablesize getdtablesize_args +int dup2 dup2 dup2_args u_int from u_int to +int fcntl fcntl fcntl_args int fd int cmd long arg +int select select select_args int nd fd_set * in fd_set * ou fd_set * ex struct timeval * tv +int fsync fsync fsync_args int fd +int setpriority setpriority setpriority_args int which int who int prio +int socket socket socket_args int domain int type int protocol +int connect connect connect_args int s caddr_t name int namelen +int getpriority getpriority getpriority_args int which int who +int bind bind bind_args int s caddr_t name int namelen +int setsockopt setsockopt setsockopt_args int s int level int name caddr_t val int valsize +int listen listen listen_args int s int backlog +int gettimeofday gettimeofday gettimeofday_args struct timeval * tp struct timezone * tzp +int getrusage getrusage getrusage_args int who struct rusage * rusage +int getsockopt getsockopt getsockopt_args int s int level int name caddr_t val int * avalsize +int readv readv readv_args int fd struct iovec * iovp u_int iovcnt +int writev writev writev_args int fd struct iovec * iovp u_int iovcnt +int settimeofday settimeofday settimeofday_args struct timeval * tv struct timezone * tzp +int fchown fchown fchown_args int fd int uid int gid +int fchmod fchmod fchmod_args int fd int mode +int setreuid setreuid setreuid_args int ruid int euid +int setregid setregid setregid_args int rgid int egid +int rename rename rename_args char * from char * to +int flock flock flock_args int fd int how +int mkfifo mkfifo mkfifo_args char * path int mode +int sendto sendto sendto_args int s caddr_t buf size_t len int flags caddr_t to int tolen +int shutdown shutdown shutdown_args int s int how +int socketpair socketpair socketpair_args int domain int type int protocol int * rsv +int mkdir mkdir mkdir_args char * path int mode +int rmdir rmdir rmdir_args char * path +int utimes utimes utimes_args char * path struct timeval * tptr +int adjtime adjtime adjtime_args struct timeval * delta struct timeval * olddelta +int setsid setsid setsid_args +int quotactl quotactl quotactl_args char * path int cmd int uid caddr_t arg +int nfssvc nfssvc nfssvc_args int flag caddr_t argp +int statfs statfs statfs_args char * path struct statfs * buf +int fstatfs fstatfs fstatfs_args int fd struct statfs * buf +int getfh getfh getfh_args char * fname struct fhandle * fhp +int getdomainname getdomainname getdomainname_args char * domainname int len +int setdomainname setdomainname setdomainname_args char * domainname int len +int uname uname uname_args struct utsname * name +int sysarch sysarch sysarch_args int op char * parms +int rtprio rtprio rtprio_args int function pid_t pid struct rtprio * rtp +int semsys semsys semsys_args int which int a2 int a3 int a4 int a5 +int msgsys msgsys msgsys_args int which int a2 int a3 int a4 int a5 int a6 +int shmsys shmsys shmsys_args int which int a2 int a3 int a4 +int pread pread pread_args int fd void * buf size_t nbyte int pad off_t offset +int pwrite pwrite pwrite_args int fd const void * buf size_t nbyte int pad off_t offset +int ntp_adjtime ntp_adjtime ntp_adjtime_args struct timex * tp +int setgid setgid setgid_args gid_t gid +int setegid setegid setegid_args gid_t egid +int seteuid seteuid seteuid_args uid_t euid +int stat stat stat_args char * path struct stat * ub +int fstat fstat fstat_args int fd struct stat * sb +int lstat lstat lstat_args char * path struct stat * ub +int pathconf pathconf pathconf_args char * path int name +int fpathconf fpathconf fpathconf_args int fd int name +int getrlimit getrlimit __getrlimit_args u_int which struct rlimit * rlp +int setrlimit setrlimit __setrlimit_args u_int which struct rlimit * rlp +int getdirentries getdirentries getdirentries_args int fd char * buf u_int count long * basep +int mmap mmap mmap_args caddr_t addr size_t len int prot int flags int fd int pad off_t pos +int __syscall nosys __syscall_args +int lseek lseek lseek_args int fd int pad off_t offset int whence +int truncate truncate truncate_args char * path int pad off_t length +int ftruncate ftruncate ftruncate_args int fd int pad off_t length +int __sysctl __sysctl sysctl_args int * name u_int namelen void * old size_t * oldlenp void * new size_t newlen +int mlock mlock mlock_args const void * addr size_t len +int munlock munlock munlock_args const void * addr size_t len +int undelete undelete undelete_args char * path +int futimes futimes futimes_args int fd struct timeval * tptr +int getpgid getpgid getpgid_args pid_t pid +int poll poll poll_args struct pollfd * fds u_int nfds int timeout +int __semctl __semctl __semctl_args int semid int semnum int cmd union semun * arg +int semget semget semget_args key_t key int nsems int semflg +int semop semop semop_args int semid struct sembuf * sops u_int nsops +int msgctl msgctl msgctl_args int msqid int cmd struct msqid_ds * buf +int msgget msgget msgget_args key_t key int msgflg +int msgsnd msgsnd msgsnd_args int msqid void * msgp size_t msgsz int msgflg +int msgrcv msgrcv msgrcv_args int msqid void * msgp size_t msgsz long msgtyp int msgflg +int shmat shmat shmat_args int shmid void * shmaddr int shmflg +int shmctl shmctl shmctl_args int shmid int cmd struct shmid_ds * buf +int shmdt shmdt shmdt_args void * shmaddr +int shmget shmget shmget_args key_t key int size int shmflg +int clock_gettime clock_gettime clock_gettime_args clockid_t clock_id struct timespec * tp +int clock_settime clock_settime clock_settime_args clockid_t clock_id const struct timespec * tp +int clock_getres clock_getres clock_getres_args clockid_t clock_id struct timespec * tp +int nanosleep nanosleep nanosleep_args const struct timespec * rqtp struct timespec * rmtp +int minherit minherit minherit_args void * addr size_t len int inherit +int rfork rfork rfork_args int flags +int openbsd_poll openbsd_poll openbsd_poll_args struct pollfd * fds u_int nfds int timeout +int issetugid issetugid issetugid_args +int lchown lchown lchown_args char * path int uid int gid +int getdents getdents getdents_args int fd char * buf size_t count +int lchmod lchmod lchmod_args char * path mode_t mode +int netbsd_lchown lchown lchown_args char * path uid_t uid gid_t gid +int lutimes lutimes lutimes_args char * path struct timeval * tptr +int netbsd_msync msync msync_args void * addr size_t len int flags +int nstat nstat nstat_args char * path struct nstat * ub +int nfstat nfstat nfstat_args int fd struct nstat * sb +int nlstat nlstat nlstat_args char * path struct nstat * ub +int fhstatfs fhstatfs fhstatfs_args const struct fhandle * u_fhp struct statfs * buf +int fhopen fhopen fhopen_args const struct fhandle * u_fhp int flags +int fhstat fhstat fhstat_args const struct fhandle * u_fhp struct stat * sb +int modnext modnext modnext_args int modid +int modstat modstat modstat_args int modid struct module_stat * stat +int modfnext modfnext modfnext_args int modid +int modfind modfind modfind_args const char * name +int kldload kldload kldload_args const char * file +int kldunload kldunload kldunload_args int fileid +int kldfind kldfind kldfind_args const char * file +int kldnext kldnext kldnext_args int fileid +int kldstat kldstat kldstat_args int fileid struct kld_file_stat * stat +int kldfirstmod kldfirstmod kldfirstmod_args int fileid +int getsid getsid getsid_args pid_t pid +int setresuid setresuid setresuid_args uid_t ruid uid_t euid uid_t suid +int setresgid setresgid setresgid_args gid_t rgid gid_t egid gid_t sgid +int aio_return aio_return aio_return_args struct aiocb * aiocbp +int aio_suspend aio_suspend aio_suspend_args struct aiocb *const * aiocbp int nent const struct timespec * timeout +int aio_cancel aio_cancel aio_cancel_args int fd struct aiocb * aiocbp +int aio_error aio_error aio_error_args struct aiocb * aiocbp +int aio_read aio_read aio_read_args struct aiocb * aiocbp +int aio_write aio_write aio_write_args struct aiocb * aiocbp +int lio_listio lio_listio lio_listio_args int mode struct aiocb *const * acb_list int nent struct sigevent * sig +int yield yield yield_args +int thr_sleep thr_sleep thr_sleep_args const struct timespec * timeout +int thr_wakeup thr_wakeup thr_wakeup_args pid_t pid +int mlockall mlockall mlockall_args int how +int munlockall munlockall munlockall_args +int __getcwd __getcwd __getcwd_args u_char * buf u_int buflen +int sched_setparam sched_setparam sched_setparam_args pid_t pid const struct sched_param * param +int sched_getparam sched_getparam sched_getparam_args pid_t pid struct sched_param * param +int sched_setscheduler sched_setscheduler sched_setscheduler_args pid_t pid int policy const struct sched_param * param +int sched_getscheduler sched_getscheduler sched_getscheduler_args pid_t pid +int sched_yield sched_yield sched_yield_args +int sched_get_priority_max sched_get_priority_max sched_get_priority_max_args int policy +int sched_get_priority_min sched_get_priority_min sched_get_priority_min_args int policy +int sched_rr_get_interval sched_rr_get_interval sched_rr_get_interval_args pid_t pid struct timespec * interval +int utrace utrace utrace_args const void * addr size_t len +int kldsym kldsym kldsym_args int fileid int cmd void * data +int jail jail jail_args struct jail * jail +int sigprocmask sigprocmask sigprocmask_args int how const sigset_t * set sigset_t * oset +int sigsuspend sigsuspend sigsuspend_args const sigset_t * sigmask +int sigaction sigaction sigaction_args int sig const struct sigaction * act struct sigaction * oact +int sigpending sigpending sigpending_args sigset_t * set +int sigreturn sigreturn sigreturn_args ucontext_t * sigcntxp +int __acl_get_file __acl_get_file __acl_get_file_args const char * path acl_type_t type struct acl * aclp +int __acl_set_file __acl_set_file __acl_set_file_args const char * path acl_type_t type struct acl * aclp +int __acl_get_fd __acl_get_fd __acl_get_fd_args int filedes acl_type_t type struct acl * aclp +int __acl_set_fd __acl_set_fd __acl_set_fd_args int filedes acl_type_t type struct acl * aclp +int __acl_delete_file __acl_delete_file __acl_delete_file_args const char * path acl_type_t type +int __acl_delete_fd __acl_delete_fd __acl_delete_fd_args int filedes acl_type_t type +int __acl_aclcheck_file __acl_aclcheck_file __acl_aclcheck_file_args const char * path acl_type_t type struct acl * aclp +int __acl_aclcheck_fd __acl_aclcheck_fd __acl_aclcheck_fd_args int filedes acl_type_t type struct acl * aclp +int extattrctl extattrctl extattrctl_args const char * path int cmd const char * attrname char * arg +int extattr_set_file extattr_set_file extattr_set_file_args const char * path const char * attrname struct iovec * iovp unsigned iovcnt +int extattr_get_file extattr_get_file extattr_get_file_args const char * path const char * attrname struct iovec * iovp unsigned iovcnt +int extattr_delete_file extattr_delete_file extattr_delete_file_args const char * path const char * attrname +int aio_waitcomplete aio_waitcomplete aio_waitcomplete_args struct aiocb ** aiocbp struct timespec * timeout +int getresuid getresuid getresuid_args uid_t * ruid uid_t * euid uid_t * suid +int getresgid getresgid getresgid_args gid_t * rgid gid_t * egid gid_t * sgid +int kqueue kqueue kqueue_args +int kevent kevent kevent_args int fd const struct kevent * changelist int nchanges struct kevent * eventlist int nevents const struct timespec * timeout +int sendfile sendfile sendfile_args int fd int s off_t offset size_t nbytes struct sf_hdtr * hdtr off_t * sbytes int flags +int varsym_set varsym_set varsym_set_args int level const char * name const char * data +int varsym_get varsym_get varsym_get_args int mask const char * wild char * buf int bufsize +int varsym_list varsym_list varsym_list_args int level char * buf int maxsize int * marker +int upc_register upc_register upc_register_args struct upcall * upc void * ctxfunc void * func void * data +int upc_control upc_control upc_control_args int cmd int upcid void * data +int caps_sys_service caps_sys_service caps_sys_service_args const char * name uid_t uid gid_t gid int upcid int flags +int caps_sys_client caps_sys_client caps_sys_client_args const char * name uid_t uid gid_t gid int upcid int flags +int caps_sys_close caps_sys_close caps_sys_close_args int portid +int caps_sys_put caps_sys_put caps_sys_put_args int portid void * msg int msgsize +int caps_sys_reply caps_sys_reply caps_sys_reply_args int portid void * msg int msgsize off_t msgcid +int caps_sys_get caps_sys_get caps_sys_get_args int portid void * msg int maxsize struct caps_msgid * msgid struct caps_cred * ccr +int caps_sys_wait caps_sys_wait caps_sys_wait_args int portid void * msg int maxsize struct caps_msgid * msgid struct caps_cred * ccr +int caps_sys_abort caps_sys_abort caps_sys_abort_args int portid off_t msgcid int flags +int caps_sys_getgen caps_sys_getgen caps_sys_getgen_args int portid +int caps_sys_setgen caps_sys_setgen caps_sys_setgen_args int portid off_t gen +int exec_sys_register exec_sys_register exec_sys_register_args void * entry +int exec_sys_unregister exec_sys_unregister exec_sys_unregister_args int id diff --git a/sys/sys/syscall-hide.h b/sys/sys/syscall-hide.h index 68f4d8b6d5..27a7e034fd 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.17 2004/03/06 22:14:16 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/sys/syscall-hide.h,v 1.18 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ HIDE_POSIX(fork) diff --git a/sys/sys/syscall.h b/sys/sys/syscall.h index 94ea2867de..5004b7b439 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.17 2004/03/06 22:14:16 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/sys/syscall.h,v 1.18 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ #define SYS_syscall 0 diff --git a/sys/sys/syscall.mk b/sys/sys/syscall.mk index b7a39fe1d8..13a8c4227e 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.17 2004/03/06 22:14:16 dillon Exp $ -# created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp +# $DragonFly: src/sys/sys/syscall.mk,v 1.18 2004/08/12 19:59:30 eirikn Exp $ +# created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp MIASM = \ syscall.o \ exit.o \ diff --git a/sys/sys/sysmsg.h b/sys/sys/sysmsg.h index e23bbb414d..4ddb00d904 100644 --- a/sys/sys/sysmsg.h +++ b/sys/sys/sysmsg.h @@ -1,7 +1,7 @@ /* * SYS/SYSMSG.H * - * $DragonFly: src/sys/sys/sysmsg.h,v 1.5 2004/06/04 20:35:39 dillon Exp $ + * $DragonFly: src/sys/sys/sysmsg.h,v 1.6 2004/08/12 19:59:30 eirikn Exp $ */ #ifndef _SYS_SYSMSG_H_ @@ -42,6 +42,7 @@ struct sysmsg { }; struct proc; +union sysunion; struct sysmsg *sysmsg_wait(struct proc *p, struct sysmsg *sysmsg, int nonblock); void sysmsg_rundown(struct proc *p, int doabort); diff --git a/sys/sys/sysproto.h b/sys/sys/sysproto.h index a8c1ad2ec9..ca8bc7ffbf 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.17 2004/03/06 22:14:16 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/sys/sysproto.h,v 1.18 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ #ifndef _SYS_SYSPROTO_H_ diff --git a/sys/sys/sysunion.h b/sys/sys/sysunion.h index 458aba2b6c..fc57b2e497 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.14 2004/03/06 22:14:16 dillon Exp $ - * created from DragonFly: src/sys/kern/syscalls.master,v 1.11 2004/01/20 18:41:51 dillon Exp + * $DragonFly: src/sys/sys/sysunion.h,v 1.15 2004/08/12 19:59:30 eirikn Exp $ + * created fromDragonFly: src/sys/kern/syscalls.master,v 1.12 2004/03/06 22:14:09 dillon Exp */ union sysunion { diff --git a/sys/sys/vmmeter.h b/sys/sys/vmmeter.h index c3c7e40a4d..b85d9181d5 100644 --- a/sys/sys/vmmeter.h +++ b/sys/sys/vmmeter.h @@ -32,7 +32,7 @@ * * @(#)vmmeter.h 8.2 (Berkeley) 7/10/94 * $FreeBSD: src/sys/sys/vmmeter.h,v 1.21.2.2 2002/10/10 19:28:21 dillon Exp $ - * $DragonFly: src/sys/sys/vmmeter.h,v 1.8 2004/04/24 04:09:21 drhodus Exp $ + * $DragonFly: src/sys/sys/vmmeter.h,v 1.9 2004/08/12 19:59:30 eirikn Exp $ */ #ifndef _SYS_VMMETER_H_ @@ -93,7 +93,8 @@ struct vmmeter { u_int v_forwarded_hits; u_int v_forwarded_misses; u_int v_sendsys; /* calls to sendsys() */ -#define vmmeter_uint_end v_sendsys + u_int v_waitsys; /* calls to waitsys() */ +#define vmmeter_uint_end v_waitsys }; struct vmstats { diff --git a/usr.bin/truss/i386.conf b/usr.bin/truss/i386.conf index ead5903aee..03e3588ca2 100644 --- a/usr.bin/truss/i386.conf +++ b/usr.bin/truss/i386.conf @@ -1,4 +1,4 @@ -# $DragonFly: src/usr.bin/truss/i386.conf,v 1.2 2003/07/25 03:43:15 dillon Exp $ +# $DragonFly: src/usr.bin/truss/i386.conf,v 1.3 2004/08/12 19:59:31 eirikn Exp $ sysnames="syscalls.h" sysproto="/dev/null" sysunion="/dev/null" @@ -7,6 +7,7 @@ syshdr="/dev/null" sysmk="/dev/null" syssw="/dev/null" syshide="/dev/null" +sysargs="/dev/null" syscallprefix="SYS_" switchname="sysent" namesname="syscallnames" diff --git a/usr.bin/truss/i386linux.conf b/usr.bin/truss/i386linux.conf index c13a46e721..379c2cdd1d 100644 --- a/usr.bin/truss/i386linux.conf +++ b/usr.bin/truss/i386linux.conf @@ -1,4 +1,4 @@ -# $DragonFly: src/usr.bin/truss/i386linux.conf,v 1.2 2003/07/25 03:43:15 dillon Exp $ +# $DragonFly: src/usr.bin/truss/i386linux.conf,v 1.3 2004/08/12 19:59:31 eirikn Exp $ sysnames="linux_syscalls.h" sysproto="/dev/null" sysunion="/dev/null" @@ -7,6 +7,7 @@ syshdr="/dev/null" sysmk="/dev/null" syssw="/dev/null" syshide="/dev/null" +sysargs="/dev/null" syscallprefix="SYS_" switchname="sysent" namesname="linux_syscallnames" -- 2.41.0