mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2024-11-16 15:44:04 +01:00
1) Added proc file system from Paul Kranenburg with changes from
John Dyson to make it reliably work under FreeBSD. 2) Added and enabled PROCFS in the GENERICxx and LINT kernels. 3) New execve() from me. Still work to be done here, but this version works well and is needed before other changes can be made. For a description of the design behind this, see freebsd-arch or ask me. 4) Rewrote stack fault code; made user stack VM grow as needed rather than all up front; improves performance a little and reduces process memory requirements. 5) Incorporated fix from Gene Stark to fault/wire a user page table page to fix a problem in copyout. This is a temporary fix and is not appropriate for pageable page tables. For a description of the problem, see Gene's post to the freebsd-hackers mailing list. 6) Tighten up vm_page struct to reduce memory requirements for it. ifdef pager page lock code as it's not being used currently. 7) Introduced new element to vmspace struct - vm_minsaddr; initial (minimum) stack address. Compliment to vm_maxsaddr. 8) Added a panic if the allocation for process u-pages fails. 9) Improve performance and accuracy of kernel profiling by putting in a little inline assembly instead of spl(). 10) Made serial console with sio driver work. Still has problems with serial input, but is almost useable. 11) Added -Bstatic to SYSTEM_LD in Makefile.i386 so that kernels will build properly with the new ld.
This commit is contained in:
parent
41d67a5615
commit
6d01f02e51
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=849
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.19 1993/11/25 01:30:55 wollman Exp $
|
||||
* $Id: machdep.c,v 1.20 1993/12/03 05:07:43 alm Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -437,9 +437,6 @@ sendsig(catcher, sig, mask, code)
|
||||
- sizeof(struct sigframe));
|
||||
}
|
||||
|
||||
if ((unsigned)fp <= (unsigned)p->p_vmspace->vm_maxsaddr + MAXSSIZ - ctob(p->p_vmspace->vm_ssize))
|
||||
(void)grow(p, (unsigned)fp);
|
||||
|
||||
if (useracc((caddr_t)fp, sizeof (struct sigframe), B_WRITE) == 0) {
|
||||
/*
|
||||
* Process has trashed its stack; give it an illegal
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
|
||||
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
|
||||
* $Id: trap.c,v 1.10 1993/12/03 05:07:45 alm Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -81,7 +81,6 @@ void write_gs __P((/* promoted u_short */ int gs));
|
||||
|
||||
struct sysent sysent[];
|
||||
int nsysent;
|
||||
int dostacklimits;
|
||||
unsigned rcr2();
|
||||
extern short cpl;
|
||||
|
||||
@ -117,6 +116,7 @@ char *trap_msg[] = {
|
||||
"stack fault", /* 27 T_STKFLT */
|
||||
};
|
||||
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
|
||||
/*
|
||||
* trap(frame):
|
||||
@ -287,10 +287,11 @@ copyfault:
|
||||
register vm_offset_t va;
|
||||
register struct vmspace *vm = p->p_vmspace;
|
||||
register vm_map_t map;
|
||||
int rv;
|
||||
int rv = 0;
|
||||
vm_prot_t ftype;
|
||||
extern vm_map_t kernel_map;
|
||||
unsigned nss,v;
|
||||
unsigned nss;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)eva);
|
||||
/*
|
||||
@ -323,21 +324,45 @@ copyfault:
|
||||
nss = 0;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK
|
||||
&& map != kernel_map
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr
|
||||
+ MAXSSIZ - (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
|
||||
/*pg("trap rlimit %d, maxsaddr %x va %x ", nss, vm->vm_maxsaddr, va);*/
|
||||
&& map != kernel_map) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur) {
|
||||
rv = KERN_FAILURE;
|
||||
goto nogo;
|
||||
}
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) - grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
goto nogo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if page table is mapped, if not, fault it first */
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
if (!pde_v(va)) {
|
||||
v = trunc_page(vtopte(va));
|
||||
v = (char *)trunc_page(vtopte(va));
|
||||
rv = vm_fault(map, v, ftype, FALSE);
|
||||
if (rv != KERN_SUCCESS) goto nogo;
|
||||
/* check if page table fault, increment wiring */
|
||||
@ -348,13 +373,23 @@ copyfault:
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
/*
|
||||
* va could be a page table address, if the fault
|
||||
* occurred from within copyout. In that case,
|
||||
* we have to wire it. (EWS 12/11/93)
|
||||
*/
|
||||
if (ispt(va))
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
va = trunc_page(vtopte(va));
|
||||
/* for page table, increment wiring
|
||||
as long as not a page table fault as well */
|
||||
/*
|
||||
* for page table, increment wiring
|
||||
* as long as not a page table fault as well
|
||||
*/
|
||||
if (!v && type != T_PAGEFLT)
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
if (type == T_PAGEFLT)
|
||||
return;
|
||||
goto out;
|
||||
@ -370,9 +405,11 @@ nogo:
|
||||
goto we_re_toast;
|
||||
}
|
||||
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
|
||||
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
ucode = type &~ T_USER;
|
||||
frame.tf_err = eva;
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -464,6 +501,7 @@ int trapwrite(addr)
|
||||
struct proc *p;
|
||||
vm_offset_t va;
|
||||
struct vmspace *vm;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)addr);
|
||||
/*
|
||||
@ -478,12 +516,38 @@ int trapwrite(addr)
|
||||
p = curproc;
|
||||
vm = p->p_vmspace;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK /* EWS 11/27/93 */
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr + MAXSSIZ
|
||||
- (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur))
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur)
|
||||
return (1);
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT, DFLSSIZ) -
|
||||
grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vm_fault(&vm->vm_map, va, VM_PROT_READ | VM_PROT_WRITE, FALSE)
|
||||
@ -493,6 +557,7 @@ int trapwrite(addr)
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Copyright 1990 W. Jolitz
|
||||
# from: @(#)Makefile.i386 7.1 5/10/91
|
||||
# $Id: Makefile.i386,v 1.15 1993/11/16 00:45:04 paul Exp $
|
||||
# $Id: Makefile.i386,v 1.16 1993/11/25 01:30:38 wollman Exp $
|
||||
#
|
||||
# Makefile for FreeBSD
|
||||
#
|
||||
@ -54,7 +54,7 @@ SYSTEM_OBJS=locore.o exception.o swtch.o support.o ${OBJS} param.o \
|
||||
ioconf.o conf.o machdep.o
|
||||
SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
|
||||
SYSTEM_LD= @${LD} -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD= @${LD} -Bstatic -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \
|
||||
${DBSYM} -fT ${LOAD_ADDRESS} $@; ${STRIP} -x $@; size $@; chmod 755 $@
|
||||
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Copyright 1990 W. Jolitz
|
||||
# from: @(#)Makefile.i386 7.1 5/10/91
|
||||
# $Id: Makefile.i386,v 1.15 1993/11/16 00:45:04 paul Exp $
|
||||
# $Id: Makefile.i386,v 1.16 1993/11/25 01:30:38 wollman Exp $
|
||||
#
|
||||
# Makefile for FreeBSD
|
||||
#
|
||||
@ -54,7 +54,7 @@ SYSTEM_OBJS=locore.o exception.o swtch.o support.o ${OBJS} param.o \
|
||||
ioconf.o conf.o machdep.o
|
||||
SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
|
||||
SYSTEM_LD= @${LD} -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD= @${LD} -Bstatic -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \
|
||||
${DBSYM} -fT ${LOAD_ADDRESS} $@; ${STRIP} -x $@; size $@; chmod 755 $@
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# This kernel is NOT MEANT to be runnable!
|
||||
#
|
||||
# $Id: LINT,v 1.30 1993/11/18 05:01:45 rgrimes Exp $
|
||||
# $Id: LINT,v 1.31 1993/12/06 01:57:16 wollman Exp $
|
||||
#
|
||||
|
||||
machine "i386"
|
||||
@ -70,6 +70,7 @@ options NFS #Network File System
|
||||
options NS #Xerox NS communications protocols
|
||||
options NSIP #XNS over IP
|
||||
options PCFS #PC (MSDOS) File System
|
||||
options PROCFS #Proc File System
|
||||
pseudo-device ppp 2
|
||||
pseudo-device pty 4
|
||||
options QUOTA #enable disk quotas
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# GENERICAH -- Generic machine with WD/AHx family disks
|
||||
#
|
||||
# $Id: GENERICAH,v 1.16 1993/10/19 01:28:07 rgrimes Exp $
|
||||
# $Id: GENERICAH,v 1.17 1993/11/03 20:02:20 ats Exp $
|
||||
#
|
||||
|
||||
machine "i386"
|
||||
@ -16,6 +16,7 @@ options INET #InterNETworking
|
||||
options ISOFS #ISO File System
|
||||
options NFS #Network File System
|
||||
options PCFS #MSDOS File System
|
||||
options PROCFS #Proc File System
|
||||
options "COMPAT_43" #Compatible with BSD 4.3
|
||||
options "TCP_COMPAT_42" #TCP/IP compatible with 4.2
|
||||
options XSERVER #Xserver
|
||||
|
@ -1,7 +1,7 @@
|
||||
#
|
||||
# GENERICBT -- Generic machine with WD/BTx family disks
|
||||
#
|
||||
# $Id: GENERICBT,v 1.15 1993/10/19 01:28:08 rgrimes Exp $
|
||||
# $Id: GENERICBT,v 1.16 1993/11/03 20:02:21 ats Exp $
|
||||
#
|
||||
|
||||
machine "i386"
|
||||
@ -16,6 +16,7 @@ options INET #InterNETworking
|
||||
options ISOFS #ISO File System
|
||||
options NFS #Network File System
|
||||
options PCFS #MSDOS File System
|
||||
options PROCFS #Proc File System
|
||||
options "COMPAT_43" #Compatible with BSD 4.3
|
||||
options "TCP_COMPAT_42" #TCP/IP compatible with 4.2
|
||||
options XSERVER #Xserver
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# This kernel is NOT MEANT to be runnable!
|
||||
#
|
||||
# $Id: LINT,v 1.30 1993/11/18 05:01:45 rgrimes Exp $
|
||||
# $Id: LINT,v 1.31 1993/12/06 01:57:16 wollman Exp $
|
||||
#
|
||||
|
||||
machine "i386"
|
||||
@ -70,6 +70,7 @@ options NFS #Network File System
|
||||
options NS #Xerox NS communications protocols
|
||||
options NSIP #XNS over IP
|
||||
options PCFS #PC (MSDOS) File System
|
||||
options PROCFS #Proc File System
|
||||
pseudo-device ppp 2
|
||||
pseudo-device pty 4
|
||||
options QUOTA #enable disk quotas
|
||||
|
@ -1,6 +1,6 @@
|
||||
# Copyright 1990 W. Jolitz
|
||||
# from: @(#)Makefile.i386 7.1 5/10/91
|
||||
# $Id: Makefile.i386,v 1.15 1993/11/16 00:45:04 paul Exp $
|
||||
# $Id: Makefile.i386,v 1.16 1993/11/25 01:30:38 wollman Exp $
|
||||
#
|
||||
# Makefile for FreeBSD
|
||||
#
|
||||
@ -54,7 +54,7 @@ SYSTEM_OBJS=locore.o exception.o swtch.o support.o ${OBJS} param.o \
|
||||
ioconf.o conf.o machdep.o
|
||||
SYSTEM_DEP=Makefile symbols.sort ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_HEAD= @echo loading $@; rm -f $@
|
||||
SYSTEM_LD= @${LD} -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD= @${LD} -Bstatic -z -T ${LOAD_ADDRESS} -o $@ -X vers.o ${SYSTEM_OBJS}
|
||||
SYSTEM_LD_TAIL= @echo rearranging symbols; symorder symbols.sort $@; \
|
||||
${DBSYM} -fT ${LOAD_ADDRESS} $@; ${STRIP} -x $@; size $@; chmod 755 $@
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
#
|
||||
# This kernel is NOT MEANT to be runnable!
|
||||
#
|
||||
# $Id: LINT,v 1.30 1993/11/18 05:01:45 rgrimes Exp $
|
||||
# $Id: LINT,v 1.31 1993/12/06 01:57:16 wollman Exp $
|
||||
#
|
||||
|
||||
machine "i386"
|
||||
@ -70,6 +70,7 @@ options NFS #Network File System
|
||||
options NS #Xerox NS communications protocols
|
||||
options NSIP #XNS over IP
|
||||
options PCFS #PC (MSDOS) File System
|
||||
options PROCFS #Proc File System
|
||||
pseudo-device ppp 2
|
||||
pseudo-device pty 4
|
||||
options QUOTA #enable disk quotas
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
|
||||
* $Id: cons.c,v 1.5 1993/11/07 17:41:32 wollman Exp $
|
||||
* $Id: cons.c,v 1.6 1993/11/25 01:30:50 wollman Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -55,6 +55,12 @@
|
||||
|
||||
/* XXX - all this could be autoconfig()ed */
|
||||
int pccnprobe(), pccninit(), pccngetc(), pccnputc();
|
||||
|
||||
#include "sio.h"
|
||||
#if NSIO > 0
|
||||
int siocnprobe(), siocninit(), siocngetc(), siocnputc();
|
||||
#endif
|
||||
|
||||
#include "com.h"
|
||||
#if NCOM > 0
|
||||
int comcnprobe(), comcninit(), comcngetc(), comcnputc();
|
||||
@ -62,6 +68,9 @@ int comcnprobe(), comcninit(), comcngetc(), comcnputc();
|
||||
|
||||
struct consdev constab[] = {
|
||||
{ pccnprobe, pccninit, pccngetc, pccnputc },
|
||||
#if NSIO > 0
|
||||
{ siocnprobe, siocninit, siocngetc, siocnputc },
|
||||
#endif
|
||||
#if NCOM > 0
|
||||
{ comcnprobe, comcninit, comcngetc, comcnputc },
|
||||
#endif
|
||||
|
@ -35,7 +35,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)machdep.c 7.4 (Berkeley) 6/3/91
|
||||
* $Id: machdep.c,v 1.19 1993/11/25 01:30:55 wollman Exp $
|
||||
* $Id: machdep.c,v 1.20 1993/12/03 05:07:43 alm Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -437,9 +437,6 @@ sendsig(catcher, sig, mask, code)
|
||||
- sizeof(struct sigframe));
|
||||
}
|
||||
|
||||
if ((unsigned)fp <= (unsigned)p->p_vmspace->vm_maxsaddr + MAXSSIZ - ctob(p->p_vmspace->vm_ssize))
|
||||
(void)grow(p, (unsigned)fp);
|
||||
|
||||
if (useracc((caddr_t)fp, sizeof (struct sigframe), B_WRITE) == 0) {
|
||||
/*
|
||||
* Process has trashed its stack; give it an illegal
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
|
||||
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
|
||||
* $Id: trap.c,v 1.10 1993/12/03 05:07:45 alm Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -81,7 +81,6 @@ void write_gs __P((/* promoted u_short */ int gs));
|
||||
|
||||
struct sysent sysent[];
|
||||
int nsysent;
|
||||
int dostacklimits;
|
||||
unsigned rcr2();
|
||||
extern short cpl;
|
||||
|
||||
@ -117,6 +116,7 @@ char *trap_msg[] = {
|
||||
"stack fault", /* 27 T_STKFLT */
|
||||
};
|
||||
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
|
||||
/*
|
||||
* trap(frame):
|
||||
@ -287,10 +287,11 @@ copyfault:
|
||||
register vm_offset_t va;
|
||||
register struct vmspace *vm = p->p_vmspace;
|
||||
register vm_map_t map;
|
||||
int rv;
|
||||
int rv = 0;
|
||||
vm_prot_t ftype;
|
||||
extern vm_map_t kernel_map;
|
||||
unsigned nss,v;
|
||||
unsigned nss;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)eva);
|
||||
/*
|
||||
@ -323,21 +324,45 @@ copyfault:
|
||||
nss = 0;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK
|
||||
&& map != kernel_map
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr
|
||||
+ MAXSSIZ - (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
|
||||
/*pg("trap rlimit %d, maxsaddr %x va %x ", nss, vm->vm_maxsaddr, va);*/
|
||||
&& map != kernel_map) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur) {
|
||||
rv = KERN_FAILURE;
|
||||
goto nogo;
|
||||
}
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) - grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
goto nogo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if page table is mapped, if not, fault it first */
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
if (!pde_v(va)) {
|
||||
v = trunc_page(vtopte(va));
|
||||
v = (char *)trunc_page(vtopte(va));
|
||||
rv = vm_fault(map, v, ftype, FALSE);
|
||||
if (rv != KERN_SUCCESS) goto nogo;
|
||||
/* check if page table fault, increment wiring */
|
||||
@ -348,13 +373,23 @@ copyfault:
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
/*
|
||||
* va could be a page table address, if the fault
|
||||
* occurred from within copyout. In that case,
|
||||
* we have to wire it. (EWS 12/11/93)
|
||||
*/
|
||||
if (ispt(va))
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
va = trunc_page(vtopte(va));
|
||||
/* for page table, increment wiring
|
||||
as long as not a page table fault as well */
|
||||
/*
|
||||
* for page table, increment wiring
|
||||
* as long as not a page table fault as well
|
||||
*/
|
||||
if (!v && type != T_PAGEFLT)
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
if (type == T_PAGEFLT)
|
||||
return;
|
||||
goto out;
|
||||
@ -370,9 +405,11 @@ nogo:
|
||||
goto we_re_toast;
|
||||
}
|
||||
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
|
||||
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
ucode = type &~ T_USER;
|
||||
frame.tf_err = eva;
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -464,6 +501,7 @@ int trapwrite(addr)
|
||||
struct proc *p;
|
||||
vm_offset_t va;
|
||||
struct vmspace *vm;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)addr);
|
||||
/*
|
||||
@ -478,12 +516,38 @@ int trapwrite(addr)
|
||||
p = curproc;
|
||||
vm = p->p_vmspace;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK /* EWS 11/27/93 */
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr + MAXSSIZ
|
||||
- (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur))
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur)
|
||||
return (1);
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT, DFLSSIZ) -
|
||||
grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vm_fault(&vm->vm_map, va, VM_PROT_READ | VM_PROT_WRITE, FALSE)
|
||||
@ -493,6 +557,7 @@ int trapwrite(addr)
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
|
||||
|
@ -34,7 +34,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)trap.c 7.4 (Berkeley) 5/13/91
|
||||
* $Id: trap.c,v 1.9 1993/11/28 09:28:54 davidg Exp $
|
||||
* $Id: trap.c,v 1.10 1993/12/03 05:07:45 alm Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -81,7 +81,6 @@ void write_gs __P((/* promoted u_short */ int gs));
|
||||
|
||||
struct sysent sysent[];
|
||||
int nsysent;
|
||||
int dostacklimits;
|
||||
unsigned rcr2();
|
||||
extern short cpl;
|
||||
|
||||
@ -117,6 +116,7 @@ char *trap_msg[] = {
|
||||
"stack fault", /* 27 T_STKFLT */
|
||||
};
|
||||
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
|
||||
/*
|
||||
* trap(frame):
|
||||
@ -287,10 +287,11 @@ copyfault:
|
||||
register vm_offset_t va;
|
||||
register struct vmspace *vm = p->p_vmspace;
|
||||
register vm_map_t map;
|
||||
int rv;
|
||||
int rv = 0;
|
||||
vm_prot_t ftype;
|
||||
extern vm_map_t kernel_map;
|
||||
unsigned nss,v;
|
||||
unsigned nss;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)eva);
|
||||
/*
|
||||
@ -323,21 +324,45 @@ copyfault:
|
||||
nss = 0;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK
|
||||
&& map != kernel_map
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr
|
||||
+ MAXSSIZ - (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur)) {
|
||||
/*pg("trap rlimit %d, maxsaddr %x va %x ", nss, vm->vm_maxsaddr, va);*/
|
||||
&& map != kernel_map) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur) {
|
||||
rv = KERN_FAILURE;
|
||||
goto nogo;
|
||||
}
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) - grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
goto nogo;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* check if page table is mapped, if not, fault it first */
|
||||
#define pde_v(v) (PTD[((v)>>PD_SHIFT)&1023].pd_v)
|
||||
if (!pde_v(va)) {
|
||||
v = trunc_page(vtopte(va));
|
||||
v = (char *)trunc_page(vtopte(va));
|
||||
rv = vm_fault(map, v, ftype, FALSE);
|
||||
if (rv != KERN_SUCCESS) goto nogo;
|
||||
/* check if page table fault, increment wiring */
|
||||
@ -348,13 +373,23 @@ copyfault:
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
/*
|
||||
* va could be a page table address, if the fault
|
||||
* occurred from within copyout. In that case,
|
||||
* we have to wire it. (EWS 12/11/93)
|
||||
*/
|
||||
if (ispt(va))
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
va = trunc_page(vtopte(va));
|
||||
/* for page table, increment wiring
|
||||
as long as not a page table fault as well */
|
||||
/*
|
||||
* for page table, increment wiring
|
||||
* as long as not a page table fault as well
|
||||
*/
|
||||
if (!v && type != T_PAGEFLT)
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
vm_map_pageable(map, va, round_page(va+1), FALSE);
|
||||
if (type == T_PAGEFLT)
|
||||
return;
|
||||
goto out;
|
||||
@ -370,9 +405,11 @@ nogo:
|
||||
goto we_re_toast;
|
||||
}
|
||||
i = (rv == KERN_PROTECTION_FAILURE) ? SIGBUS : SIGSEGV;
|
||||
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
ucode = type &~ T_USER;
|
||||
frame.tf_err = eva;
|
||||
/* kludge to pass faulting virtual address to sendsig */
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
@ -464,6 +501,7 @@ int trapwrite(addr)
|
||||
struct proc *p;
|
||||
vm_offset_t va;
|
||||
struct vmspace *vm;
|
||||
char *v;
|
||||
|
||||
va = trunc_page((vm_offset_t)addr);
|
||||
/*
|
||||
@ -478,12 +516,38 @@ int trapwrite(addr)
|
||||
p = curproc;
|
||||
vm = p->p_vmspace;
|
||||
if ((caddr_t)va >= vm->vm_maxsaddr
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK /* EWS 11/27/93 */
|
||||
&& dostacklimits) {
|
||||
nss = clrnd(btoc((unsigned)vm->vm_maxsaddr + MAXSSIZ
|
||||
- (unsigned)va));
|
||||
if (nss > btoc(p->p_rlimit[RLIMIT_STACK].rlim_cur))
|
||||
&& (caddr_t)va < (caddr_t)USRSTACK) {
|
||||
nss = roundup(USRSTACK - (unsigned)va, PAGE_SIZE);
|
||||
if (nss > p->p_rlimit[RLIMIT_STACK].rlim_cur)
|
||||
return (1);
|
||||
|
||||
if (vm->vm_ssize && roundup(vm->vm_ssize << PGSHIFT,
|
||||
DFLSSIZ) < nss) {
|
||||
int grow_amount;
|
||||
/*
|
||||
* If necessary, grow the VM that the stack occupies
|
||||
* to allow for the rlimit. This allows us to not have
|
||||
* to allocate all of the VM up-front in execve (which
|
||||
* is expensive).
|
||||
* Grow the VM by the amount requested rounded up to
|
||||
* the nearest DFLSSIZ to provide for some hysteresis.
|
||||
*/
|
||||
grow_amount = roundup(nss, DFLSSIZ);
|
||||
v = (char *)USRSTACK - roundup(vm->vm_ssize << PGSHIFT, DFLSSIZ) -
|
||||
grow_amount;
|
||||
/*
|
||||
* If there isn't enough room to extend by DFLSSIZ, then
|
||||
* just extend to the maximum size
|
||||
*/
|
||||
if (v < vm->vm_maxsaddr) {
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PGSHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, &v, grow_amount, FALSE) !=
|
||||
KERN_SUCCESS) {
|
||||
return(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vm_fault(&vm->vm_map, va, VM_PROT_READ | VM_PROT_WRITE, FALSE)
|
||||
@ -493,6 +557,7 @@ int trapwrite(addr)
|
||||
/*
|
||||
* XXX: continuation of rude stack hack
|
||||
*/
|
||||
nss = nss >> PGSHIFT;
|
||||
if (nss > vm->vm_ssize)
|
||||
vm->vm_ssize = nss;
|
||||
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)cons.c 7.2 (Berkeley) 5/9/91
|
||||
* $Id: cons.c,v 1.5 1993/11/07 17:41:32 wollman Exp $
|
||||
* $Id: cons.c,v 1.6 1993/11/25 01:30:50 wollman Exp $
|
||||
*/
|
||||
|
||||
|
||||
@ -55,6 +55,12 @@
|
||||
|
||||
/* XXX - all this could be autoconfig()ed */
|
||||
int pccnprobe(), pccninit(), pccngetc(), pccnputc();
|
||||
|
||||
#include "sio.h"
|
||||
#if NSIO > 0
|
||||
int siocnprobe(), siocninit(), siocngetc(), siocnputc();
|
||||
#endif
|
||||
|
||||
#include "com.h"
|
||||
#if NCOM > 0
|
||||
int comcnprobe(), comcninit(), comcngetc(), comcnputc();
|
||||
@ -62,6 +68,9 @@ int comcnprobe(), comcninit(), comcngetc(), comcnputc();
|
||||
|
||||
struct consdev constab[] = {
|
||||
{ pccnprobe, pccninit, pccngetc, pccnputc },
|
||||
#if NSIO > 0
|
||||
{ siocnprobe, siocninit, siocngetc, siocnputc },
|
||||
#endif
|
||||
#if NCOM > 0
|
||||
{ comcnprobe, comcninit, comcngetc, comcnputc },
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user