Start to implement another strange feature: signals as Mach software

exceptions. This can be requested with ptrace, and cause signals to
be transformed into a particular kind of exception.
This commit is contained in:
manu 2003-11-20 07:12:34 +00:00
parent 6918f15fc1
commit 3c00d1aad5
17 changed files with 529 additions and 55 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_exec.h,v 1.8 2003/10/25 10:43:45 manu Exp $ */
/* $NetBSD: darwin_exec.h,v 1.9 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -50,8 +50,11 @@ struct darwin_emuldata {
pid_t ded_fakepid;
dev_t ded_wsdev; /* display to restore on exit */
int *ded_hidsystem_finished; /* iohidsystem thread finished flag */
int ded_flags; /* flags, see below */
};
#define DARWIN_DED_SIGEXC 1 /* Mach exceptions instead of signals */
int exec_darwin_copyargs(struct proc *, struct exec_package *,
struct ps_strings *, char **, void *);
int exec_darwin_probe(char **);

View File

@ -0,0 +1,156 @@
/* $NetBSD: darwin_ptrace.c,v 1.1 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_ptrace.c,v 1.1 2003/11/20 07:12:34 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/mount.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/sa.h>
#include <sys/syscallargs.h>
#include <compat/mach/mach_types.h>
#include <compat/mach/mach_vm.h>
#include <compat/darwin/darwin_exec.h>
#include <compat/darwin/darwin_ptrace.h>
#include <compat/darwin/darwin_syscallargs.h>
#if 0
#define ISSET(t, f) ((t) & (f))
static inline int ptrace_sanity_check(struct proc *, struct proc *);
/* Sanity checks copied from native sys_ptrace() */
static inline int
ptrace_sanity_check(p, t)
struct proc *p;
struct proc *t;
{
/*
* You can't do what you want to the process if:
* (1) It's not being traced at all,
*/
if (!ISSET(t->p_flag, P_TRACED))
return (EPERM);
/*
* (2) it's being traced by procfs (which has
* different signal delivery semantics),
*/
if (ISSET(t->p_flag, P_FSTRACE))
return (EBUSY);
/*
* (3) it's not being traced by _you_, or
*/
if (t->p_pptr != p)
return (EBUSY);
/*
* (4) it's not currently stopped.
*/
if (t->p_stat != SSTOP || !ISSET(t->p_flag, P_WAITED))
return (EBUSY);
return 0;
}
#endif
int
darwin_sys_ptrace(l, v, retval)
struct lwp *l;
void *v;
register_t *retval;
{
struct darwin_sys_ptrace_args /* {
syscallarg(int) req;
syscallarg(pid_t) pid;
syscallarg(caddr_t) addr;
syscallarg(int) data;
} */ *uap = v;
int req = SCARG(uap, req);
struct proc *p = l->l_proc;
struct darwin_emuldata *ded = NULL;
struct proc *t; /* target process */
int error;
switch (req) {
case DARWIN_PT_SIGEXC:
ded = (struct darwin_emuldata *)p->p_emuldata;
ded->ded_flags |= DARWIN_DED_SIGEXC;
break;
case DARWIN_PT_DETACH:
if ((t = pfind(SCARG(uap, pid))) == NULL)
return (ESRCH);
/*
* Clear signal-as-exceptions flag if detaching is
* successful and if it is a Darwin process.
*/
if (((error = sys_ptrace(l, v, retval)) == 0) &&
(t->p_emul != &emul_darwin)) {
ded = (struct darwin_emuldata *)t->p_emuldata;
ded->ded_flags &= ~DARWIN_DED_SIGEXC;
}
break;
case DARWIN_PT_READ_U:
case DARWIN_PT_WRITE_U:
case DARWIN_PT_STEP:
case DARWIN_PT_THUPDATE:
case DARWIN_PT_ATTACHEXC:
case DARWIN_PT_FORCEQUOTA:
case DARWIN_PT_DENY_ATTACH:
printf("darwin_sys_ptrace: unimplemented command %d\n", req);
break;
/* The other ptrace commands are the same on NetBSD */
default:
return sys_ptrace(l, v, retval);
break;
}
return 0;
}

View File

