summaryrefslogtreecommitdiff
path: root/sys/arch/i386
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2015-06-28 01:11:28 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2015-06-28 01:11:28 +0000
commitc8f5fb546e9d2dbb857809a2be3e79f9b9db2c84 (patch)
tree275d7b3fc59e03c1a1a7762dac315ca34b181fe4 /sys/arch/i386
parent8d4b52690835329b08f9bf4c8b83728bc079af80 (diff)
Split AST handling from trap() into ast() and get rid of T_ASTFLT
testing by krw@, and then many via snapshots
Diffstat (limited to 'sys/arch/i386')
-rw-r--r--sys/arch/i386/i386/apicvec.s20
-rw-r--r--sys/arch/i386/i386/db_trace.c8
-rw-r--r--sys/arch/i386/i386/kgdb_machdep.c3
-rw-r--r--sys/arch/i386/i386/locore.s14
-rw-r--r--sys/arch/i386/i386/trap.c33
-rw-r--r--sys/arch/i386/i386/vector.s8
-rw-r--r--sys/arch/i386/include/trap.h5
-rw-r--r--sys/arch/i386/isa/icu.s6
8 files changed, 51 insertions, 46 deletions
diff --git a/sys/arch/i386/i386/apicvec.s b/sys/arch/i386/i386/apicvec.s
index 6de0c7eebcf..237def059bf 100644
--- a/sys/arch/i386/i386/apicvec.s
+++ b/sys/arch/i386/i386/apicvec.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: apicvec.s,v 1.29 2015/02/07 00:26:37 deraadt Exp $ */
+/* $OpenBSD: apicvec.s,v 1.30 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: apicvec.s,v 1.1.2.2 2000/02/21 21:54:01 sommerfeld Exp $ */
/*-
@@ -42,8 +42,7 @@
#ifdef MULTIPROCESSOR
.globl XINTR(ipi)
XINTR(ipi):
- pushl $0
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
MAKE_FRAME
pushl CPL
@@ -156,8 +155,7 @@ XINTR(ipi_reloadcr3):
*/
.globl XINTR(ltimer)
XINTR(ltimer):
- pushl $0
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
MAKE_FRAME
pushl CPL
@@ -175,8 +173,7 @@ XINTR(ltimer):
.globl XINTR(softclock), XINTR(softnet), XINTR(softtty)
XINTR(softclock):
- pushl $0
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
MAKE_FRAME
pushl CPL
@@ -198,8 +195,7 @@ XINTR(softclock):
jmp _C_LABEL(Xdoreti)
XINTR(softnet):
- pushl $0
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
MAKE_FRAME
pushl CPL
@@ -222,8 +218,7 @@ XINTR(softnet):
#undef DONETISR
XINTR(softtty):
- pushl $0
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
MAKE_FRAME
pushl CPL
@@ -258,8 +253,7 @@ XINTR(softtty):
#define APICINTR(name, num, early_ack, late_ack, mask, unmask, level_mask) \
_C_LABEL(Xintr_##name##num): \
- pushl $0 ;\
- pushl $T_ASTFLT ;\
+ subl $8,%esp /* space for tf_{err,trapno} */ ;\
INTRENTRY ;\
MAKE_FRAME ;\
pushl CPL ;\
diff --git a/sys/arch/i386/i386/db_trace.c b/sys/arch/i386/i386/db_trace.c
index 291b9e9cb0f..a8cf498e4cd 100644
--- a/sys/arch/i386/i386/db_trace.c
+++ b/sys/arch/i386/i386/db_trace.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_trace.c,v 1.14 2014/07/13 12:11:01 jasper Exp $ */
+/* $OpenBSD: db_trace.c,v 1.15 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: db_trace.c,v 1.18 1996/05/03 19:42:01 christos Exp $ */
/*
@@ -78,6 +78,7 @@ struct i386_frame {
#define TRAP 1
#define SYSCALL 2
#define INTERRUPT 3
+#define AST 4
db_addr_t db_trap_symbol_value = 0;
db_addr_t db_syscall_symbol_value = 0;
@@ -161,6 +162,9 @@ db_nextframe(struct i386_frame **fp, db_addr_t *ip, int *argp, int is_trap,
case TRAP:
(*pr)("--- trap (number %d) ---\n", tf->tf_trapno);
break;
+ case AST:
+ (*pr)("--- ast ---\n");
+ break;
case SYSCALL:
(*pr)("--- syscall (number %d) ---\n", tf->tf_eax);
break;
@@ -256,6 +260,8 @@ db_stack_trace_print(db_expr_t addr, boolean_t have_addr, db_expr_t count,
if (INKERNEL((int)frame) && name) {
if (!strcmp(name, "trap")) {
is_trap = TRAP;
+ } else if (!strcmp(name, "ast")) {
+ is_trap = AST;
} else if (!strcmp(name, "syscall")) {
is_trap = SYSCALL;
} else if (!strncmp(name, "Xintr", 5) ||
diff --git a/sys/arch/i386/i386/kgdb_machdep.c b/sys/arch/i386/i386/kgdb_machdep.c
index 245f9bba3da..1a46515fd7c 100644
--- a/sys/arch/i386/i386/kgdb_machdep.c
+++ b/sys/arch/i386/i386/kgdb_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kgdb_machdep.c,v 1.12 2015/04/12 18:37:53 mlarkin Exp $ */
+/* $OpenBSD: kgdb_machdep.c,v 1.13 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: kgdb_machdep.c,v 1.6 1998/08/13 21:36:03 thorpej Exp $ */
/*-
@@ -115,7 +115,6 @@ kgdb_signal(int type)
case T_TRCTRAP:
return (SIGTRAP);
- case T_ASTFLT:
case T_DOUBLEFLT:
return (SIGEMT);
diff --git a/sys/arch/i386/i386/locore.s b/sys/arch/i386/i386/locore.s
index cea9a8437ba..9bd21dc7f53 100644
--- a/sys/arch/i386/i386/locore.s
+++ b/sys/arch/i386/i386/locore.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: locore.s,v 1.157 2015/04/26 09:48:29 kettenis Exp $ */
+/* $OpenBSD: locore.s,v 1.158 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: locore.s,v 1.145 1996/05/03 19:41:19 christos Exp $ */
/*-
@@ -1408,8 +1408,7 @@ IDTVEC(fpu)
* error. It would be better to handle npx interrupts as traps but
* this is difficult for nested interrupts.
*/
- pushl $0 # dummy error code
- pushl $T_ASTFLT
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
pushl CPL # if_ppl in intrframe
pushl %esp # push address of intrframe
@@ -1471,9 +1470,8 @@ calltrap:
jz 1f
5: CLEAR_ASTPENDING(%ecx)
sti
- movl $T_ASTFLT,TF_TRAPNO(%esp)
pushl %esp
- call _C_LABEL(trap)
+ call _C_LABEL(ast)
addl $4,%esp
jmp 2b
#ifndef DIAGNOSTIC
@@ -1498,8 +1496,7 @@ calltrap:
* Trap gate entry for syscall
*/
IDTVEC(syscall)
- pushl $2 # ignored
- pushl $T_ASTFLT # trap # for doing ASTs
+ subl $8,%esp /* space for tf_{err,trapno} */
INTRENTRY
pushl %esp
call _C_LABEL(syscall)
@@ -1511,9 +1508,8 @@ IDTVEC(syscall)
/* Always returning to user mode here. */
CLEAR_ASTPENDING(%ecx)
sti
- /* Pushed T_ASTFLT into tf_trapno on entry. */
pushl %esp
- call _C_LABEL(trap)
+ call _C_LABEL(ast)
addl $4,%esp
jmp 2b
1: INTRFASTEXIT
diff --git a/sys/arch/i386/i386/trap.c b/sys/arch/i386/i386/trap.c
index 9843a2bac92..55f45f87a59 100644
--- a/sys/arch/i386/i386/trap.c
+++ b/sys/arch/i386/i386/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.122 2015/04/24 12:52:38 kettenis Exp $ */
+/* $OpenBSD: trap.c,v 1.123 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: trap.c,v 1.95 1996/05/05 06:50:02 mycroft Exp $ */
/*-
@@ -80,13 +80,14 @@ extern struct emul emul_linux_elf;
#include "npx.h"
void trap(struct trapframe *);
+void ast(struct trapframe *);
void syscall(struct trapframe *);
char *trap_type[] = {
"privileged instruction fault", /* 0 T_PRIVINFLT */
"breakpoint trap", /* 1 T_BPTFLT */
"arithmetic trap", /* 2 T_ARITHTRAP */
- "asynchronous system trap", /* 3 T_ASTFLT */
+ "reserved trap", /* 3 T_RESERVED */
"protection fault", /* 4 T_PROTFLT */
"trace trap", /* 5 T_TRCTRAP */
"page fault", /* 6 T_PAGEFLT */
@@ -103,7 +104,6 @@ char *trap_type[] = {
"stack fault", /* 17 T_STKFLT */
"machine check", /* 18 T_MACHK ([P]Pro) */
"SIMD FP fault", /* 19 T_XFTRAP */
- "reserved trap", /* 20 T_RESERVED */
};
int trap_types = sizeof trap_type / sizeof trap_type[0];
@@ -118,7 +118,6 @@ int trapdebug = 0;
* routines that prepare a suitable stack frame, and restore this
* frame after the exception has been processed.
*/
-/*ARGSUSED*/
void
trap(struct trapframe *frame)
{
@@ -335,11 +334,6 @@ trap(struct trapframe *frame)
KERNEL_UNLOCK();
goto out;
- case T_ASTFLT|T_USER: /* Allow process switch */
- uvmexp.softs++;
- mi_ast(p, want_resched);
- goto out;
-
case T_DNA|T_USER: {
printf("pid %d killed due to lack of floating point\n",
p->p_pid);
@@ -522,6 +516,27 @@ out:
userret(p);
}
+
+/*
+ * ast(frame):
+ * AST handler. This is called from assembly language stubs when
+ * returning to userspace after a syscall, trap, or interrupt.
+ */
+void
+ast(struct trapframe *frame)
+{
+ struct proc *p = curproc;
+
+ uvmexp.traps++;
+ KASSERT(!KERNELMODE(frame->tf_cs, frame->tf_eflags));
+ p->p_md.md_regs = frame;
+ refreshcreds(p);
+ uvmexp.softs++;
+ mi_ast(p, want_resched);
+ userret(p);
+}
+
+
/*
* syscall(frame):
* System call request from POSIX system call gate interface to kernel.
diff --git a/sys/arch/i386/i386/vector.s b/sys/arch/i386/i386/vector.s
index 8f3aadff113..7ed63cf7fbe 100644
--- a/sys/arch/i386/i386/vector.s
+++ b/sys/arch/i386/i386/vector.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: vector.s,v 1.19 2015/04/25 21:31:24 guenther Exp $ */
+/* $OpenBSD: vector.s,v 1.20 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: vector.s,v 1.32 1996/01/07 21:29:47 mycroft Exp $ */
/*
@@ -80,8 +80,7 @@ IDTVEC(recurse_##name##num) ;\
pushfl ;\
pushl %cs ;\
pushl %esi ;\
- pushl $0 /* dummy error code */ ;\
- pushl $T_ASTFLT /* trap # for doing ASTs */ ;\
+ subl $8,%esp /* space for tf_{err,trapno} */ ;\
movl %ebx,%esi ;\
INTRENTRY ;\
MAKE_FRAME ;\
@@ -89,8 +88,7 @@ IDTVEC(recurse_##name##num) ;\
cli ;\
jmp 1f ;\
_C_LABEL(Xintr_##name##num): ;\
- pushl $0 /* dummy error code */ ;\
- pushl $T_ASTFLT /* trap # for doing ASTs */ ;\
+ subl $8,%esp /* space for tf_{err,trapno} */ ;\
INTRENTRY ;\
MAKE_FRAME ;\
mask(num) /* mask it in hardware */ ;\
diff --git a/sys/arch/i386/include/trap.h b/sys/arch/i386/include/trap.h
index 652bfbf9f1b..a93fee7c3ba 100644
--- a/sys/arch/i386/include/trap.h
+++ b/sys/arch/i386/include/trap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.h,v 1.5 2005/10/26 20:32:59 marco Exp $ */
+/* $OpenBSD: trap.h,v 1.6 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: trap.h,v 1.4 1994/10/27 04:16:30 cgd Exp $ */
/*-
@@ -43,7 +43,7 @@
#define T_PRIVINFLT 0 /* privileged instruction */
#define T_BPTFLT 1 /* breakpoint trap */
#define T_ARITHTRAP 2 /* arithmetic trap */
-#define T_ASTFLT 3 /* asynchronous system trap */
+#define T_RESERVED 3 /* reserved fault base */
#define T_PROTFLT 4 /* protection fault */
#define T_TRCTRAP 5 /* trace trap */
#define T_PAGEFLT 6 /* page fault */
@@ -60,7 +60,6 @@
#define T_STKFLT 17 /* stack fault */
#define T_MACHK 18 /* machine check ([P]Pro) */
#define T_XFTRAP 19 /* SIMD FP exception */
-#define T_RESERVED 20 /* reserved fault base */
/* Trap's coming from user mode */
#define T_USER 0x100
diff --git a/sys/arch/i386/isa/icu.s b/sys/arch/i386/isa/icu.s
index 2d83f61843a..8b77101f110 100644
--- a/sys/arch/i386/isa/icu.s
+++ b/sys/arch/i386/isa/icu.s
@@ -1,4 +1,4 @@
-/* $OpenBSD: icu.s,v 1.31 2010/12/21 14:56:23 claudio Exp $ */
+/* $OpenBSD: icu.s,v 1.32 2015/06/28 01:11:27 guenther Exp $ */
/* $NetBSD: icu.s,v 1.45 1996/01/07 03:59:34 mycroft Exp $ */
/*-
@@ -103,10 +103,8 @@ IDTVEC(doreti)
jz 3f
4: CLEAR_ASTPENDING(%ecx)
sti
- movl $T_ASTFLT,TF_TRAPNO(%esp) /* XXX undo later. */
- /* Pushed T_ASTFLT into tf_trapno on entry. */
pushl %esp
- call _C_LABEL(trap)
+ call _C_LABEL(ast)
addl $4,%esp
cli
jmp 2b