diff options
author | julian <julian@FreeBSD.org> | 1999-01-06 23:05:42 +0000 |
---|---|---|
committer | julian <julian@FreeBSD.org> | 1999-01-06 23:05:42 +0000 |
commit | 4666ac50272776168d29d2c4142de771daa30381 (patch) | |
tree | 132bbd3c7ed8de9adf36dcd6258013de903e583a /sys/amd64 | |
parent | 6b0a11c013bb11bbed19aea0a563ebb393a899ef (diff) | |
download | FreeBSD-src-4666ac50272776168d29d2c4142de771daa30381.zip FreeBSD-src-4666ac50272776168d29d2c4142de771daa30381.tar.gz |
Add (but don't activate) code for a special VM option to make
downward growing stacks more general.
Add (but don't activate) code to use the new stack facility
when running threads, (specifically the linux threads support).
This allows people to use both linux compiled linuxthreads, and also the
native FreeBSD linux-threads port.
The code is conditional on VM_STACK. Not using this will
produce the old heavily tested system.
Submitted by: Richard Seaman <dick@tar.com>
Diffstat (limited to 'sys/amd64')
-rw-r--r-- | sys/amd64/amd64/machdep.c | 6 | ||||
-rw-r--r-- | sys/amd64/amd64/trap.c | 38 | ||||
-rw-r--r-- | sys/amd64/amd64/vm_machdep.c | 19 |
3 files changed, 60 insertions, 3 deletions
diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index 45c5e8f..cb4f514 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 - * $Id: machdep.c,v 1.318 1998/12/10 01:49:01 steve Exp $ + * $Id: machdep.c,v 1.319 1998/12/16 16:28:56 bde Exp $ */ #include "apm.h" @@ -525,7 +525,11 @@ sendsig(catcher, sig, mask, code) * and the stack can not be grown. useracc will return FALSE * if access is denied. */ +#ifdef VM_STACK + if ((grow_stack (p, (int)fp) == FALSE) || +#else if ((grow(p, (int)fp) == FALSE) || +#endif (useracc((caddr_t)fp, sizeof(struct sigframe), B_WRITE) == FALSE)) { /* * Process has trashed its stack; give it an illegal diff --git a/sys/amd64/amd64/trap.c b/sys/amd64/amd64/trap.c index e672368..42b0c85 100644 --- a/sys/amd64/amd64/trap.c +++ b/sys/amd64/amd64/trap.c @@ -35,7 +35,7 @@ * SUCH DAMAGE. * * from: @(#)trap.c 7.4 (Berkeley) 5/13/91 - * $Id: trap.c,v 1.131 1998/12/16 15:21:50 bde Exp $ + * $Id: trap.c,v 1.132 1998/12/28 23:02:56 msmith Exp $ */ /* @@ -665,6 +665,7 @@ trap_pfault(frame, usermode, eva) /* * Grow the stack if necessary */ +#ifndef VM_STACK if ((caddr_t)va > vm->vm_maxsaddr && va < USRSTACK) { if (!grow(p, va)) { rv = KERN_FAILURE; @@ -673,6 +674,20 @@ trap_pfault(frame, usermode, eva) } } +#else + /* grow_stack returns false only if va falls into + * a growable stack region and the stack growth + * fails. It returns true if va was not within + * a growable stack region, or if the stack + * growth succeeded. + */ + if (!grow_stack (p, va)) { + rv = KERN_FAILURE; + --p->p_lock; + goto nogo; + } +#endif + /* Fault in the user page: */ rv = vm_fault(map, va, ftype, (ftype & VM_PROT_WRITE) ? VM_FAULT_DIRTY : 0); @@ -775,6 +790,7 @@ trap_pfault(frame, usermode, eva) /* * Grow the stack if necessary */ +#ifndef VM_STACK if ((caddr_t)va > vm->vm_maxsaddr && va < USRSTACK) { if (!grow(p, va)) { rv = KERN_FAILURE; @@ -782,6 +798,19 @@ trap_pfault(frame, usermode, eva) goto nogo; } } +#else + /* grow_stack returns false only if va falls into + * a growable stack region and the stack growth + * fails. It returns true if va was not within + * a growable stack region, or if the stack + * growth succeeded. + */ + if (!grow_stack (p, va)) { + rv = KERN_FAILURE; + --p->p_lock; + goto nogo; + } +#endif /* Fault in the user page: */ rv = vm_fault(map, va, ftype, @@ -969,12 +998,19 @@ int trapwrite(addr) ++p->p_lock; +#ifndef VM_STACK if ((caddr_t)va >= vm->vm_maxsaddr && va < USRSTACK) { if (!grow(p, va)) { --p->p_lock; return (1); } } +#else + if (!grow_stack (p, va)) { + --p->p_lock; + return (1); + } +#endif /* * fault the data page diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index 761008e..d0bdc93 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -38,7 +38,7 @@ * * from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91 * Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$ - * $Id: vm_machdep.c,v 1.113 1998/10/31 17:21:30 peter Exp $ + * $Id: vm_machdep.c,v 1.114 1998/12/16 15:21:51 bde Exp $ */ #include "npx.h" @@ -507,6 +507,7 @@ cpu_reset_real() while(1); } +#ifndef VM_STACK /* * Grow the user stack to allow for 'sp'. This version grows the stack in * chunks of SGROWSIZ. @@ -559,6 +560,22 @@ grow(p, sp) return (1); } +#else +int +grow_stack(p, sp) + struct proc *p; + u_int sp; +{ + int rv; + + rv = vm_map_growstack (p, sp); + if (rv != KERN_SUCCESS) + return (0); + + return (1); +} +#endif + static int cnt_prezero; |