diff options
author | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-10-15 23:35:30 +0000 |
---|---|---|
committer | Philip Guenthe <guenther@cvs.openbsd.org> | 2011-10-15 23:35:30 +0000 |
commit | 67874eb615d7ff9c8ac1f262fa286e41e2e0e32f (patch) | |
tree | a4438f1bc677ce643f078f2bfaef615b6264844d /sys/kern/kern_prot.c | |
parent | ae0a9206a9212a9f09180c0e6c63b4973377fc50 (diff) |
"TLS-lite": add kernel support for a per-thread userspace pointer,
for pointing to the thread-control-block. Support for mapping this
to the correct hardware register can be added as it's finished;
start with support for amd64, sparc, and sparc64. Includes syscalls
for getting and setting it (for a portable __errno implementation) as
well as creating a new thread with an initial value for it.
discussed with miod@, kettenis@, deraadt@; committing to get the syscalls
in with the impending libc bump and do further refinements in tree
Diffstat (limited to 'sys/kern/kern_prot.c')
-rw-r--r-- | sys/kern/kern_prot.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/sys/kern/kern_prot.c b/sys/kern/kern_prot.c index 1a0f724db41..e936e44970e 100644 --- a/sys/kern/kern_prot.c +++ b/sys/kern/kern_prot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_prot.c,v 1.50 2011/07/25 20:32:06 tedu Exp $ */ +/* $OpenBSD: kern_prot.c,v 1.51 2011/10/15 23:35:29 guenther Exp $ */ /* $NetBSD: kern_prot.c,v 1.33 1996/02/09 18:59:42 christos Exp $ */ /* @@ -54,6 +54,10 @@ #include <sys/mount.h> #include <sys/syscallargs.h> +#ifdef __HAVE_MD_TCB +# include <machine/tcb.h> +#endif + /* ARGSUSED */ int sys_getpid(struct proc *p, void *v, register_t *retval) @@ -890,3 +894,27 @@ proc_cansugid(struct proc *p) /* Allow. */ return (1); } + +/* + * Set address of the proc's thread-control-block + */ +int +sys___set_tcb(struct proc *p, void *v, register_t *retval) +{ + struct sys___set_tcb_args /* { + syscallarg(void *) tcb; + } */ *uap = v; + + TCB_SET(p, SCARG(uap, tcb)); + return (0); +} + +/* + * Get address of the proc's thread-control-block + */ +int +sys___get_tcb(struct proc *p, void *v, register_t *retval) +{ + *retval = (register_t)TCB_GET(p); + return (0); +} |