@ -0,0 +1,61 @@
/* $NetBSD: darwin_ptrace.h,v 1.1 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Emmanuel Dreyfus
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DARWIN_PTRACE_H_
#define _DARWIN_PTRACE_H_
#define DARWIN_PT_TRACE_ME 0
#define DARWIN_PT_READ_I 1
#define DARWIN_PT_READ_D 2
#define DARWIN_PT_READ_U 3
#define DARWIN_PT_WRITE_I 4
#define DARWIN_PT_WRITE_D 5
#define DARWIN_PT_WRITE_U 6
#define DARWIN_PT_CONTINUE 7
#define DARWIN_PT_KILL 8
#define DARWIN_PT_STEP 9
#define DARWIN_PT_ATTACH 10
#define DARWIN_PT_DETACH 11
#define DARWIN_PT_SIGEXC 12
#define DARWIN_PT_THUPDATE 13
#define DARWIN_PT_ATTACHEXC 14
#define DARWIN_PT_FORCEQUOTA 30
#define DARWIN_PT_DENY_ATTACH 31
#endif /* _DARWIN_PTRACE_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_signal.c,v 1.8 2003/11/17 01:52:14 manu Exp $ */
/* $NetBSD: darwin_signal.c,v 1.9 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2002 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_signal.c,v 1.8 2003/11/17 01:52:14 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_signal.c,v 1.9 2003/11/20 07:12:34 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: darwin_signal.c,v 1.8 2003/11/17 01:52:14 manu Exp $
#include <compat/mach/mach_port.h>
#include <compat/mach/mach_notify.h>
#include <compat/darwin/darwin_exec.h>
#include <compat/darwin/darwin_signal.h>
#include <compat/darwin/darwin_syscallargs.h>
@ -129,9 +130,24 @@ darwin_trapsignal(l, ksi)
struct lwp *l;
const struct ksiginfo *ksi;
{
struct darwin_emuldata *ded;
int code[2];
/*
* Send signals as software exception if the process requested that
* XXX this skips various checks (signal masks...)
*/
ded = (struct darwin_emuldata *)l->l_proc->p_emuldata;
if (ded->ded_flags & DARWIN_DED_SIGEXC) {
code[0] = MACH_SOFT_SIGNAL;
code[1] = ksi->ksi_signo;
mach_exception(l, MACH_EXC_SOFTWARE, code);
return;
}
/*
* If mach_trapsignal1 returns 0, the exception was intercepted at
* the Mach level, n signal is to be sent. if it returns an error,
* the Mach level, no signal is to be sent. if it returns an error,
* we call native trapsignal to fire a UNIX signal.
*/
if (mach_trapsignal1(l, ksi) != 0)

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_syscall.h,v 1.33 2003/09/06 11:50:25 manu Exp $ */
/* $NetBSD: darwin_syscall.h,v 1.34 2003/11/20 07:12:34 manu Exp $ */
/*
* System call numbers.
@ -49,9 +49,15 @@
/* syscall: "setuid" ret: "int" args: "uid_t" */
#define DARWIN_SYS_setuid 23
#ifdef COMPAT_43
/* syscall: "getuid" ret: "uid_t" args: */
#define DARWIN_SYS_getuid 24
#else
/* syscall: "getuid" ret: "uid_t" args: */
#define DARWIN_SYS_getuid 24
#endif
/* syscall: "geteuid" ret: "uid_t" args: */
#define DARWIN_SYS_geteuid 25
@ -100,16 +106,25 @@
/* syscall: "profil" ret: "int" args: "caddr_t" "size_t" "u_long" "u_int" */
#define DARWIN_SYS_profil 44
#if defined(KTRACE) || !defined(_KERNEL)
/* syscall: "ktrace" ret: "int" args: "const char *" "int" "int" "int" */
#define DARWIN_SYS_ktrace 45
#else
/* 45 is excluded ktrace */
#endif
/* syscall: "sigaction" ret: "int" args: "int" "struct darwin___sigaction *" "struct sigaction13 *" */
#define DARWIN_SYS_sigaction 46
#ifdef COMPAT_43
/* syscall: "getgid" ret: "gid_t" args: */
#define DARWIN_SYS_getgid 47
#else
/* syscall: "getgid" ret: "gid_t" args: */
#define DARWIN_SYS_getgid 47
#endif
/* syscall: "sigprocmask13" ret: "int" args: "int" "int" */
#define DARWIN_SYS_sigprocmask13 48
@ -337,10 +352,13 @@
/* syscall: "ogetsockname" ret: "int" args: "int" "caddr_t" "int *" */
#define DARWIN_SYS_ogetsockname 150
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
/* syscall: "nfssvc" ret: "int" args: "int" "void *" */
#define DARWIN_SYS_nfssvc 155
#else
/* 155 is excluded nfssvc */
#endif
/* syscall: "ogetdirentries" ret: "int" args: "int" "char *" "u_int" "long *" */
#define DARWIN_SYS_ogetdirentries 156
@ -350,7 +368,10 @@
/* syscall: "fstatfs" ret: "int" args: "int" "struct darwin_statfs *" */
#define DARWIN_SYS_fstatfs 158
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
#else
/* 161 is excluded getfh */
#endif
/* syscall: "ogetdomainname" ret: "int" args: "char *" "int" */
#define DARWIN_SYS_ogetdomainname 162

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_syscallargs.h,v 1.33 2003/09/06 11:50:26 manu Exp $ */
/* $NetBSD: darwin_syscallargs.h,v 1.34 2003/11/20 07:12:34 manu Exp $ */
/*
* System call argument lists.
@ -85,6 +85,16 @@ struct bsd_sys_unmount_args {
syscallarg(const char *) path;
syscallarg(int) flags;
};
#ifdef COMPAT_43
#else
#endif
struct darwin_sys_ptrace_args {
syscallarg(int) req;
syscallarg(pid_t) pid;
syscallarg(caddr_t) addr;
syscallarg(int) data;
};
struct bsd_sys_access_args {
syscallarg(const char *) path;
@ -105,12 +115,18 @@ struct bsd_compat_43_sys_lstat_args {
syscallarg(const char *) path;
syscallarg(struct stat43 *) ub;
};
#if defined(KTRACE) || !defined(_KERNEL)
#else
#endif
struct darwin_sys_sigaction_args {
syscallarg(int) signum;
syscallarg(struct darwin___sigaction *) nsa;
syscallarg(struct sigaction13 *) osa;
};
#ifdef COMPAT_43
#else
#endif
struct bsd_sys_acct_args {
syscallarg(const char *) path;
@ -189,6 +205,9 @@ struct bsd_sys_utimes_args {
syscallarg(const char *) path;
syscallarg(const struct timeval *) tptr;
};
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
#else
#endif
struct darwin_sys_statfs_args {
syscallarg(const char *) path;
@ -199,11 +218,14 @@ struct darwin_sys_fstatfs_args {
syscallarg(int) fd;
syscallarg(struct darwin_statfs *) buf;
};
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
struct bsd_sys_getfh_args {
syscallarg(const char *) fname;
syscallarg(fhandle_t *) fhp;
};
#else
#endif
struct darwin_sys_stat_args {
syscallarg(const char *) path;
@ -270,183 +292,346 @@ struct darwin_sys_pthread_exit_args {
*/
int sys_exit(struct lwp *, void *, register_t *);
int darwin_sys_fork(struct lwp *, void *, register_t *);
int sys_read(struct lwp *, void *, register_t *);
int sys_write(struct lwp *, void *, register_t *);
int bsd_sys_open(struct lwp *, void *, register_t *);
int sys_close(struct lwp *, void *, register_t *);
int sys_wait4(struct lwp *, void *, register_t *);
int bsd_compat_43_sys_creat(struct lwp *, void *, register_t *);
int bsd_sys_link(struct lwp *, void *, register_t *);
int bsd_sys_unlink(struct lwp *, void *, register_t *);
int bsd_sys_chdir(struct lwp *, void *, register_t *);
int sys_fchdir(struct lwp *, void *, register_t *);
int darwin_sys_mknod(struct lwp *, void *, register_t *);
int bsd_sys_chmod(struct lwp *, void *, register_t *);
int bsd_sys_chown(struct lwp *, void *, register_t *);
int sys_obreak(struct lwp *, void *, register_t *);
int darwin_sys_getfsstat(struct lwp *, void *, register_t *);
int compat_43_sys_lseek(struct lwp *, void *, register_t *);
int darwin_sys_getpid(struct lwp *, void *, register_t *);
int bsd_sys_mount(struct lwp *, void *, register_t *);
int bsd_sys_unmount(struct lwp *, void *, register_t *);
int sys_setuid(struct lwp *, void *, register_t *);
#ifdef COMPAT_43
int sys_getuid_with_euid(struct lwp *, void *, register_t *);
#else
int sys_getuid(struct lwp *, void *, register_t *);
#endif
int sys_geteuid(struct lwp *, void *, register_t *);
int sys_ptrace(struct lwp *, void *, register_t *);
int darwin_sys_ptrace(struct lwp *, void *, register_t *);
int sys_recvmsg(struct lwp *, void *, register_t *);
int sys_sendmsg(struct lwp *, void *, register_t *);
int sys_recvfrom(struct lwp *, void *, register_t *);
int sys_accept(struct lwp *, void *, register_t *);
int sys_getpeername(struct lwp *, void *, register_t *);
int sys_getsockname(struct lwp *, void *, register_t *);
int bsd_sys_access(struct lwp *, void *, register_t *);
int bsd_sys_chflags(struct lwp *, void *, register_t *);
int sys_fchflags(struct lwp *, void *, register_t *);
int sys_sync(struct lwp *, void *, register_t *);
int sys_kill(struct lwp *, void *, register_t *);
int bsd_compat_43_sys_stat(struct lwp *, void *, register_t *);
int sys_getppid(struct lwp *, void *, register_t *);
int bsd_compat_43_sys_lstat(struct lwp *, void *, register_t *);
int sys_dup(struct lwp *, void *, register_t *);
int sys_pipe(struct lwp *, void *, register_t *);
int sys_getegid(struct lwp *, void *, register_t *);
int sys_profil(struct lwp *, void *, register_t *);
#if defined(KTRACE) || !defined(_KERNEL)
int sys_ktrace(struct lwp *, void *, register_t *);
#else
#endif
int darwin_sys_sigaction(struct lwp *, void *, register_t *);
#ifdef COMPAT_43
int sys_getgid_with_egid(struct lwp *, void *, register_t *);
#else
int sys_getgid(struct lwp *, void *, register_t *);
#endif
int compat_13_sys_sigprocmask(struct lwp *, void *, register_t *);
int sys___getlogin(struct lwp *, void *, register_t *);
int sys___setlogin(struct lwp *, void *, register_t *);
int bsd_sys_acct(struct lwp *, void *, register_t *);
int compat_13_sys_sigpending(struct lwp *, void *, register_t *);
int compat_13_sys_sigaltstack(struct lwp *, void *, register_t *);
int darwin_sys_ioctl(struct lwp *, void *, register_t *);
int sys_reboot(struct lwp *, void *, register_t *);
int bsd_sys_revoke(struct lwp *, void *, register_t *);
int bsd_sys_symlink(struct lwp *, void *, register_t *);
int bsd_sys_readlink(struct lwp *, void *, register_t *);
int bsd_sys_execve(struct lwp *, void *, register_t *);
int sys_umask(struct lwp *, void *, register_t *);
int bsd_sys_chroot(struct lwp *, void *, register_t *);
int compat_43_sys_fstat(struct lwp *, void *, register_t *);
int compat_43_sys_getpagesize(struct lwp *, void *, register_t *);
int compat_12_sys_msync(struct lwp *, void *, register_t *);
int darwin_sys_vfork(struct lwp *, void *, register_t *);
int sys_sbrk(struct lwp *, void *, register_t *);
int sys_sstk(struct lwp *, void *, register_t *);
int sys_mmap(struct lwp *, void *, register_t *);
int sys_ovadvise(struct lwp *, void *, register_t *);
int sys_munmap(struct lwp *, void *, register_t *);
int sys_mprotect(struct lwp *, void *, register_t *);
int sys_madvise(struct lwp *, void *, register_t *);
int sys_mincore(struct lwp *, void *, register_t *);
int sys_getgroups(struct lwp *, void *, register_t *);
int sys_setgroups(struct lwp *, void *, register_t *);
int sys_getpgrp(struct lwp *, void *, register_t *);
int sys_setpgid(struct lwp *, void *, register_t *);
int sys_setitimer(struct lwp *, void *, register_t *);
int compat_43_sys_wait(struct lwp *, void *, register_t *);
int bsd_compat_12_sys_swapon(struct lwp *, void *, register_t *);
int sys_getitimer(struct lwp *, void *, register_t *);
int compat_43_sys_gethostname(struct lwp *, void *, register_t *);
int compat_43_sys_sethostname(struct lwp *, void *, register_t *);
int compat_43_sys_getdtablesize(struct lwp *, void *, register_t *);
int sys_dup2(struct lwp *, void *, register_t *);
int sys_fcntl(struct lwp *, void *, register_t *);
int sys_select(struct lwp *, void *, register_t *);
int sys_fsync(struct lwp *, void *, register_t *);
int sys_setpriority(struct lwp *, void *, register_t *);
int sys_socket(struct lwp *, void *, register_t *);
int sys_connect(struct lwp *, void *, register_t *);
int compat_43_sys_accept(struct lwp *, void *, register_t *);
int sys_getpriority(struct lwp *, void *, register_t *);
int compat_43_sys_send(struct lwp *, void *, register_t *);
int compat_43_sys_recv(struct lwp *, void *, register_t *);
int darwin_sys_sigreturn(struct lwp *, void *, register_t *);
int bsd_sys_bind(struct lwp *, void *, register_t *);
int sys_setsockopt(struct lwp *, void *, register_t *);
int sys_listen(struct lwp *, void *, register_t *);
int compat_43_sys_sigvec(struct lwp *, void *, register_t *);
int compat_43_sys_sigblock(struct lwp *, void *, register_t *);
int compat_43_sys_sigsetmask(struct lwp *, void *, register_t *);
int compat_13_sys_sigsuspend(struct lwp *, void *, register_t *);
int compat_43_sys_sigstack(struct lwp *, void *, register_t *);
int compat_43_sys_recvmsg(struct lwp *, void *, register_t *);
int compat_43_sys_sendmsg(struct lwp *, void *, register_t *);
int sys_gettimeofday(struct lwp *, void *, register_t *);
int sys_getrusage(struct lwp *, void *, register_t *);
int sys_getsockopt(struct lwp *, void *, register_t *);
int sys_readv(struct lwp *, void *, register_t *);
int sys_writev(struct lwp *, void *, register_t *);
int sys_settimeofday(struct lwp *, void *, register_t *);
int sys_fchown(struct lwp *, void *, register_t *);
int sys_fchmod(struct lwp *, void *, register_t *);
int compat_43_sys_recvfrom(struct lwp *, void *, register_t *);
int sys_setreuid(struct lwp *, void *, register_t *);
int sys_setregid(struct lwp *, void *, register_t *);
int bsd_sys_rename(struct lwp *, void *, register_t *);
int bsd_compat_43_sys_truncate(struct lwp *, void *, register_t *);
int compat_43_sys_ftruncate(struct lwp *, void *, register_t *);
int sys_flock(struct lwp *, void *, register_t *);
int bsd_sys_mkfifo(struct lwp *, void *, register_t *);
int sys_sendto(struct lwp *, void *, register_t *);
int sys_shutdown(struct lwp *, void *, register_t *);
int sys_socketpair(struct lwp *, void *, register_t *);
int bsd_sys_mkdir(struct lwp *, void *, register_t *);
int bsd_sys_rmdir(struct lwp *, void *, register_t *);
int bsd_sys_utimes(struct lwp *, void *, register_t *);
int sys_adjtime(struct lwp *, void *, register_t *);
int compat_43_sys_getpeername(struct lwp *, void *, register_t *);
int compat_43_sys_gethostid(struct lwp *, void *, register_t *);
int compat_43_sys_getrlimit(struct lwp *, void *, register_t *);
int compat_43_sys_setrlimit(struct lwp *, void *, register_t *);
int compat_43_sys_killpg(struct lwp *, void *, register_t *);
int sys_setsid(struct lwp *, void *, register_t *);
int compat_43_sys_getsockname(struct lwp *, void *, register_t *);
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
int sys_nfssvc(struct lwp *, void *, register_t *);
#else
#endif
int compat_43_sys_getdirentries(struct lwp *, void *, register_t *);
int darwin_sys_statfs(struct lwp *, void *, register_t *);
int darwin_sys_fstatfs(struct lwp *, void *, register_t *);
#if defined(NFS) || defined(NFSSERVER) || !defined(_KERNEL)
int bsd_sys_getfh(struct lwp *, void *, register_t *);
#else
#endif
int compat_09_sys_getdomainname(struct lwp *, void *, register_t *);
int compat_09_sys_setdomainname(struct lwp *, void *, register_t *);
int sys_setgid(struct lwp *, void *, register_t *);
int sys_setegid(struct lwp *, void *, register_t *);
int sys_seteuid(struct lwp *, void *, register_t *);
int darwin_sys_stat(struct lwp *, void *, register_t *);
int darwin_sys_fstat(struct lwp *, void *, register_t *);
int darwin_sys_lstat(struct lwp *, void *, register_t *);
int bsd_sys_pathconf(struct lwp *, void *, register_t *);
int sys_fpathconf(struct lwp *, void *, register_t *);
int sys_getrlimit(struct lwp *, void *, register_t *);
int sys_setrlimit(struct lwp *, void *, register_t *);
int compat_12_sys_getdirentries(struct lwp *, void *, register_t *);
int sys_mmap(struct lwp *, void *, register_t *);
int darwin_sys_lseek(struct lwp *, void *, register_t *);
int bsd_sys_truncate(struct lwp *, void *, register_t *);
int sys_ftruncate(struct lwp *, void *, register_t *);
int darwin_sys___sysctl(struct lwp *, void *, register_t *);
int sys_mlock(struct lwp *, void *, register_t *);
int sys_munlock(struct lwp *, void *, register_t *);
int bsd_sys_undelete(struct lwp *, void *, register_t *);
int darwin_sys_load_shared_file(struct lwp *, void *, register_t *);
int darwin_sys_pthread_exit(struct lwp *, void *, register_t *);
#endif /* _DARWIN_SYS__SYSCALLARGS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_syscalls.c,v 1.33 2003/09/06 11:50:25 manu Exp $ */
/* $NetBSD: darwin_syscalls.c,v 1.34 2003/11/20 07:12:34 manu Exp $ */
/*
* System call names.
@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_syscalls.c,v 1.33 2003/09/06 11:50:25 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_syscalls.c,v 1.34 2003/11/20 07:12:34 manu Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ktrace.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: darwin_sysent.c,v 1.34 2003/09/06 11:50:26 manu Exp $ */
/* $NetBSD: darwin_sysent.c,v 1.35 2003/11/20 07:12:34 manu Exp $ */
/*
* System call switch table.
@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: darwin_sysent.c,v 1.34 2003/09/06 11:50:26 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: darwin_sysent.c,v 1.35 2003/11/20 07:12:34 manu Exp $");
#include "opt_ktrace.h"
#include "opt_nfsserver.h"
@ -90,8 +90,8 @@ struct sysent darwin_sysent[] = {
#endif
{ 0, 0, 0,
sys_geteuid }, /* 25 = geteuid */
{ 4, s(struct sys_ptrace_args), 0,
sys_ptrace }, /* 26 = ptrace */
{ 4, s(struct darwin_sys_ptrace_args), 0,
darwin_sys_ptrace }, /* 26 = ptrace */
{ 3, s(struct sys_recvmsg_args), 0,
sys_recvmsg }, /* 27 = recvmsg */
{ 3, s(struct sys_sendmsg_args), 0,

View File

@ -1,4 +1,4 @@
# $NetBSD: files.darwin,v 1.14 2003/11/01 00:32:44 manu Exp $
# $NetBSD: files.darwin,v 1.15 2003/11/20 07:12:34 manu Exp $
#
# Config file description for machine-independent Darwin compat code.
# Included by ports that need it.
@ -13,6 +13,7 @@ file compat/darwin/darwin_iohidsystem.c compat_darwin
file compat/darwin/darwin_iokit.c compat_darwin
file compat/darwin/darwin_mman.c compat_darwin
file compat/darwin/darwin_mount.c compat_darwin
file compat/darwin/darwin_ptrace.c compat_darwin
file compat/darwin/darwin_signal.c compat_darwin
file compat/darwin/darwin_stat.c compat_darwin
file compat/darwin/darwin_sysent.c compat_darwin

View File

@ -1,4 +1,4 @@
$NetBSD: syscalls.master,v 1.17 2003/09/06 11:50:02 manu Exp $
$NetBSD: syscalls.master,v 1.18 2003/11/20 07:12:35 manu Exp $
; @(#)syscalls.master 8.2 (Berkeley) 1/13/94
@ -104,8 +104,8 @@
24 NOARGS { uid_t sys_getuid(void); }
#endif
25 NOARGS { uid_t sys_geteuid(void); }
26 NOARGS { int sys_ptrace(int req, pid_t pid, caddr_t addr, \
int data); }
26 STD { int darwin_sys_ptrace(int req, pid_t pid, \
caddr_t addr, int data); }
27 NOARGS { ssize_t sys_recvmsg(int s, struct msghdr *msg, \
int flags); }
28 NOARGS { ssize_t sys_sendmsg(int s, \

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_notify.c,v 1.6 2003/11/18 11:20:34 manu Exp $ */
/* $NetBSD: mach_notify.c,v 1.7 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.6 2003/11/18 11:20:34 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_notify.c,v 1.7 2003/11/20 07:12:34 manu Exp $");
#include "opt_ktrace.h"
#include "opt_compat_mach.h" /* For COMPAT_MACH in <sys/ktrace.h> */
@ -194,11 +194,11 @@ mach_notify_port_dead_name(l, mr)
* Mach does not use signals, so mach_trapsignal will not try to send
* any signal. But systems based on Mach (e.g.: Darwin), can use both
* Mach exceptions and UNIX signals. In order to allow the Mach layer
* to intercept the exception and inhiubit UNIX signals, we have
* to intercept the exception and inhibit UNIX signals, we have
* mach_trapsignal1 returning an error. If it returns 0, then the
* exception was intercepted at the Mach level, and no signal should
* be produced. Else, a signal might be sent. darwin_trapinfo calls
* mach_trapinfo1 and handle signls if it gets a non zero return value.
* mach_trapinfo1 and handle signals if it gets a non zero return value.
*/
void
mach_trapsignal(l, ksi)
@ -216,17 +216,11 @@ mach_trapsignal1(l, ksi)
{
struct proc *p = l->l_proc;
struct mach_emuldata *med;
struct mach_port *exc_port;
struct mach_right *task;
struct mach_right *thread;
int exc_no;
int code[2];
med = (struct mach_emuldata *)p->p_emuldata;
/* XXX Thread and task should have different ports */
task = mach_right_get(med->med_kernel, l, MACH_PORT_TYPE_SEND, 0);
thread = mach_right_get(med->med_kernel, l, MACH_PORT_TYPE_SEND, 0);
switch (ksi->ksi_signo) {
case SIGILL:
exc_no = MACH_EXC_BAD_INSTRUCTION;
@ -246,20 +240,16 @@ mach_trapsignal1(l, ksi)
break;
}
if ((exc_port = med->med_exc[exc_no]) == NULL)
return EINVAL;
else
return mach_exception(l, ksi, exc_port, exc_no, task, thread);
mach_siginfo_to_exception(ksi, code);
return mach_exception(l, exc_no, code);
}
int
mach_exception(l, ksi, exc_port, exc, task, thread)
mach_exception(l, exc, code)
struct lwp *l;
const struct ksiginfo *ksi;
struct mach_port *exc_port;
int exc;
struct mach_right *task;
struct mach_right *thread;
int *code;
{
int behavior, flavor;
mach_msg_header_t *msgh;
@ -268,8 +258,18 @@ mach_exception(l, ksi, exc_port, exc, task, thread)
struct mach_emuldata *med;
struct mach_right *kernel_mr;
struct lwp *catcher_lwp;
struct mach_right *task;
struct mach_right *thread;
struct mach_port *exc_port;
int error;
if ((exc_port = med->med_exc[exc]) == NULL)
return EINVAL;
/* XXX Thread and task should have different ports */
task = mach_right_get(med->med_kernel, l, MACH_PORT_TYPE_SEND, 0);
thread = mach_right_get(med->med_kernel, l, MACH_PORT_TYPE_SEND, 0);
#ifdef DIAGNOSTIC
if (exc_port->mp_datatype != MACH_MP_EXC_FLAGS)
printf("mach_exception: unexpected datatype");
@ -312,7 +312,7 @@ mach_exception(l, ksi, exc_port, exc, task, thread)
req->req_task.type = 0; /* XXX */
req->req_exc = exc;
req->req_codecount = 2;
mach_siginfo_to_exception(ksi, &req->req_code[0]);
memcpy(&req->req_code[0], code, sizeof(req->req_code));
req->req_trailer.msgh_trailer_size = 8;
break;
}
@ -335,7 +335,7 @@ mach_exception(l, ksi, exc_port, exc, task, thread)
req->req_msgh.msgh_id = MACH_EXCEPTION_STATE;
req->req_exc = exc;
req->req_codecount = 2;
mach_siginfo_to_exception(ksi, &req->req_code[0]);
memcpy(&req->req_code[0], code, sizeof(req->req_code));
req->req_flavor = flavor;
mach_thread_get_state_machdep(l, flavor, req->req_state, &dc);
/* Trailer */
@ -372,7 +372,7 @@ mach_exception(l, ksi, exc_port, exc, task, thread)
req->req_task.type = 0; /* XXX */
req->req_exc = exc;
req->req_codecount = 2;
mach_siginfo_to_exception(ksi, &req->req_code[0]);
memcpy(&req->req_code[0], code, sizeof(req->req_code));
req->req_flavor = flavor;
mach_thread_get_state_machdep(l, flavor, req->req_state, &dc);
/* Trailer */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_notify.h,v 1.5 2003/11/18 01:40:18 manu Exp $ */
/* $NetBSD: mach_notify.h,v 1.6 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2003 The NetBSD Foundation, Inc.
@ -107,12 +107,13 @@ void mach_notify_port_dead_name(struct lwp *, struct mach_right *);
#define MACH_EXC_MASK_MACH_SYSCALL (1 << MACH_EXC_MACH_SYSCALL)
#define MACH_EXC_MASK_RPC_ALERT (1 << MACH_EXC_RPC_ALERT)
/* exceptions codes */
/* exceptions codes. Values < 0x10000 may be machine dependent */
#define MACH_BUS_ADRALN 1
#define MACH_SEGV_MAPERR 2
#define MACH_TRAP_BRKPT 1
#define MACH_ILL_ILLOPC 2
#define MACH_ILL_PRVOPC 3
#define MACH_SOFT_SIGNAL 0x10003
/* Exception behaviors and associated messages Id */
@ -190,8 +191,7 @@ typedef struct {
void mach_trapsignal(struct lwp *, const struct ksiginfo *);
int mach_trapsignal1(struct lwp *, const struct ksiginfo *);
int mach_exception(struct lwp *, const struct ksiginfo *,
struct mach_port *, int, struct mach_right *, struct mach_right *);
int mach_exception(struct lwp *, int, int *);
#endif /* _MACH_NOTIFICATION_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_syscall.h,v 1.11 2003/01/18 23:38:35 thorpej Exp $ */
/* $NetBSD: mach_syscall.h,v 1.12 2003/11/20 07:12:34 manu Exp $ */
/*
* System call numbers.

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_syscallargs.h,v 1.11 2003/01/18 23:38:36 thorpej Exp $ */
/* $NetBSD: mach_syscallargs.h,v 1.12 2003/11/20 07:12:34 manu Exp $ */
/*
* System call argument lists.
@ -166,34 +166,65 @@ struct mach_sys_timer_cancel_args {
*/
int mach_sys_reply_port(struct lwp *, void *, register_t *);
int mach_sys_thread_self_trap(struct lwp *, void *, register_t *);
int mach_sys_task_self_trap(struct lwp *, void *, register_t *);
int mach_sys_host_self_trap(struct lwp *, void *, register_t *);
int mach_sys_msg_trap(struct lwp *, void *, register_t *);
int mach_sys_msg_overwrite_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_signal_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_signal_all_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_signal_thread_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_wait_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_wait_signal_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_timedwait_trap(struct lwp *, void *, register_t *);
int mach_sys_semaphore_timedwait_signal_trap(struct lwp *, void *, register_t *);
int mach_sys_init_process(struct lwp *, void *, register_t *);
int mach_sys_map_fd(struct lwp *, void *, register_t *);
int mach_sys_task_for_pid(struct lwp *, void *, register_t *);
int mach_sys_pid_for_task(struct lwp *, void *, register_t *);
int mach_sys_macx_swapon(struct lwp *, void *, register_t *);
int mach_sys_macx_swapoff(struct lwp *, void *, register_t *);
int mach_sys_macx_triggers(struct lwp *, void *, register_t *);
int mach_sys_swtch_pri(struct lwp *, void *, register_t *);
int mach_sys_swtch(struct lwp *, void *, register_t *);
int mach_sys_syscall_thread_switch(struct lwp *, void *, register_t *);
int mach_sys_clock_sleep_trap(struct lwp *, void *, register_t *);
int mach_sys_timebase_info(struct lwp *, void *, register_t *);
int mach_sys_wait_until(struct lwp *, void *, register_t *);
int mach_sys_timer_create(struct lwp *, void *, register_t *);
int mach_sys_timer_destroy(struct lwp *, void *, register_t *);
int mach_sys_timer_arm(struct lwp *, void *, register_t *);
int mach_sys_timer_cancel(struct lwp *, void *, register_t *);
int mach_sys_get_time_base_info(struct lwp *, void *, register_t *);
#endif /* _MACH_SYS__SYSCALLARGS_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_syscalls.c,v 1.11 2003/01/18 23:38:36 thorpej Exp $ */
/* $NetBSD: mach_syscalls.c,v 1.12 2003/11/20 07:12:34 manu Exp $ */
/*
* System call names.
@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_syscalls.c,v 1.11 2003/01/18 23:38:36 thorpej Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_syscalls.c,v 1.12 2003/11/20 07:12:34 manu Exp $");
#if defined(_KERNEL_OPT)
#if defined(_KERNEL_OPT)

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_sysent.c,v 1.12 2003/11/16 01:14:07 manu Exp $ */
/* $NetBSD: mach_sysent.c,v 1.13 2003/11/20 07:12:34 manu Exp $ */
/*
* System call switch table.
@ -8,7 +8,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_sysent.c,v 1.12 2003/11/16 01:14:07 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_sysent.c,v 1.13 2003/11/20 07:12:34 manu Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ntp.h"

View File

@ -1,4 +1,4 @@
/* $NetBSD: mach_task.c,v 1.36 2003/11/18 01:40:18 manu Exp $ */
/* $NetBSD: mach_task.c,v 1.37 2003/11/20 07:12:34 manu Exp $ */
/*-
* Copyright (c) 2002-2003 The NetBSD Foundation, Inc.
@ -39,7 +39,7 @@
#include "opt_compat_darwin.h"
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.36 2003/11/18 01:40:18 manu Exp $");
__KERNEL_RCSID(0, "$NetBSD: mach_task.c,v 1.37 2003/11/20 07:12:34 manu Exp $");
#include <sys/types.h>
#include <sys/param.h>
@ -436,8 +436,8 @@ mach_task_set_exception_ports(args)
med->med_exc[MACH_EXC_RPC_ALERT] = mp;
#ifdef DEBUG_MACH
if (req->req_mask & (MACH_EXC_ARITHMETIC | MACH_EXC_EMULATION |
MACH_EXC_MASK_SOFTWARE | MACH_EXC_MASK_SYSCALL |
if (req->req_mask & (MACH_EXC_ARITHMETIC |
MACH_EXC_EMULATION | MACH_EXC_MASK_SYSCALL |
MACH_EXC_MASK_MACH_SYSCALL | MACH_EXC_RPC_ALERT))
printf("mach_set_exception_ports: some exceptions are "
"not supported (mask %x)\n", req->req_mask);