1994-08-24 11:47:23 +00:00
|
|
|
/*-
|
|
|
|
* Copyright (c) 1982, 1988, 1991 The Regents of the University of California.
|
|
|
|
* 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.
|
|
|
|
* 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.
|
|
|
|
*
|
1999-08-28 01:08:13 +00:00
|
|
|
* $FreeBSD$
|
1994-08-24 11:47:23 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _SYS_SYSENT_H_
|
1996-03-29 14:29:50 +00:00
|
|
|
#define _SYS_SYSENT_H_
|
1994-08-24 11:47:23 +00:00
|
|
|
|
2005-05-29 20:08:39 +00:00
|
|
|
#include <bsm/audit.h>
|
|
|
|
|
2007-05-14 22:40:04 +00:00
|
|
|
struct rlimit;
|
2006-08-03 05:26:51 +00:00
|
|
|
struct sysent;
|
2001-09-12 08:38:13 +00:00
|
|
|
struct thread;
|
1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, most
changes in MD code are trivial, before this change, trapsignal and
sendsig use discrete parameters, now they uses member fields of
ksiginfo_t structure. For sendsig, this change allows us to pass
POSIX realtime signal value to user code.
2. Remove cpu_thread_siginfo, it is no longer needed because we now always
generate ksiginfo_t data and feed it to libpthread.
3. Add p_sigqueue to proc structure to hold shared signals which were
blocked by all threads in the proc.
4. Add td_sigqueue to thread structure to hold all signals delivered to
thread.
5. i386 and amd64 now return POSIX standard si_code, other arches will
be fixed.
6. In this sigqueue implementation, pending signal set is kept as before,
an extra siginfo list holds additional siginfo_t data for signals.
kernel code uses psignal() still behavior as before, it won't be failed
even under memory pressure, only exception is when deleting a signal,
we should call sigqueue_delete to remove signal from sigqueue but
not SIGDELSET. Current there is no kernel code will deliver a signal
with additional data, so kernel should be as stable as before,
a ksiginfo can carry more information, for example, allow signal to
be delivered but throw away siginfo data if memory is not enough.
SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can
not be caught or masked.
The sigqueue() syscall allows user code to queue a signal to target
process, if resource is unavailable, EAGAIN will be returned as
specification said.
Just before thread exits, signal queue memory will be freed by
sigqueue_flush.
Current, all signals are allowed to be queued, not only realtime signals.
Earlier patch reviewed by: jhb, deischen
Tested on: i386, amd64
2005-10-14 12:43:47 +00:00
|
|
|
struct ksiginfo;
|
1998-02-03 21:52:02 +00:00
|
|
|
|
2002-03-19 20:18:42 +00:00
|
|
|
typedef int sy_call_t(struct thread *, void *);
|
1995-09-19 13:31:04 +00:00
|
|
|
|
2006-08-03 05:26:51 +00:00
|
|
|
/* Used by the machine dependent syscall() code. */
|
|
|
|
typedef void (*systrace_probe_func_t)(u_int32_t, int, struct sysent *, void *);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Used by loaded syscalls to convert arguments to a DTrace array
|
|
|
|
* of 64-bit arguments.
|
|
|
|
*/
|
2008-11-05 19:39:11 +00:00
|
|
|
typedef void (*systrace_args_func_t)(int, void *, u_int64_t *, int *);
|
2006-08-03 05:26:51 +00:00
|
|
|
|
|
|
|
extern systrace_probe_func_t systrace_probe_func;
|
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
struct sysent { /* system call table */
|
1994-08-24 11:47:23 +00:00
|
|
|
int sy_narg; /* number of arguments */
|
1995-09-19 13:31:04 +00:00
|
|
|
sy_call_t *sy_call; /* implementing function */
|
2005-05-29 20:08:39 +00:00
|
|
|
au_event_t sy_auevent; /* audit event associated with syscall */
|
2006-08-03 05:26:51 +00:00
|
|
|
systrace_args_func_t sy_systrace_args_func;
|
|
|
|
/* optional argument conversion function. */
|
2008-09-18 20:26:06 +00:00
|
|
|
u_int32_t sy_entry; /* DTrace entry ID for systrace. */
|
|
|
|
u_int32_t sy_return; /* DTrace return ID for systrace. */
|
1994-08-24 11:47:23 +00:00
|
|
|
};
|
2000-03-28 07:16:37 +00:00
|
|
|
|
1995-09-19 13:31:04 +00:00
|
|
|
struct image_params;
|
1999-12-27 15:54:52 +00:00
|
|
|
struct __sigset;
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
struct trapframe;
|
1999-09-02 08:02:17 +00:00
|
|
|
struct vnode;
|
1995-09-19 13:31:04 +00:00
|
|
|
|
1994-08-24 11:47:23 +00:00
|
|
|
struct sysentvec {
|
|
|
|
int sv_size; /* number of entries */
|
|
|
|
struct sysent *sv_table; /* pointer to sysent */
|
1996-03-29 14:29:50 +00:00
|
|
|
u_int sv_mask; /* optional mask to index */
|
1994-10-09 21:53:05 +00:00
|
|
|
int sv_sigsize; /* size of signal translation table */
|
|
|
|
int *sv_sigtbl; /* signal translation table */
|
1996-04-04 01:08:20 +00:00
|
|
|
int sv_errsize; /* size of errno translation table */
|
1994-10-09 21:53:05 +00:00
|
|
|
int *sv_errtbl; /* errno translation table */
|
2002-03-19 20:18:42 +00:00
|
|
|
int (*sv_transtrap)(int, int);
|
1998-04-28 18:15:08 +00:00
|
|
|
/* translate trap-to-signal mapping */
|
2002-03-19 20:18:42 +00:00
|
|
|
int (*sv_fixup)(register_t **, struct image_params *);
|
1995-09-19 13:31:04 +00:00
|
|
|
/* stack fixup function */
|
1. Change prototype of trapsignal and sendsig to use ksiginfo_t *, most
changes in MD code are trivial, before this change, trapsignal and
sendsig use discrete parameters, now they uses member fields of
ksiginfo_t structure. For sendsig, this change allows us to pass
POSIX realtime signal value to user code.
2. Remove cpu_thread_siginfo, it is no longer needed because we now always
generate ksiginfo_t data and feed it to libpthread.
3. Add p_sigqueue to proc structure to hold shared signals which were
blocked by all threads in the proc.
4. Add td_sigqueue to thread structure to hold all signals delivered to
thread.
5. i386 and amd64 now return POSIX standard si_code, other arches will
be fixed.
6. In this sigqueue implementation, pending signal set is kept as before,
an extra siginfo list holds additional siginfo_t data for signals.
kernel code uses psignal() still behavior as before, it won't be failed
even under memory pressure, only exception is when deleting a signal,
we should call sigqueue_delete to remove signal from sigqueue but
not SIGDELSET. Current there is no kernel code will deliver a signal
with additional data, so kernel should be as stable as before,
a ksiginfo can carry more information, for example, allow signal to
be delivered but throw away siginfo data if memory is not enough.
SIGKILL and SIGSTOP have fast path in sigqueue_add, because they can
not be caught or masked.
The sigqueue() syscall allows user code to queue a signal to target
process, if resource is unavailable, EAGAIN will be returned as
specification said.
Just before thread exits, signal queue memory will be freed by
sigqueue_flush.
Current, all signals are allowed to be queued, not only realtime signals.
Earlier patch reviewed by: jhb, deischen
Tested on: i386, amd64
2005-10-14 12:43:47 +00:00
|
|
|
void (*sv_sendsig)(void (*)(int), struct ksiginfo *, struct __sigset *);
|
|
|
|
/* send signal */
|
Mega-commit for Linux emulator update.. This has been stress tested under
netscape-2.0 for Linux running all the Java stuff. The scrollbars are now
working, at least on my machine. (whew! :-)
I'm uncomfortable with the size of this commit, but it's too
inter-dependant to easily seperate out.
The main changes:
COMPAT_LINUX is *GONE*. Most of the code has been moved out of the i386
machine dependent section into the linux emulator itself. The int 0x80
syscall code was almost identical to the lcall 7,0 code and a minor tweak
allows them to both be used with the same C code. All kernels can now
just modload the lkm and it'll DTRT without having to rebuild the kernel
first. Like IBCS2, you can statically compile it in with "options LINUX".
A pile of new syscalls implemented, including getdents(), llseek(),
readv(), writev(), msync(), personality(). The Linux-ELF libraries want
to use some of these.
linux_select() now obeys Linux semantics, ie: returns the time remaining
of the timeout value rather than leaving it the original value.
Quite a few bugs removed, including incorrect arguments being used in
syscalls.. eg: mixups between passing the sigset as an int, vs passing
it as a pointer and doing a copyin(), missing return values, unhandled
cases, SIOC* ioctls, etc.
The build for the code has changed. i386/conf/files now knows how
to build linux_genassym and generate linux_assym.h on the fly.
Supporting changes elsewhere in the kernel:
The user-mode signal trampoline has moved from the U area to immediately
below the top of the stack (below PS_STRINGS). This allows the different
binary emulations to have their own signal trampoline code (which gets rid
of the hardwired syscall 103 (sigreturn on BSD, syslog on Linux)) and so
that the emulator can provide the exact "struct sigcontext *" argument to
the program's signal handlers.
The sigstack's "ss_flags" now uses SS_DISABLE and SS_ONSTACK flags, which
have the same values as the re-used SA_DISABLE and SA_ONSTACK which are
intended for sigaction only. This enables the support of a SA_RESETHAND
flag to sigaction to implement the gross SYSV and Linux SA_ONESHOT signal
semantics where the signal handler is reset when it's triggered.
makesyscalls.sh no longer appends the struct sysentvec on the end of the
generated init_sysent.c code. It's a lot saner to have it in a seperate
file rather than trying to update the structure inside the awk script. :-)
At exec time, the dozen bytes or so of signal trampoline code are copied
to the top of the user's stack, rather than obtaining the trampoline code
the old way by getting a clone of the parent's user area. This allows
Linux and native binaries to freely exec each other without getting
trampolines mixed up.
1996-03-02 19:38:20 +00:00
|
|
|
char *sv_sigcode; /* start of sigtramp code */
|
|
|
|
int *sv_szsigcode; /* size of sigtramp code */
|
2002-03-23 08:46:52 +00:00
|
|
|
void (*sv_prepsyscall)(struct trapframe *, int *, u_int *,
|
|
|
|
caddr_t *);
|
1996-06-18 05:16:00 +00:00
|
|
|
char *sv_name; /* name of binary type */
|
2002-03-23 08:46:52 +00:00
|
|
|
int (*sv_coredump)(struct thread *, struct vnode *, off_t);
|
1998-09-14 05:36:51 +00:00
|
|
|
/* function to dump core, or NULL */
|
2002-03-19 20:18:42 +00:00
|
|
|
int (*sv_imgact_try)(struct image_params *);
|
2000-11-09 08:25:48 +00:00
|
|
|
int sv_minsigstksz; /* minimum signal stack size */
|
2002-09-01 21:41:24 +00:00
|
|
|
int sv_pagesize; /* pagesize */
|
|
|
|
vm_offset_t sv_minuser; /* VM_MIN_ADDRESS */
|
|
|
|
vm_offset_t sv_maxuser; /* VM_MAXUSER_ADDRESS */
|
|
|
|
vm_offset_t sv_usrstack; /* USRSTACK */
|
|
|
|
vm_offset_t sv_psstrings; /* PS_STRINGS */
|
|
|
|
int sv_stackprot; /* vm protection for stack */
|
2002-07-20 02:56:12 +00:00
|
|
|
register_t *(*sv_copyout_strings)(struct image_params *);
|
|
|
|
void (*sv_setregs)(struct thread *, u_long, u_long, u_long);
|
2007-05-14 22:40:04 +00:00
|
|
|
void (*sv_fixlimit)(struct rlimit *, int);
|
2007-07-12 18:01:31 +00:00
|
|
|
u_long *sv_maxssiz;
|
2008-11-22 12:36:15 +00:00
|
|
|
u_int sv_flags;
|
1994-08-24 11:47:23 +00:00
|
|
|
};
|
|
|
|
|
2008-11-22 12:36:15 +00:00
|
|
|
#define SV_ILP32 0x000100
|
|
|
|
#define SV_LP64 0x000200
|
|
|
|
#define SV_IA32 0x004000
|
|
|
|
#define SV_AOUT 0x008000
|
|
|
|
|
|
|
|
#define SV_ABI_MASK 0xff
|
|
|
|
#define SV_CURPROC_FLAG(x) (curproc->p_sysent->sv_flags & (x))
|
|
|
|
#define SV_CURPROC_ABI() (curproc->p_sysent->sv_flags & SV_ABI_MASK)
|
|
|
|
/* same as ELFOSABI_XXX, to prevent header pollution */
|
|
|
|
#define SV_ABI_LINUX 3
|
|
|
|
#define SV_ABI_FREEBSD 9
|
|
|
|
#define SV_ABI_UNDEF 255
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#ifdef _KERNEL
|
1995-03-16 18:17:34 +00:00
|
|
|
extern struct sysentvec aout_sysvec;
|
2000-11-05 10:41:35 +00:00
|
|
|
extern struct sysentvec elf_freebsd_sysvec;
|
2002-09-01 21:41:24 +00:00
|
|
|
extern struct sysentvec null_sysvec;
|
1994-08-24 11:47:23 +00:00
|
|
|
extern struct sysent sysent[];
|
1999-01-09 14:15:41 +00:00
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
#define NO_SYSCALL (-1)
|
1999-01-09 14:15:41 +00:00
|
|
|
|
|
|
|
struct module;
|
|
|
|
|
|
|
|
struct syscall_module_data {
|
2008-09-18 20:26:06 +00:00
|
|
|
int (*chainevh)(struct module *, int, void *); /* next handler */
|
|
|
|
void *chainarg; /* arg for next event handler */
|
|
|
|
int *offset; /* offset into sysent */
|
|
|
|
struct sysent *new_sysent; /* new sysent */
|
|
|
|
struct sysent old_sysent; /* old sysent */
|
1999-01-09 14:15:41 +00:00
|
|
|
};
|
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
#define MAKE_SYSENT(syscallname) \
|
|
|
|
static struct sysent syscallname##_sysent = { \
|
|
|
|
(sizeof(struct syscallname ## _args ) \
|
|
|
|
/ sizeof(register_t)), \
|
|
|
|
(sy_call_t *)& syscallname, \
|
|
|
|
SYS_AUE_##syscallname \
|
2007-04-02 13:53:26 +00:00
|
|
|
}
|
2008-09-18 20:26:06 +00:00
|
|
|
|
|
|
|
#define SYSCALL_MODULE(name, offset, new_sysent, evh, arg) \
|
|
|
|
static struct syscall_module_data name##_syscall_mod = { \
|
|
|
|
evh, arg, offset, new_sysent, { 0, NULL, AUE_NULL } \
|
|
|
|
}; \
|
|
|
|
\
|
|
|
|
static moduledata_t name##_mod = { \
|
|
|
|
#name, \
|
|
|
|
syscall_module_handler, \
|
|
|
|
&name##_syscall_mod \
|
|
|
|
}; \
|
2006-08-01 16:32:20 +00:00
|
|
|
DECLARE_MODULE(name, name##_mod, SI_SUB_SYSCALLS, SI_ORDER_MIDDLE)
|
1999-01-09 14:15:41 +00:00
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
#define SYSCALL_MODULE_HELPER(syscallname) \
|
|
|
|
static int syscallname##_syscall = SYS_##syscallname; \
|
|
|
|
MAKE_SYSENT(syscallname); \
|
|
|
|
SYSCALL_MODULE(syscallname, \
|
|
|
|
& syscallname##_syscall, & syscallname##_sysent, \
|
|
|
|
NULL, NULL)
|
2000-12-01 08:57:47 +00:00
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
#define SYSCALL_MODULE_PRESENT(syscallname) \
|
|
|
|
(sysent[SYS_##syscallname].sy_call != (sy_call_t *)lkmnosys && \
|
|
|
|
sysent[SYS_##syscallname].sy_call != (sy_call_t *)lkmressys)
|
2006-12-20 19:00:52 +00:00
|
|
|
|
2008-09-18 20:26:06 +00:00
|
|
|
int syscall_register(int *offset, struct sysent *new_sysent,
|
2002-03-23 08:46:52 +00:00
|
|
|
struct sysent *old_sysent);
|
2008-09-18 20:26:06 +00:00
|
|
|
int syscall_deregister(int *offset, struct sysent *old_sysent);
|
|
|
|
int syscall_module_handler(struct module *mod, int what, void *arg);
|
1999-01-09 14:15:41 +00:00
|
|
|
|
2008-09-25 20:07:42 +00:00
|
|
|
/* Special purpose system call functions. */
|
|
|
|
struct nosys_args;
|
|
|
|
|
|
|
|
int lkmnosys(struct thread *, struct nosys_args *);
|
|
|
|
int lkmressys(struct thread *, struct nosys_args *);
|
|
|
|
|
1999-12-29 04:46:21 +00:00
|
|
|
#endif /* _KERNEL */
|
1994-08-24 11:47:23 +00:00
|
|
|
|
1996-03-29 14:29:50 +00:00
|
|
|
#endif /* !_SYS_SYSENT_H_ */
|