summaryrefslogtreecommitdiff
path: root/sys/arch
diff options
context:
space:
mode:
authorNikolay Sturm <sturm@cvs.openbsd.org>2004-05-13 20:20:25 +0000
committerNikolay Sturm <sturm@cvs.openbsd.org>2004-05-13 20:20:25 +0000
commit4268cc6c2417477493619708f48678f3eb8ff22f (patch)
tree62d05c086f5a5f5d47ef70f78c071ca01ccb777b /sys/arch
parent2125db2d855a542bbe0dcdf2ad4f173f365b6e1a (diff)
activate systrace on amd64, while here get rid of syscall_{plain,fancy}
instead use syscall() as everywhere else ok mickey, tested and ok tedu@
Diffstat (limited to 'sys/arch')
-rw-r--r--sys/arch/amd64/amd64/genassym.cf3
-rw-r--r--sys/arch/amd64/amd64/locore.S6
-rw-r--r--sys/arch/amd64/amd64/machdep.c5
-rw-r--r--sys/arch/amd64/amd64/syscall.c149
-rw-r--r--sys/arch/amd64/amd64/vm_machdep.c4
-rw-r--r--sys/arch/amd64/include/proc.h4
6 files changed, 17 insertions, 154 deletions
diff --git a/sys/arch/amd64/amd64/genassym.cf b/sys/arch/amd64/amd64/genassym.cf
index 52dbec0bdb5..de6ab55ca81 100644
--- a/sys/arch/amd64/amd64/genassym.cf
+++ b/sys/arch/amd64/amd64/genassym.cf
@@ -1,4 +1,4 @@
-# $OpenBSD: genassym.cf,v 1.2 2004/02/07 17:00:12 miod Exp $
+# $OpenBSD: genassym.cf,v 1.3 2004/05/13 20:20:24 sturm Exp $
# Written by Artur Grabowski art@openbsd.org, Public Domain
@@ -38,7 +38,6 @@ member p_wchan
member P_MD_TSS_SEL p_md.md_tss_sel
member P_MD_REGS p_md.md_regs
member P_MD_FLAGS p_md.md_flags
-member P_MD_SYSCALL p_md.md_syscall
member P_MD_ASTPENDING p_md.md_astpending
member p_flag
diff --git a/sys/arch/amd64/amd64/locore.S b/sys/arch/amd64/amd64/locore.S
index e7aa2ffb9fe..a61e1719e61 100644
--- a/sys/arch/amd64/amd64/locore.S
+++ b/sys/arch/amd64/amd64/locore.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.S,v 1.9 2004/02/25 00:16:04 deraadt Exp $ */
+/* $OpenBSD: locore.S,v 1.10 2004/05/13 20:20:24 sturm Exp $ */
/* $NetBSD: locore.S,v 1.2 2003/04/26 19:34:45 fvdl Exp $ */
/*
@@ -1094,7 +1094,7 @@ IDTVEC(syscall)
movq CPUVAR(CURPROC),%r14
movq %rsp,P_MD_REGS(%r14) # save pointer to frame
andl $~MDP_IRET,P_MD_FLAGS(%r14)
- call *P_MD_SYSCALL(%r14)
+ call _C_LABEL(syscall)
1: /* Check for ASTs on exit to user mode. */
cli
CHECK_ASTPENDING(%r11)
@@ -1191,7 +1191,7 @@ osyscall1:
sti
movq CPUVAR(CURPROC),%rdx
movq %rsp,P_MD_REGS(%rdx) # save pointer to frame
- call *P_MD_SYSCALL(%rdx)
+ call _C_LABEL(syscall)
_C_LABEL(osyscall_return):
2: /* Check for ASTs on exit to user mode. */
cli
diff --git a/sys/arch/amd64/amd64/machdep.c b/sys/arch/amd64/amd64/machdep.c
index 8fa5af7a800..2d8b3eb11aa 100644
--- a/sys/arch/amd64/amd64/machdep.c
+++ b/sys/arch/amd64/amd64/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.23 2004/05/05 16:43:53 marc Exp $ */
+/* $OpenBSD: machdep.c,v 1.24 2004/05/13 20:20:24 sturm Exp $ */
/* $NetBSD: machdep.c,v 1.3 2003/05/07 22:58:18 fvdl Exp $ */
/*-
@@ -245,7 +245,6 @@ int cpu_dumpsize(void);
u_long cpu_dump_mempagecnt(void);
void dumpsys(void);
void init_x86_64(paddr_t);
-void syscall_intern(struct proc *p);
#ifdef APERTURE
#ifdef INSECURE
@@ -1157,8 +1156,6 @@ setregs(struct proc *p, struct exec_package *pack, u_long stack,
pmap_ldt_cleanup(p);
#endif
- syscall_intern(p);
-
p->p_md.md_flags &= ~MDP_USEDFPU;
pcb->pcb_flags = 0;
pcb->pcb_savefpu.fp_fxsave.fx_fcw = __OpenBSD_NPXCW__;
diff --git a/sys/arch/amd64/amd64/syscall.c b/sys/arch/amd64/amd64/syscall.c
index 0320aeec741..f41166b80a0 100644
--- a/sys/arch/amd64/amd64/syscall.c
+++ b/sys/arch/amd64/amd64/syscall.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syscall.c,v 1.6 2004/02/19 18:43:32 deraadt Exp $ */
+/* $OpenBSD: syscall.c,v 1.7 2004/05/13 20:20:24 sturm Exp $ */
/* $NetBSD: syscall.c,v 1.1 2003/04/26 18:39:32 fvdl Exp $ */
/*-
@@ -45,9 +45,10 @@
#ifdef KTRACE
#include <sys/ktrace.h>
#endif
-#ifdef SYSTRACE
-#include <sys/systrace.h>
-#endif
+
+#include "systrace.h"
+#include <dev/systrace.h>
+
#include <sys/syscall.h>
#include <uvm/uvm_extern.h>
@@ -56,28 +57,7 @@
#include <machine/psl.h>
#include <machine/userret.h>
-void syscall_intern(struct proc *);
-void syscall_plain(struct trapframe);
-void syscall_fancy(struct trapframe);
-
-void
-syscall_intern(p)
- struct proc *p;
-{
-#ifdef KTRACE
- if (p->p_traceflag & (KTRFAC_SYSCALL | KTRFAC_SYSRET)) {
- p->p_md.md_syscall = syscall_fancy;
- return;
- }
-#endif
-#ifdef SYSTRACE
- if (ISSET(p->p_flag, P_SYSTRACE)) {
- p->p_md.md_syscall = syscall_fancy;
- return;
- }
-#endif
- p->p_md.md_syscall = syscall_plain;
-}
+void syscall(struct trapframe);
/*
* syscall(frame):
@@ -85,117 +65,7 @@ syscall_intern(p)
* Like trap(), argument is call by reference.
*/
void
-syscall_plain(frame)
- struct trapframe frame;
-{
- caddr_t params;
- const struct sysent *callp;
- struct proc *p;
- int error;
- int nsys;
- size_t argsize, argoff;
- register_t code, args[9], rval[2], *argp;
-
-
- uvmexp.syscalls++;
- p = curproc;
-
- code = frame.tf_rax;
- nsys = p->p_emul->e_nsysent;
- callp = p->p_emul->e_sysent;
- argoff = 0;
- argp = &args[0];
-
- switch (code) {
- case SYS_syscall:
- case SYS___syscall:
- /*
- * Code is first argument, followed by actual args.
- */
- code = frame.tf_rdi;
- argp = &args[1];
- argoff = 1;
- break;
- default:
- break;
- }
-
- if (code < 0 || code >= nsys)
- callp += p->p_emul->e_nosys;
- else
- callp += code;
-
- argsize = (callp->sy_argsize >> 3) + argoff;
- if (argsize) {
- switch (MIN(argsize, 6)) {
- case 6:
- args[5] = frame.tf_r9;
- case 5:
- args[4] = frame.tf_r8;
- case 4:
- args[3] = frame.tf_r10;
- case 3:
- args[2] = frame.tf_rdx;
- case 2:
- args[1] = frame.tf_rsi;
- case 1:
- args[0] = frame.tf_rdi;
- break;
- default:
- panic("impossible syscall argsize");
- }
- if (argsize > 6) {
- argsize -= 6;
- params = (caddr_t)frame.tf_rsp + sizeof(register_t);
- error = copyin(params, (caddr_t)&args[6],
- argsize << 3);
- if (error != 0)
- goto bad;
- }
- }
-
-#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, argp);
-#endif /* SYSCALL_DEBUG */
-
- rval[0] = 0;
- rval[1] = frame.tf_rdx;
- KERNEL_PROC_LOCK(p);
- error = (*callp->sy_call)(p, argp, rval);
- KERNEL_PROC_UNLOCK(p);
-
- switch (error) {
- case 0:
- frame.tf_rax = rval[0];
- frame.tf_rdx = rval[1];
- frame.tf_rflags &= ~PSL_C; /* carry bit */
- break;
- case ERESTART:
- /*
- * The offset to adjust the PC by depends on whether we entered
- * the kernel through the trap or call gate. We pushed the
- * size of the instruction into tf_err on entry.
- */
- frame.tf_rip -= frame.tf_err;
- break;
- case EJUSTRETURN:
- /* nothing to do */
- break;
- default:
- bad:
- frame.tf_rax = error;
- frame.tf_rflags |= PSL_C; /* carry bit */
- break;
- }
-
-#ifdef SYSCALL_DEBUG
- scdebug_ret(p, code, error, rval);
-#endif /* SYSCALL_DEBUG */
- userret(p);
-}
-
-void
-syscall_fancy(frame)
+syscall(frame)
struct trapframe frame;
{
caddr_t params;
@@ -265,7 +135,7 @@ syscall_fancy(frame)
KERNEL_PROC_LOCK(p);
#ifdef SYSCALL_DEBUG
- scdebug_call(p, code, args);
+ scdebug_call(p, code, argp);
#endif
#ifdef KTRACE
if (KTRPOINT(p, KTR_SYSCALL))
@@ -276,7 +146,8 @@ syscall_fancy(frame)
rval[1] = frame.tf_rdx;
#if NSYSTRACE > 0
if (ISSET(p->p_flag, P_SYSTRACE))
- error = systrace_redirect(code, p, args, rval);
+ error = systrace_redirect(code, p, argp, rval);
+ else
#endif
error = (*callp->sy_call)(p, argp, rval);
KERNEL_PROC_UNLOCK(p);
diff --git a/sys/arch/amd64/amd64/vm_machdep.c b/sys/arch/amd64/amd64/vm_machdep.c
index 40d41ee2bf3..9e38904ac64 100644
--- a/sys/arch/amd64/amd64/vm_machdep.c
+++ b/sys/arch/amd64/amd64/vm_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_machdep.c,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: vm_machdep.c,v 1.2 2004/05/13 20:20:24 sturm Exp $ */
/* $NetBSD: vm_machdep.c,v 1.1 2003/04/26 18:39:33 fvdl Exp $ */
/*-
@@ -68,7 +68,6 @@
#include <machine/mtrr.h>
void setredzone(struct proc *);
-void syscall_intern(struct proc *p); /* syscall.c */
/*
* Finish a fork operation, with process p2 nearly set up.
@@ -99,7 +98,6 @@ cpu_fork(struct proc *p1, struct proc *p2, void *stack, size_t stacksize,
fpusave_proc(p1, 1);
p2->p_md.md_flags = p1->p_md.md_flags;
- syscall_intern(p2);
/* Copy pcb from proc p1 to p2. */
if (p1 == curproc) {
diff --git a/sys/arch/amd64/include/proc.h b/sys/arch/amd64/include/proc.h
index 89e8360b954..5a6cbc840e7 100644
--- a/sys/arch/amd64/include/proc.h
+++ b/sys/arch/amd64/include/proc.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proc.h,v 1.1 2004/01/28 01:39:39 mickey Exp $ */
+/* $OpenBSD: proc.h,v 1.2 2004/05/13 20:20:24 sturm Exp $ */
/* $NetBSD: proc.h,v 1.1 2003/04/26 18:39:46 fvdl Exp $ */
/*
@@ -48,8 +48,6 @@ struct mdproc {
struct trapframe *md_regs; /* registers on current frame */
int md_tss_sel; /* TSS selector */
int md_flags;
- /* Syscall handling function */
- void (*md_syscall)(struct trapframe);
__volatile int md_astpending;
};