Deleted Added
full compact
subr_syscall.c (5455) subr_syscall.c (5603)
1/*-
2 * Copyright (C) 1994, David Greenman
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the University of Utah, and William Jolitz.
8 *

--- 21 unchanged lines hidden (view full) ---

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91
1/*-
2 * Copyright (C) 1994, David Greenman
3 * Copyright (c) 1990, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * the University of Utah, and William Jolitz.
8 *

--- 21 unchanged lines hidden (view full) ---

30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * SUCH DAMAGE.
36 *
37 * from: @(#)trap.c 7.4 (Berkeley) 5/13/91
38 * $Id: trap.c,v 1.42 1994/12/24 07:22:58 bde Exp $
38 * $Id: trap.c,v 1.43 1995/01/09 16:04:39 davidg Exp $
39 */
40
41/*
42 * 386 Trap and System call handling
43 */
44
45#include <sys/param.h>
46#include <sys/systm.h>

--- 21 unchanged lines hidden (view full) ---

68#include "isa.h"
69#include "npx.h"
70
71int trap_pfault __P((struct trapframe *, int));
72void trap_fatal __P((struct trapframe *));
73
74#define MAX_TRAP_MSG 27
75char *trap_msg[] = {
39 */
40
41/*
42 * 386 Trap and System call handling
43 */
44
45#include <sys/param.h>
46#include <sys/systm.h>

--- 21 unchanged lines hidden (view full) ---

68#include "isa.h"
69#include "npx.h"
70
71int trap_pfault __P((struct trapframe *, int));
72void trap_fatal __P((struct trapframe *));
73
74#define MAX_TRAP_MSG 27
75char *trap_msg[] = {
76 "reserved addressing fault", /* 0 T_RESADFLT */
76 "", /* 0 unused */
77 "privileged instruction fault", /* 1 T_PRIVINFLT */
77 "privileged instruction fault", /* 1 T_PRIVINFLT */
78 "reserved operand fault", /* 2 T_RESOPFLT */
78 "", /* 2 unused */
79 "breakpoint instruction fault", /* 3 T_BPTFLT */
80 "", /* 4 unused */
79 "breakpoint instruction fault", /* 3 T_BPTFLT */
80 "", /* 4 unused */
81 "system call trap", /* 5 T_SYSCALL */
81 "", /* 5 unused */
82 "arithmetic trap", /* 6 T_ARITHTRAP */
83 "system forced exception", /* 7 T_ASTFLT */
82 "arithmetic trap", /* 6 T_ARITHTRAP */
83 "system forced exception", /* 7 T_ASTFLT */
84 "segmentation (limit) fault", /* 8 T_SEGFLT */
84 "", /* 8 unused */
85 "general protection fault", /* 9 T_PROTFLT */
86 "trace trap", /* 10 T_TRCTRAP */
87 "", /* 11 unused */
88 "page fault", /* 12 T_PAGEFLT */
85 "general protection fault", /* 9 T_PROTFLT */
86 "trace trap", /* 10 T_TRCTRAP */
87 "", /* 11 unused */
88 "page fault", /* 12 T_PAGEFLT */
89 "page table fault", /* 13 T_TABLEFLT */
89 "", /* 13 unused */
90 "alignment fault", /* 14 T_ALIGNFLT */
90 "alignment fault", /* 14 T_ALIGNFLT */
91 "kernel stack pointer not valid", /* 15 T_KSPNOTVAL */
92 "bus error", /* 16 T_BUSERR */
93 "kernel debugger fault", /* 17 T_KDBTRAP */
91 "", /* 15 unused */
92 "", /* 16 unused */
93 "", /* 17 unused */
94 "integer divide fault", /* 18 T_DIVIDE */
95 "non-maskable interrupt trap", /* 19 T_NMI */
96 "overflow trap", /* 20 T_OFLOW */
97 "FPU bounds check fault", /* 21 T_BOUND */
98 "FPU device not available", /* 22 T_DNA */
99 "double fault", /* 23 T_DOUBLEFLT */
100 "FPU operand fetch fault", /* 24 T_FPOPFLT */
101 "invalid TSS fault", /* 25 T_TSSFLT */

--- 60 unchanged lines hidden (view full) ---

162{
163 struct proc *p = curproc;
164 u_quad_t sticks = 0;
165 int i = 0, ucode = 0, type, code;
166#ifdef DIAGNOSTIC
167 u_long eva;
168#endif
169
94 "integer divide fault", /* 18 T_DIVIDE */
95 "non-maskable interrupt trap", /* 19 T_NMI */
96 "overflow trap", /* 20 T_OFLOW */
97 "FPU bounds check fault", /* 21 T_BOUND */
98 "FPU device not available", /* 22 T_DNA */
99 "double fault", /* 23 T_DOUBLEFLT */
100 "FPU operand fetch fault", /* 24 T_FPOPFLT */
101 "invalid TSS fault", /* 25 T_TSSFLT */

--- 60 unchanged lines hidden (view full) ---

162{
163 struct proc *p = curproc;
164 u_quad_t sticks = 0;
165 int i = 0, ucode = 0, type, code;
166#ifdef DIAGNOSTIC
167 u_long eva;
168#endif
169
170 frame.tf_eflags &= ~PSL_NT; /* clear nested trap XXX */
171 type = frame.tf_trapno;
172 code = frame.tf_err;
173
174 if (ISPL(frame.tf_cs) == SEL_UPL) {
175 /* user trap */
176
177 sticks = p->p_sticks;
178 p->p_md.md_regs = (int *)&frame;
179
180 switch (type) {
170 type = frame.tf_trapno;
171 code = frame.tf_err;
172
173 if (ISPL(frame.tf_cs) == SEL_UPL) {
174 /* user trap */
175
176 sticks = p->p_sticks;
177 p->p_md.md_regs = (int *)&frame;
178
179 switch (type) {
181 case T_RESADFLT: /* reserved addressing fault */
182 case T_PRIVINFLT: /* privileged instruction fault */
180 case T_PRIVINFLT: /* privileged instruction fault */
183 case T_RESOPFLT: /* reserved operand fault */
184 ucode = type;
185 i = SIGILL;
186 break;
187
188 case T_BPTFLT: /* bpt instruction fault */
189 case T_TRCTRAP: /* trace trap */
190 frame.tf_eflags &= ~PSL_T;
191 i = SIGTRAP;

--- 11 unchanged lines hidden (view full) ---

203 addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
204 p->p_flag &= ~P_OWEUPC;
205 }
206 goto out;
207
208 case T_PROTFLT: /* general protection fault */
209 case T_SEGNPFLT: /* segment not present fault */
210 case T_STKFLT: /* stack fault */
181 ucode = type;
182 i = SIGILL;
183 break;
184
185 case T_BPTFLT: /* bpt instruction fault */
186 case T_TRCTRAP: /* trace trap */
187 frame.tf_eflags &= ~PSL_T;
188 i = SIGTRAP;

--- 11 unchanged lines hidden (view full) ---

200 addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
201 p->p_flag &= ~P_OWEUPC;
202 }
203 goto out;
204
205 case T_PROTFLT: /* general protection fault */
206 case T_SEGNPFLT: /* segment not present fault */
207 case T_STKFLT: /* stack fault */
208 case T_TSSFLT: /* invalid TSS fault */
209 case T_DOUBLEFLT: /* double fault */
210 default:
211 ucode = code + BUS_SEGM_FAULT ;
212 i = SIGBUS;
213 break;
214
215 case T_PAGEFLT: /* page fault */
216 i = trap_pfault(&frame, TRUE);
217 if (i == -1)
218 return;

--- 52 unchanged lines hidden (view full) ---

271 ucode = FPE_FPU_NP_TRAP;
272#endif /* MATH_EMULATE || GPL_MATH_EMULATE */
273 break;
274
275 case T_FPOPFLT: /* FPU operand fetch fault */
276 ucode = T_FPOPFLT;
277 i = SIGILL;
278 break;
211 ucode = code + BUS_SEGM_FAULT ;
212 i = SIGBUS;
213 break;
214
215 case T_PAGEFLT: /* page fault */
216 i = trap_pfault(&frame, TRUE);
217 if (i == -1)
218 return;

--- 52 unchanged lines hidden (view full) ---

271 ucode = FPE_FPU_NP_TRAP;
272#endif /* MATH_EMULATE || GPL_MATH_EMULATE */
273 break;
274
275 case T_FPOPFLT: /* FPU operand fetch fault */
276 ucode = T_FPOPFLT;
277 i = SIGILL;
278 break;
279
280 default:
281 trap_fatal(&frame);
282 return;
283 }
284 } else {
285 /* kernel trap */
286
287 switch (type) {
288 case T_PAGEFLT: /* page fault */
289 (void) trap_pfault(&frame, FALSE);
290 return;
291
292 case T_PROTFLT: /* general protection fault */
293 case T_SEGNPFLT: /* segment not present fault */
279 }
280 } else {
281 /* kernel trap */
282
283 switch (type) {
284 case T_PAGEFLT: /* page fault */
285 (void) trap_pfault(&frame, FALSE);
286 return;
287
288 case T_PROTFLT: /* general protection fault */
289 case T_SEGNPFLT: /* segment not present fault */
290 /*
291 * Invalid segment selectors and out of bounds
292 * %eip's and %esp's can be set up in user mode.
293 * This causes a fault in kernel mode when the
294 * kernel tries to return to user mode. We want
295 * to get this fault so that we can fix the
296 * problem here and not have to check all the
297 * selectors and pointers when the user changes
298 * them.
299 */
300#define MAYBE_DORETI_FAULT(where, whereto) \
301 do { \
302 extern void where(void) __asm(__STRING(where)); \
303 extern void whereto(void) __asm(__STRING(whereto)); \
304 if (frame.tf_eip == (int)where) { \
305 frame.tf_eip = (int)whereto; \
306 return; \
307 } \
308 } while (0)
309
310 if (intr_nesting_level == 0) {
311 MAYBE_DORETI_FAULT(doreti_iret,
312 doreti_iret_fault);
313 MAYBE_DORETI_FAULT(doreti_popl_ds,
314 doreti_popl_ds_fault);
315 MAYBE_DORETI_FAULT(doreti_popl_es,
316 doreti_popl_es_fault);
317 }
294 if (curpcb && curpcb->pcb_onfault) {
295 frame.tf_eip = (int)curpcb->pcb_onfault;
296 return;
297 }
298 break;
299
318 if (curpcb && curpcb->pcb_onfault) {
319 frame.tf_eip = (int)curpcb->pcb_onfault;
320 return;
321 }
322 break;
323
324 case T_TSSFLT:
325 /*
326 * PSL_NT can be set in user mode and isn't cleared
327 * automatically when the kernel is entered. This
328 * causes a TSS fault when the kernel attempts to
329 * `iret' because the TSS link is uninitialized. We
330 * want to get this fault so that we can fix the
331 * problem here and not every time the kernel is
332 * entered.
333 */
334 if (frame.tf_eflags & PSL_NT) {
335 frame.tf_eflags &= ~PSL_NT;
336 return;
337 }
338 break;
339
300#ifdef DDB
301 case T_BPTFLT:
302 case T_TRCTRAP:
303 if (kdb_trap (type, 0, &frame))
304 return;
305 break;
306#else
307 case T_TRCTRAP: /* trace trap -- someone single stepping lcall's */

--- 410 unchanged lines hidden ---
340#ifdef DDB
341 case T_BPTFLT:
342 case T_TRCTRAP:
343 if (kdb_trap (type, 0, &frame))
344 return;
345 break;
346#else
347 case T_TRCTRAP: /* trace trap -- someone single stepping lcall's */

--- 410 unchanged lines hidden ---