1993-06-12 14:58:17 +00:00
|
|
|
/*-
|
1994-06-06 14:54:41 +00:00
|
|
|
* Copyright (C) 1994, David Greenman
|
|
|
|
* Copyright (c) 1990, 1993
|
|
|
|
* The Regents of the University of California. All rights reserved.
|
1993-06-12 14:58:17 +00:00
|
|
|
*
|
|
|
|
* This code is derived from software contributed to Berkeley by
|
|
|
|
* the University of Utah, and William Jolitz.
|
|
|
|
*
|
|
|
|
* 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 University of
|
|
|
|
* California, Berkeley and its contributors.
|
|
|
|
* 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
|
|
|
|
*
|
genassym.c:
Remove NKMEMCLUSTERS, it is no longer define or used.
locores.s:
Fix comment on PTDpde and APTDpde to be pde instead of pte
Add new equation for calculating location of Sysmap
Remove Bill's old #ifdef garbage for counting up memory,
that stuff will never be made to work and was just cluttering
up the file.
Add code that places the PTD, page table pages, and kernel
stack below the 640k ISA hole if there is room for it, otherwise
put this stuff all at 1MB. This fixes the 28K bogusity in
the boot blocks, that can now go away!
Fix the caclulation of where first is to be dependent on
NKPDE so that we can skip over the above mentioned areas.
The 28K thing is now 44K in size due to the increase in
kernel virtual memory space, but since we no longer have
to worry about that this is no big deal.
Use if NNPX > 0 instead of ifdef NPX for floating point code.
machdep.c
Change the calculation of for the buffer cache to be
20% of all memory above 2MB and add back the upper limit
of 2/5's of the VM_KMEM_SIZE so that we do not eat ALL
of the kernel memory space on large memory machines, note
that this will not even come into effect unless you have
more than 32MB. The current buffer cache limit is 6.7MB
due to this caclulation.
It seems that we where erroniously allocating bufpages pages
for buffer_map. buffer_map is UNUSED in this implementation
of the buffer cache, but since the map is referenced in
several if statements a quick fix was to simply allocate
1 vm page (but no real memory) to it.
pmap.h
Remove rcsid, don't want them in the kernel files!
Removed some cruft inside an #ifdef DEBUGx that caused
compiler errors if you where compiling this for debug.
Use the #defines for PD_SHIFT and PG_SHIFT in place of
constants.
trap.c:
Remove patch kit header and rcsid, fix $Id$.
Now include "npx.h" and use NNPX for controlling the
floating point code.
Remove a now completly invalid check for a maximum virtual
address, the virtual address now ends at 0xFFFFFFFF so
there is no more MAX!! (Thanks David, I completly missed
that one!)
vm_machdep.c
Remove patch kit header and rcsid, fix $Id$.
Now include "npx.h" and use NNPX for controlling the
floating point code.
Replace several 0xFE00000 constants with KERNBASE
1993-10-15 10:34:29 +00:00
|
|
|
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
|
1994-09-11 11:26:18 +00:00
|
|
|
* $Id: trap.c,v 1.33 1994/09/08 11:48:52 bde Exp $
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
1994-06-11 05:13:33 +00:00
|
|
|
* 386 Trap and System call handling
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/proc.h>
|
|
|
|
#include <sys/user.h>
|
|
|
|
#include <sys/acct.h>
|
|
|
|
#include <sys/kernel.h>
|
|
|
|
#include <sys/syscall.h>
|
1994-08-24 11:52:21 +00:00
|
|
|
#include <sys/sysent.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
#ifdef KTRACE
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <sys/ktrace.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
#include <vm/vm_param.h>
|
|
|
|
#include <vm/pmap.h>
|
|
|
|
#include <vm/vm_map.h>
|
|
|
|
#include <vm/vm_page.h>
|
|
|
|
|
|
|
|
#include <machine/cpu.h>
|
|
|
|
#include <machine/psl.h>
|
|
|
|
#include <machine/reg.h>
|
|
|
|
#include <machine/trap.h>
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
#include "isa.h"
|
|
|
|
#include "npx.h"
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
int trap_pfault __P((struct trapframe *, int));
|
|
|
|
void trap_fatal __P((struct trapframe *));
|
1993-06-12 14:58:17 +00:00
|
|
|
|
First steps in rewriting locore.s, and making info useful
when the machine panics.
i386/i386/locore.s:
1) got rid of most .set directives that were being used like
#define's, and replaced them with appropriate #define's in
the appropriate header files (accessed via genassym).
2) added comments to header inclusions and global definitions,
and global variables
3) replaced some hardcoded constants with cpp defines (such as
PDESIZE and others)
4) aligned all comments to the same column to make them easier to
read
5) moved macro definitions for ENTRY, ALIGN, NOP, etc. to
/sys/i386/include/asmacros.h
6) added #ifdef BDE_DEBUGGER around all of Bruce's debugger code
7) added new global '_KERNend' to store last location+1 of kernel
8) cleaned up zeroing of bss so that only bss is zeroed
9) fix zeroing of page tables so that it really does zero them all
- not just if they follow the bss.
10) rewrote page table initialization code so that 1) works correctly
and 2) write protects the kernel text by default
11) properly initialize the kernel page directory, upages, p0stack PT,
and page tables. The previous scheme was more than a bit
screwy.
12) change allocation of virtual area of IO hole so that it is
fixed at KERNBASE + 0xa0000. The previous scheme put it
right after the kernel page tables and then later expected
it to be at KERNBASE +0xa0000
13) change multiple bogus settings of user read/write of various
areas of kernel VM - including the IO hole; we should never
be accessing the IO hole in user mode through the kernel
page tables
14) split kernel support routines such as bcopy, bzero, copyin,
copyout, etc. into a seperate file 'support.s'
15) split swtch and related routines into a seperate 'swtch.s'
16) split routines related to traps, syscalls, and interrupts
into a seperate file 'exception.s'
17) remove some unused global variables from locore that got
inserted by Garrett when he pulled them out of some .h
files.
i386/isa/icu.s:
1) clean up global variable declarations
2) move in declaration of astpending and netisr
i386/i386/pmap.c:
1) fix calculation of virtual_avail. It previously was calculated
to be right in the middle of the kernel page tables - not
a good place to start allocating kernel VM.
2) properly allocate kernel page dir/tables etc out of kernel map
- previously only took out 2 pages.
i386/i386/machdep.c:
1) modify boot() to print a warning that the system will reboot in
PANIC_REBOOT_WAIT_TIME amount of seconds, and let the user
abort with a key on the console. The machine will wait for
ever if a key is typed before the reboot. The default is
15 seconds, but can be set to 0 to mean don't wait at all,
-1 to mean wait forever, or any positive value to wait for
that many seconds.
2) print "Rebooting..." just before doing it.
kern/subr_prf.c:
1) remove PANICWAIT as it is deprecated by the change to machdep.c
i386/i386/trap.c:
1) add table of trap type strings and use it to print a real trap/
panic message rather than just a number. Lot's of work to
be done here, but this is the first step. Symbolic traceback
is in the TODO.
i386/i386/Makefile.i386:
1) add support in to build support.s, exception.s and swtch.s
...and various changes to various header files to make all of the
above happen.
1993-11-13 02:25:21 +00:00
|
|
|
#define MAX_TRAP_MSG 27
|
|
|
|
char *trap_msg[] = {
|
|
|
|
"reserved addressing fault", /* 0 T_RESADFLT */
|
|
|
|
"privileged instruction fault", /* 1 T_PRIVINFLT */
|
|
|
|
"reserved operand fault", /* 2 T_RESOPFLT */
|
|
|
|
"breakpoint instruction fault", /* 3 T_BPTFLT */
|
|
|
|
"", /* 4 unused */
|
|
|
|
"system call trap", /* 5 T_SYSCALL */
|
|
|
|
"arithmetic trap", /* 6 T_ARITHTRAP */
|
|
|
|
"system forced exception", /* 7 T_ASTFLT */
|
|
|
|
"segmentation (limit) fault", /* 8 T_SEGFLT */
|
1994-06-06 14:54:41 +00:00
|
|
|
"general protection fault", /* 9 T_PROTFLT */
|
First steps in rewriting locore.s, and making info useful
when the machine panics.
i386/i386/locore.s:
1) got rid of most .set directives that were being used like
#define's, and replaced them with appropriate #define's in
the appropriate header files (accessed via genassym).
2) added comments to header inclusions and global definitions,
and global variables
3) replaced some hardcoded constants with cpp defines (such as
PDESIZE and others)
4) aligned all comments to the same column to make them easier to
read
5) moved macro definitions for ENTRY, ALIGN, NOP, etc. to
/sys/i386/include/asmacros.h
6) added #ifdef BDE_DEBUGGER around all of Bruce's debugger code
7) added new global '_KERNend' to store last location+1 of kernel
8) cleaned up zeroing of bss so that only bss is zeroed
9) fix zeroing of page tables so that it really does zero them all
- not just if they follow the bss.
10) rewrote page table initialization code so that 1) works correctly
and 2) write protects the kernel text by default
11) properly initialize the kernel page directory, upages, p0stack PT,
and page tables. The previous scheme was more than a bit
screwy.
12) change allocation of virtual area of IO hole so that it is
fixed at KERNBASE + 0xa0000. The previous scheme put it
right after the kernel page tables and then later expected
it to be at KERNBASE +0xa0000
13) change multiple bogus settings of user read/write of various
areas of kernel VM - including the IO hole; we should never
be accessing the IO hole in user mode through the kernel
page tables
14) split kernel support routines such as bcopy, bzero, copyin,
copyout, etc. into a seperate file 'support.s'
15) split swtch and related routines into a seperate 'swtch.s'
16) split routines related to traps, syscalls, and interrupts
into a seperate file 'exception.s'
17) remove some unused global variables from locore that got
inserted by Garrett when he pulled them out of some .h
files.
i386/isa/icu.s:
1) clean up global variable declarations
2) move in declaration of astpending and netisr
i386/i386/pmap.c:
1) fix calculation of virtual_avail. It previously was calculated
to be right in the middle of the kernel page tables - not
a good place to start allocating kernel VM.
2) properly allocate kernel page dir/tables etc out of kernel map
- previously only took out 2 pages.
i386/i386/machdep.c:
1) modify boot() to print a warning that the system will reboot in
PANIC_REBOOT_WAIT_TIME amount of seconds, and let the user
abort with a key on the console. The machine will wait for
ever if a key is typed before the reboot. The default is
15 seconds, but can be set to 0 to mean don't wait at all,
-1 to mean wait forever, or any positive value to wait for
that many seconds.
2) print "Rebooting..." just before doing it.
kern/subr_prf.c:
1) remove PANICWAIT as it is deprecated by the change to machdep.c
i386/i386/trap.c:
1) add table of trap type strings and use it to print a real trap/
panic message rather than just a number. Lot's of work to
be done here, but this is the first step. Symbolic traceback
is in the TODO.
i386/i386/Makefile.i386:
1) add support in to build support.s, exception.s and swtch.s
...and various changes to various header files to make all of the
above happen.
1993-11-13 02:25:21 +00:00
|
|
|
"trace trap", /* 10 T_TRCTRAP */
|
|
|
|
"", /* 11 unused */
|
|
|
|
"page fault", /* 12 T_PAGEFLT */
|
|
|
|
"page table fault", /* 13 T_TABLEFLT */
|
|
|
|
"alignment fault", /* 14 T_ALIGNFLT */
|
|
|
|
"kernel stack pointer not valid", /* 15 T_KSPNOTVAL */
|
|
|
|
"bus error", /* 16 T_BUSERR */
|
|
|
|
"kernel debugger fault", /* 17 T_KDBTRAP */
|
|
|
|
"integer divide fault", /* 18 T_DIVIDE */
|
|
|
|
"non-maskable interrupt trap", /* 19 T_NMI */
|
|
|
|
"overflow trap", /* 20 T_OFLOW */
|
|
|
|
"FPU bounds check fault", /* 21 T_BOUND */
|
|
|
|
"FPU device not available", /* 22 T_DNA */
|
|
|
|
"double fault", /* 23 T_DOUBLEFLT */
|
|
|
|
"FPU operand fetch fault", /* 24 T_FPOPFLT */
|
|
|
|
"invalid TSS fault", /* 25 T_TSSFLT */
|
|
|
|
"segment not present fault", /* 26 T_SEGNPFLT */
|
|
|
|
"stack fault", /* 27 T_STKFLT */
|
|
|
|
};
|
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
static inline void
|
|
|
|
userret(p, frame, oticks)
|
|
|
|
struct proc *p;
|
|
|
|
struct trapframe *frame;
|
|
|
|
u_quad_t oticks;
|
|
|
|
{
|
|
|
|
int sig, s;
|
|
|
|
|
|
|
|
while (sig = CURSIG(p))
|
|
|
|
postsig(sig);
|
|
|
|
p->p_priority = p->p_usrpri;
|
|
|
|
if (want_resched) {
|
|
|
|
/*
|
|
|
|
* Since we are curproc, clock will normally just change
|
|
|
|
* our priority without moving us from one queue to another
|
|
|
|
* (since the running process is not on a queue.)
|
|
|
|
* If that happened after we setrunqueue ourselves but before we
|
|
|
|
* mi_switch()'ed, we might not be on the queue indicated by
|
|
|
|
* our priority.
|
|
|
|
*/
|
|
|
|
s = splclock();
|
|
|
|
setrunqueue(p);
|
|
|
|
p->p_stats->p_ru.ru_nivcsw++;
|
|
|
|
mi_switch();
|
|
|
|
splx(s);
|
|
|
|
while (sig = CURSIG(p))
|
|
|
|
postsig(sig);
|
|
|
|
}
|
|
|
|
if (p->p_stats->p_prof.pr_scale) {
|
|
|
|
u_quad_t ticks = p->p_sticks - oticks;
|
|
|
|
|
|
|
|
if (ticks) {
|
|
|
|
#ifdef PROFTIMER
|
|
|
|
extern int profscale;
|
|
|
|
addupc(frame->tf_eip, &p->p_stats->p_prof,
|
|
|
|
ticks * profscale);
|
|
|
|
#else
|
|
|
|
addupc(frame->tf_eip, &p->p_stats->p_prof, ticks);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
curpriority = p->p_priority;
|
|
|
|
}
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* trap(frame):
|
1994-06-06 14:54:41 +00:00
|
|
|
* Exception, fault, and trap interface to the FreeBSD kernel.
|
|
|
|
* This common code is called from assembly language IDT gate entry
|
1993-06-12 14:58:17 +00:00
|
|
|
* routines that prepare a suitable stack frame, and restore this
|
1994-06-06 14:54:41 +00:00
|
|
|
* frame after the exception has been processed.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/*ARGSUSED*/
|
1993-11-25 01:38:01 +00:00
|
|
|
void
|
1993-06-12 14:58:17 +00:00
|
|
|
trap(frame)
|
|
|
|
struct trapframe frame;
|
|
|
|
{
|
1994-06-06 14:54:41 +00:00
|
|
|
struct proc *p = curproc;
|
1994-05-25 09:21:21 +00:00
|
|
|
u_quad_t sticks = 0;
|
1994-06-06 14:54:41 +00:00
|
|
|
int i = 0, ucode = 0, type, code, eva, fault_type;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
frame.tf_eflags &= ~PSL_NT; /* clear nested trap XXX */
|
|
|
|
type = frame.tf_trapno;
|
1994-06-06 14:54:41 +00:00
|
|
|
code = frame.tf_err;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
if (ISPL(frame.tf_cs) == SEL_UPL) {
|
1994-06-06 14:54:41 +00:00
|
|
|
/* user trap */
|
1994-01-14 16:25:31 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
sticks = p->p_sticks;
|
|
|
|
p->p_md.md_regs = (int *)&frame;
|
1994-01-14 16:25:31 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
switch (type) {
|
|
|
|
case T_RESADFLT: /* reserved addressing fault */
|
|
|
|
case T_PRIVINFLT: /* privileged instruction fault */
|
|
|
|
case T_RESOPFLT: /* reserved operand fault */
|
|
|
|
ucode = type;
|
|
|
|
i = SIGILL;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_BPTFLT: /* bpt instruction fault */
|
|
|
|
case T_TRCTRAP: /* trace trap */
|
|
|
|
frame.tf_eflags &= ~PSL_T;
|
|
|
|
i = SIGTRAP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_ARITHTRAP: /* arithmetic trap */
|
|
|
|
ucode = code;
|
|
|
|
i = SIGFPE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case T_ASTFLT: /* Allow process switch */
|
|
|
|
astoff();
|
|
|
|
cnt.v_soft++;
|
|
|
|
if ((p->p_flag & P_OWEUPC) && p->p_stats->p_prof.pr_scale) {
|
|
|
|
addupc(frame.tf_eip, &p->p_stats->p_prof, 1);
|
|
|
|
p->p_flag &= ~P_OWEUPC;
|
|
|
|
}
|
|
|
|
goto out;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_PROTFLT: /* general protection fault */
|
|
|
|
case T_SEGNPFLT: /* segment not present fault */
|
|
|
|
case T_STKFLT: /* stack fault */
|
|
|
|
ucode = code + BUS_SEGM_FAULT ;
|
|
|
|
i = SIGBUS;
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_PAGEFLT: /* page fault */
|
|
|
|
i = trap_pfault(&frame, TRUE);
|
|
|
|
if (i == 0)
|
|
|
|
goto out;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
ucode = T_PAGEFLT;
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_DIVIDE: /* integer divide fault */
|
|
|
|
ucode = FPE_INTDIV_TRAP;
|
|
|
|
i = SIGFPE;
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
#if NISA > 0
|
|
|
|
case T_NMI:
|
1994-08-27 16:14:39 +00:00
|
|
|
#ifdef DDB
|
1994-06-06 14:54:41 +00:00
|
|
|
/* NMI can be hooked up to a pushbutton for debugging */
|
|
|
|
printf ("NMI ... going to debugger\n");
|
|
|
|
if (kdb_trap (type, 0, &frame))
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
/* machine/parity/power fail/"kitchen sink" faults */
|
|
|
|
if (isa_nmi(code) == 0) return;
|
1994-08-10 04:39:52 +00:00
|
|
|
panic("NMI indicates hardware failure");
|
1994-06-06 14:54:41 +00:00
|
|
|
#endif
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_OFLOW: /* integer overflow fault */
|
|
|
|
ucode = FPE_INTOVF_TRAP;
|
|
|
|
i = SIGFPE;
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_BOUND: /* bounds check fault */
|
|
|
|
ucode = FPE_SUBRNG_TRAP;
|
|
|
|
i = SIGFPE;
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_DNA:
|
|
|
|
#if NNPX > 0
|
|
|
|
/* if a transparent fault (due to context switch "late") */
|
|
|
|
if (npxdna())
|
|
|
|
return;
|
|
|
|
#endif /* NNPX > 0 */
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
#if defined(MATH_EMULATE) || defined(GPL_MATH_EMULATE)
|
|
|
|
i = math_emulate(&frame);
|
|
|
|
if (i == 0) return;
|
|
|
|
#else /* MATH_EMULATE || GPL_MATH_EMULATE */
|
|
|
|
panic("trap: math emulation necessary!");
|
|
|
|
#endif /* MATH_EMULATE || GPL_MATH_EMULATE */
|
|
|
|
ucode = FPE_FPU_NP_TRAP;
|
|
|
|
break;
|
1994-02-08 09:26:04 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_FPOPFLT: /* FPU operand fetch fault */
|
|
|
|
ucode = T_FPOPFLT;
|
|
|
|
i = SIGILL;
|
|
|
|
break;
|
1994-01-14 16:25:31 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
default:
|
|
|
|
trap_fatal(&frame);
|
1994-01-14 16:25:31 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
} else {
|
|
|
|
/* kernel trap */
|
1994-01-14 16:25:31 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
switch (type) {
|
|
|
|
case T_PAGEFLT: /* page fault */
|
|
|
|
(void) trap_pfault(&frame, FALSE);
|
|
|
|
return;
|
1994-03-24 23:12:48 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_PROTFLT: /* general protection fault */
|
|
|
|
case T_SEGNPFLT: /* segment not present fault */
|
|
|
|
if (curpcb && curpcb->pcb_onfault) {
|
|
|
|
frame.tf_eip = (int)curpcb->pcb_onfault;
|
|
|
|
return;
|
1994-03-24 23:12:48 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
break;
|
1994-03-24 23:12:48 +00:00
|
|
|
|
1994-08-27 16:14:39 +00:00
|
|
|
#ifdef DDB
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_BPTFLT:
|
|
|
|
case T_TRCTRAP:
|
|
|
|
if (kdb_trap (type, 0, &frame))
|
1993-06-12 14:58:17 +00:00
|
|
|
return;
|
1994-06-06 14:54:41 +00:00
|
|
|
break;
|
|
|
|
#else
|
|
|
|
case T_TRCTRAP: /* trace trap -- someone single stepping lcall's */
|
1993-06-12 14:58:17 +00:00
|
|
|
/* Q: how do we turn it on again? */
|
1994-06-06 14:54:41 +00:00
|
|
|
frame.tf_eflags &= ~PSL_T;
|
|
|
|
return;
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
|
|
|
|
1994-02-01 23:07:35 +00:00
|
|
|
#if NISA > 0
|
1994-06-06 14:54:41 +00:00
|
|
|
case T_NMI:
|
1994-08-27 16:14:39 +00:00
|
|
|
#ifdef DDB
|
1994-06-06 14:54:41 +00:00
|
|
|
/* NMI can be hooked up to a pushbutton for debugging */
|
|
|
|
printf ("NMI ... going to debugger\n");
|
1994-04-07 10:51:00 +00:00
|
|
|
if (kdb_trap (type, 0, &frame))
|
|
|
|
return;
|
|
|
|
#endif
|
1994-06-06 14:54:41 +00:00
|
|
|
/* machine/parity/power fail/"kitchen sink" faults */
|
|
|
|
if (isa_nmi(code) == 0) return;
|
|
|
|
/* FALL THROUGH */
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
1994-06-06 14:54:41 +00:00
|
|
|
}
|
1994-02-01 23:07:35 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
trap_fatal(&frame);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
trapsignal(p, i, ucode);
|
1994-04-07 10:51:00 +00:00
|
|
|
|
|
|
|
#ifdef DIAGNOSTIC
|
1994-06-06 14:54:41 +00:00
|
|
|
eva = rcr2();
|
|
|
|
if (type <= MAX_TRAP_MSG) {
|
1994-04-07 10:51:00 +00:00
|
|
|
uprintf("fatal process exception: %s",
|
1994-06-06 14:54:41 +00:00
|
|
|
trap_msg[type]);
|
|
|
|
if ((type == T_PAGEFLT) || (type == T_PROTFLT))
|
1994-04-07 10:51:00 +00:00
|
|
|
uprintf(", fault VA = 0x%x", eva);
|
|
|
|
uprintf("\n");
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
out:
|
1994-06-06 14:54:41 +00:00
|
|
|
userret(p, &frame, sticks);
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
trap_pfault(frame, usermode)
|
|
|
|
struct trapframe *frame;
|
|
|
|
int usermode;
|
|
|
|
{
|
|
|
|
vm_offset_t va;
|
1994-09-11 11:26:18 +00:00
|
|
|
struct vmspace *vm = NULL;
|
1994-06-06 14:54:41 +00:00
|
|
|
vm_map_t map = 0;
|
|
|
|
int rv = 0, oldflags;
|
|
|
|
vm_prot_t ftype;
|
|
|
|
extern vm_map_t kernel_map;
|
|
|
|
int eva;
|
|
|
|
struct proc *p = curproc;
|
|
|
|
|
|
|
|
eva = rcr2();
|
|
|
|
va = trunc_page((vm_offset_t)eva);
|
|
|
|
|
1994-09-11 11:26:18 +00:00
|
|
|
if (va >= KERNBASE) {
|
|
|
|
/*
|
|
|
|
* Don't allow user-mode faults in kernel address space.
|
|
|
|
*/
|
|
|
|
if (usermode)
|
|
|
|
goto nogo;
|
1994-06-06 14:54:41 +00:00
|
|
|
|
|
|
|
map = kernel_map;
|
|
|
|
} else {
|
1994-09-11 11:26:18 +00:00
|
|
|
/*
|
|
|
|
* This is a fault on non-kernel virtual memory.
|
|
|
|
* vm is initialized above to NULL. If curproc is NULL
|
|
|
|
* or curproc->p_vmspace is NULL the fault is fatal.
|
|
|
|
*/
|
|
|
|
if (p != NULL)
|
|
|
|
vm = p->p_vmspace;
|
|
|
|
|
|
|
|
if (vm == NULL)
|
|
|
|
goto nogo;
|
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
map = &vm->vm_map;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (frame->tf_err & PGEX_W)
|
|
|
|
ftype = VM_PROT_READ | VM_PROT_WRITE;
|
|
|
|
else
|
|
|
|
ftype = VM_PROT_READ;
|
|
|
|
|
|
|
|
if (map != kernel_map) {
|
|
|
|
vm_offset_t pa;
|
|
|
|
vm_offset_t v = (vm_offset_t) vtopte(va);
|
|
|
|
vm_page_t ptepg;
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
1994-06-06 14:54:41 +00:00
|
|
|
* Keep swapout from messing with us during this
|
|
|
|
* critical time.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
1994-06-06 14:54:41 +00:00
|
|
|
++p->p_lock;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Grow the stack if necessary
|
|
|
|
*/
|
|
|
|
if ((caddr_t)va > vm->vm_maxsaddr
|
|
|
|
&& (caddr_t)va < (caddr_t)USRSTACK) {
|
|
|
|
if (!grow(p, va)) {
|
|
|
|
rv = KERN_FAILURE;
|
|
|
|
--p->p_lock;
|
|
|
|
goto nogo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if page table is mapped, if not,
|
|
|
|
* fault it first
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* Fault the pte only if needed: */
|
|
|
|
*(volatile char *)v += 0;
|
|
|
|
|
|
|
|
ptepg = (vm_page_t) pmap_pte_vm_page(vm_map_pmap(map), v);
|
1994-08-01 11:25:45 +00:00
|
|
|
if( ptepg->hold_count == 0)
|
|
|
|
ptepg->act_count += 3;
|
1994-06-06 14:54:41 +00:00
|
|
|
vm_page_hold(ptepg);
|
|
|
|
|
|
|
|
/* Fault in the user page: */
|
|
|
|
rv = vm_fault(map, va, ftype, FALSE);
|
|
|
|
|
|
|
|
vm_page_unhold(ptepg);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* page table pages don't need to be kept if they
|
|
|
|
* are not held
|
|
|
|
*/
|
|
|
|
if( ptepg->hold_count == 0 && ptepg->wire_count == 0) {
|
|
|
|
pmap_page_protect( VM_PAGE_TO_PHYS(ptepg),
|
|
|
|
VM_PROT_NONE);
|
|
|
|
vm_page_free(ptepg);
|
|
|
|
}
|
|
|
|
|
|
|
|
--p->p_lock;
|
|
|
|
} else {
|
|
|
|
/*
|
|
|
|
* Since we know that kernel virtual address addresses
|
|
|
|
* always have pte pages mapped, we just have to fault
|
|
|
|
* the page.
|
|
|
|
*/
|
|
|
|
rv = vm_fault(map, va, ftype, FALSE);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
if (rv == KERN_SUCCESS)
|
|
|
|
return (0);
|
|
|
|
nogo:
|
|
|
|
if (!usermode) {
|
1994-09-11 11:26:18 +00:00
|
|
|
if (curpcb && curpcb->pcb_onfault) {
|
1994-06-06 14:54:41 +00:00
|
|
|
frame->tf_eip = (int)curpcb->pcb_onfault;
|
|
|
|
return (0);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
trap_fatal(frame);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
|
|
|
|
/* kludge to pass faulting virtual address to sendsig */
|
|
|
|
frame->tf_err = eva;
|
|
|
|
|
|
|
|
return((rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
trap_fatal(frame)
|
|
|
|
struct trapframe *frame;
|
|
|
|
{
|
|
|
|
int code, type, eva;
|
|
|
|
|
|
|
|
code = frame->tf_err;
|
|
|
|
type = frame->tf_trapno;
|
|
|
|
eva = rcr2();
|
|
|
|
|
|
|
|
if (type <= MAX_TRAP_MSG)
|
|
|
|
printf("\n\nFatal trap %d: %s while in %s mode\n",
|
|
|
|
type, trap_msg[type],
|
|
|
|
ISPL(frame->tf_cs) == SEL_UPL ? "user" : "kernel");
|
|
|
|
if (type == T_PAGEFLT) {
|
|
|
|
printf("fault virtual address = 0x%x\n", eva);
|
|
|
|
printf("fault code = %s %s, %s\n",
|
|
|
|
code & PGEX_U ? "user" : "supervisor",
|
|
|
|
code & PGEX_W ? "write" : "read",
|
|
|
|
code & PGEX_P ? "protection violation" : "page not present");
|
|
|
|
}
|
|
|
|
printf("instruction pointer = 0x%x\n", frame->tf_eip);
|
|
|
|
printf("processor eflags = ");
|
1994-09-08 11:49:04 +00:00
|
|
|
if (frame->tf_eflags & PSL_T)
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("trace/trap, ");
|
1994-09-08 11:49:04 +00:00
|
|
|
if (frame->tf_eflags & PSL_I)
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("interrupt enabled, ");
|
1994-09-08 11:49:04 +00:00
|
|
|
if (frame->tf_eflags & PSL_NT)
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("nested task, ");
|
1994-09-08 11:49:04 +00:00
|
|
|
if (frame->tf_eflags & PSL_RF)
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("resume, ");
|
1994-09-08 11:49:04 +00:00
|
|
|
if (frame->tf_eflags & PSL_VM)
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("vm86, ");
|
1994-09-08 11:49:04 +00:00
|
|
|
printf("IOPL = %d\n", (frame->tf_eflags & PSL_IOPL) >> 12);
|
1994-06-06 14:54:41 +00:00
|
|
|
printf("current process = ");
|
|
|
|
if (curproc) {
|
|
|
|
printf("%d (%s)\n",
|
|
|
|
curproc->p_pid, curproc->p_comm ?
|
|
|
|
curproc->p_comm : "");
|
|
|
|
} else {
|
|
|
|
printf("Idle\n");
|
|
|
|
}
|
|
|
|
printf("interrupt mask = ");
|
|
|
|
if ((cpl & net_imask) == net_imask)
|
|
|
|
printf("net ");
|
|
|
|
if ((cpl & tty_imask) == tty_imask)
|
|
|
|
printf("tty ");
|
|
|
|
if ((cpl & bio_imask) == bio_imask)
|
|
|
|
printf("bio ");
|
|
|
|
if (cpl == 0)
|
|
|
|
printf("none");
|
|
|
|
printf("\n");
|
|
|
|
|
|
|
|
#ifdef KDB
|
|
|
|
if (kdb_trap(&psl))
|
|
|
|
return;
|
|
|
|
#endif
|
1994-08-27 16:14:39 +00:00
|
|
|
#ifdef DDB
|
1994-06-06 14:54:41 +00:00
|
|
|
if (kdb_trap (type, 0, frame))
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
if (type <= MAX_TRAP_MSG)
|
|
|
|
panic(trap_msg[type]);
|
|
|
|
else
|
|
|
|
panic("unknown/reserved trap");
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
1993-07-27 10:52:31 +00:00
|
|
|
* Compensate for 386 brain damage (missing URKR).
|
|
|
|
* This is a little simpler than the pagefault handler in trap() because
|
|
|
|
* it the page tables have already been faulted in and high addresses
|
|
|
|
* are thrown out early for other reasons.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
1993-07-27 10:52:31 +00:00
|
|
|
int trapwrite(addr)
|
|
|
|
unsigned addr;
|
|
|
|
{
|
|
|
|
struct proc *p;
|
1994-02-08 09:26:04 +00:00
|
|
|
vm_offset_t va, v;
|
1993-07-27 10:52:31 +00:00
|
|
|
struct vmspace *vm;
|
1994-01-14 16:25:31 +00:00
|
|
|
int oldflags;
|
|
|
|
int rv;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
va = trunc_page((vm_offset_t)addr);
|
1993-07-27 10:52:31 +00:00
|
|
|
/*
|
|
|
|
* XXX - MAX is END. Changed > to >= for temp. fix.
|
|
|
|
*/
|
|
|
|
if (va >= VM_MAXUSER_ADDRESS)
|
|
|
|
return (1);
|
1994-02-08 09:26:04 +00:00
|
|
|
|
1993-07-27 10:52:31 +00:00
|
|
|
p = curproc;
|
|
|
|
vm = p->p_vmspace;
|
1994-01-14 16:25:31 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
++p->p_lock;
|
1994-01-14 16:25:31 +00:00
|
|
|
|
Patch from Gene Stark:
Subject: Page fault in PTE area fails in copyout
Index: sys/i386/i386/trap.c FreeBSD-1.0.2
Description:
Reading files of several megabytes into Emacs, or many small
files all at once, would fail with "IO error - bad address".
Repeat-By:
The bug can be exercised by a test program that malloc()'s
a 5MB chunk of memory, and then, without accessing the memory
first, filling it with data from a file using read().
(I read 64k chunks from /dev/wd0d into successive 64k regions
of the 5MB chunk.) The read() will fail with EFAULT at the first
virtual address boundary that is a multiple of 0x400000.
Fix:
The problem was code in sys/i386/i386/trap.c that tries to
figure out what kind of trap occurred and to handle it appropriately.
It was interpreting any page fault with virtual address
>= vm->vm_maxsaddr as being a user stack segment fault.
In fact, addresses >= USRSTACK are in the user structure/PTE area,
and if they are handled as stack faults, the proper PTE will
not be paged in when it is supposed to be. This situation comes
up in copyout() and copyoutstr(), if PTE's are accessed for the
first time ever. The page fault on accessing the nonexistent PTE
is mishandled as a stack fault, and then the fault that occurs on
the subsequent access to the page itself causes copyout to fail
with EFAULT.
1993-11-28 09:28:54 +00:00
|
|
|
if ((caddr_t)va >= vm->vm_maxsaddr
|
1993-12-12 12:22:57 +00:00
|
|
|
&& (caddr_t)va < (caddr_t)USRSTACK) {
|
1994-02-08 09:26:04 +00:00
|
|
|
if (!grow(p, va)) {
|
1994-05-25 09:21:21 +00:00
|
|
|
--p->p_lock;
|
1993-07-27 10:52:31 +00:00
|
|
|
return (1);
|
1994-01-14 16:25:31 +00:00
|
|
|
}
|
1993-07-27 10:52:31 +00:00
|
|
|
}
|
|
|
|
|
1994-02-08 09:26:04 +00:00
|
|
|
v = trunc_page(vtopte(va));
|
1993-07-27 10:52:31 +00:00
|
|
|
|
1994-02-08 09:26:04 +00:00
|
|
|
/*
|
|
|
|
* wire the pte page
|
|
|
|
*/
|
|
|
|
if (va < USRSTACK) {
|
|
|
|
vm_map_pageable(&vm->vm_map, v, round_page(v+1), FALSE);
|
1994-01-14 16:25:31 +00:00
|
|
|
}
|
1994-02-08 09:26:04 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* fault the data page
|
|
|
|
*/
|
|
|
|
rv = vm_fault(&vm->vm_map, va, VM_PROT_READ|VM_PROT_WRITE, FALSE);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* unwire the pte page
|
|
|
|
*/
|
|
|
|
if (va < USRSTACK) {
|
|
|
|
vm_map_pageable(&vm->vm_map, v, round_page(v+1), TRUE);
|
|
|
|
}
|
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
--p->p_lock;
|
1994-01-14 16:25:31 +00:00
|
|
|
|
|
|
|
if (rv != KERN_SUCCESS)
|
|
|
|
return 1;
|
1994-02-08 09:26:04 +00:00
|
|
|
|
1993-07-27 10:52:31 +00:00
|
|
|
return (0);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* syscall(frame):
|
|
|
|
* System call request from POSIX system call gate interface to kernel.
|
|
|
|
* Like trap(), argument is call by reference.
|
|
|
|
*/
|
|
|
|
/*ARGSUSED*/
|
1993-11-25 01:38:01 +00:00
|
|
|
void
|
1993-06-12 14:58:17 +00:00
|
|
|
syscall(frame)
|
1994-06-06 14:54:41 +00:00
|
|
|
struct trapframe frame;
|
1993-06-12 14:58:17 +00:00
|
|
|
{
|
1994-06-06 14:54:41 +00:00
|
|
|
caddr_t params;
|
|
|
|
int i;
|
|
|
|
struct sysent *callp;
|
|
|
|
struct proc *p = curproc;
|
1994-05-25 09:21:21 +00:00
|
|
|
u_quad_t sticks;
|
1993-06-12 14:58:17 +00:00
|
|
|
int error, opc;
|
|
|
|
int args[8], rval[2];
|
1994-05-25 09:21:21 +00:00
|
|
|
u_int code;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-05-25 09:21:21 +00:00
|
|
|
sticks = p->p_sticks;
|
1994-01-03 07:55:47 +00:00
|
|
|
if (ISPL(frame.tf_cs) != SEL_UPL)
|
1993-06-12 14:58:17 +00:00
|
|
|
panic("syscall");
|
|
|
|
|
1994-01-03 07:55:47 +00:00
|
|
|
code = frame.tf_eax;
|
1994-05-25 09:21:21 +00:00
|
|
|
p->p_md.md_regs = (int *)&frame;
|
1994-01-03 07:55:47 +00:00
|
|
|
params = (caddr_t)frame.tf_esp + sizeof (int) ;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Reconstruct pc, assuming lcall $X,y is 7 bytes, as it is always.
|
|
|
|
*/
|
1994-01-03 07:55:47 +00:00
|
|
|
opc = frame.tf_eip - 7;
|
1994-05-25 09:21:21 +00:00
|
|
|
/*
|
|
|
|
* Need to check if this is a 32 bit or 64 bit syscall.
|
|
|
|
*/
|
|
|
|
if (code == SYS_syscall) {
|
|
|
|
/*
|
|
|
|
* Code is first argument, followed by actual args.
|
|
|
|
*/
|
1994-01-03 07:55:47 +00:00
|
|
|
code = fuword(params);
|
1993-06-12 14:58:17 +00:00
|
|
|
params += sizeof (int);
|
1994-05-25 09:21:21 +00:00
|
|
|
} else if (code == SYS___syscall) {
|
|
|
|
/*
|
|
|
|
* Like syscall, but code is a quad, so as to maintain
|
|
|
|
* quad alignment for the rest of the arguments.
|
|
|
|
*/
|
|
|
|
code = fuword(params + _QUAD_LOWWORD * sizeof(int));
|
|
|
|
params += sizeof(quad_t);
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1994-05-25 09:21:21 +00:00
|
|
|
|
1994-08-24 11:52:21 +00:00
|
|
|
if (p->p_sysent->sv_mask)
|
|
|
|
code = code & p->p_sysent->sv_mask;
|
|
|
|
|
1994-08-28 16:16:33 +00:00
|
|
|
if (code >= p->p_sysent->sv_size)
|
1994-08-24 11:52:21 +00:00
|
|
|
callp = &p->p_sysent->sv_table[0];
|
|
|
|
else
|
|
|
|
callp = &p->p_sysent->sv_table[code];
|
1993-06-12 14:58:17 +00:00
|
|
|
|
|
|
|
if ((i = callp->sy_narg * sizeof (int)) &&
|
|
|
|
(error = copyin(params, (caddr_t)args, (u_int)i))) {
|
|
|
|
#ifdef KTRACE
|
|
|
|
if (KTRPOINT(p, KTR_SYSCALL))
|
1993-12-19 00:55:01 +00:00
|
|
|
ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
1994-06-06 14:54:41 +00:00
|
|
|
goto bad;
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
|
|
|
#ifdef KTRACE
|
|
|
|
if (KTRPOINT(p, KTR_SYSCALL))
|
1993-12-19 00:55:01 +00:00
|
|
|
ktrsyscall(p->p_tracep, code, callp->sy_narg, args);
|
1993-06-12 14:58:17 +00:00
|
|
|
#endif
|
|
|
|
rval[0] = 0;
|
1994-01-03 07:55:47 +00:00
|
|
|
rval[1] = frame.tf_edx;
|
1994-06-06 14:54:41 +00:00
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
error = (*callp->sy_call)(p, args, rval);
|
1994-06-06 14:54:41 +00:00
|
|
|
|
|
|
|
switch (error) {
|
|
|
|
|
|
|
|
case 0:
|
1993-06-12 14:58:17 +00:00
|
|
|
/*
|
1994-06-06 14:54:41 +00:00
|
|
|
* Reinitialize proc pointer `p' as it may be different
|
|
|
|
* if this is a child returning from fork syscall.
|
1993-06-12 14:58:17 +00:00
|
|
|
*/
|
1994-06-06 14:54:41 +00:00
|
|
|
p = curproc;
|
|
|
|
frame.tf_eax = rval[0];
|
|
|
|
frame.tf_edx = rval[1];
|
|
|
|
frame.tf_eflags &= ~PSL_C; /* carry bit */
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
|
1994-06-06 14:54:41 +00:00
|
|
|
case ERESTART:
|
|
|
|
frame.tf_eip = opc;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case EJUSTRETURN:
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
bad:
|
|
|
|
frame.tf_eax = error;
|
|
|
|
frame.tf_eflags |= PSL_C; /* carry bit */
|
|
|
|
break;
|
1993-06-12 14:58:17 +00:00
|
|
|
}
|
1994-06-06 14:54:41 +00:00
|
|
|
|
|
|
|
userret(p, &frame, sticks);
|
|
|
|
|
1993-06-12 14:58:17 +00:00
|
|
|
#ifdef KTRACE
|
|
|
|
if (KTRPOINT(p, KTR_SYSRET))
|
|
|
|
ktrsysret(p->p_tracep, code, error, rval[0]);
|
|
|
|
#endif
|
|
|
|
}
|