diff options
-rw-r--r-- | lib/libc/sys/mmap.2 | 19 | ||||
-rw-r--r-- | sys/alpha/alpha/machdep.c | 12 | ||||
-rw-r--r-- | sys/alpha/alpha/trap.c | 17 | ||||
-rw-r--r-- | sys/alpha/alpha/vm_machdep.c | 19 | ||||
-rw-r--r-- | sys/conf/Makefile.i386 | 4 | ||||
-rw-r--r-- | sys/conf/Makefile.powerpc | 4 | ||||
-rw-r--r-- | sys/i386/conf/Makefile.i386 | 4 | ||||
-rw-r--r-- | sys/powerpc/aim/vm_machdep.c | 19 | ||||
-rw-r--r-- | sys/powerpc/powerpc/vm_machdep.c | 19 | ||||
-rw-r--r-- | sys/sys/mman.h | 4 | ||||
-rw-r--r-- | sys/vm/vm_extern.h | 5 | ||||
-rw-r--r-- | sys/vm/vm_map.c | 8 | ||||
-rw-r--r-- | sys/vm/vm_map.h | 6 | ||||
-rw-r--r-- | sys/vm/vm_mmap.c | 9 |
14 files changed, 116 insertions, 33 deletions
diff --git a/lib/libc/sys/mmap.2 b/lib/libc/sys/mmap.2 index 174a083..a2be590 100644 --- a/lib/libc/sys/mmap.2 +++ b/lib/libc/sys/mmap.2 @@ -130,6 +130,25 @@ system calls. Modifications are private. .It Dv MAP_SHARED Modifications are shared. +.It Dv MAP_STACK +This option is only available if your system has been compiled with +VM_STACK defined when compiling the kernel. This is the default for +i386 only. Consider adding -DVM_STACK to COPTFLAGS in your /etc/make.conf +to enable this option for other architechures. MAP_STACK implies +MAP_ANON, and +.Fa offset +of 0. +.Fa fd +must be -1 and +.Fa prot +must include at least PROT_READ and PROT_WRITE. This option creates +a memory region that grows to at most +.Fa len +bytes in size, starting from the stack top and growing down. The +stack top is the starting address returned by the call, plus +.Fa len +bytes. The bottom of the stack at maximum growth is the starting +address returned by the call. .El .Pp The diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 5211879..f98904e 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: machdep.c,v 1.29 1998/12/30 10:38:58 dfr Exp $ + * $Id: machdep.c,v 1.30 1999/01/15 18:00:19 msmith Exp $ */ /*- * Copyright (c) 1998 The NetBSD Foundation, Inc. @@ -1268,12 +1268,22 @@ sendsig(sig_t catcher, int sig, int mask, u_long code) psp->ps_sigstk.ss_flags |= SS_ONSTACK; } else scp = (struct sigcontext *)(alpha_pal_rdusp() - rndfsize); +#ifndef VM_STACK if ((u_long)scp <= USRSTACK - ctob(p->p_vmspace->vm_ssize)) #if defined(UVM) (void)uvm_grow(p, (u_long)scp); #else (void)grow(p, (u_long)scp); #endif +#else + /* Note: uvm_grow doesn't seem to be defined anywhere, so we don't + * know how to implement it for the VM_STACK case. Also, we would + * think that it would be wise to test for success of grow_stack, + * but we don't since there is no test for success for grow in the + * non VM_STACK case. + */ + (void)grow_stack(p, (u_long)scp); +#endif #ifdef DEBUG if ((sigdebug & SDB_KSTACK) && p->p_pid == sigpid) printf("sendsig(%d): sig %d ssp %p usp %p\n", p->p_pid, diff --git a/sys/alpha/alpha/trap.c b/sys/alpha/alpha/trap.c index 107f1b0..2a91e7d 100644 --- a/sys/alpha/alpha/trap.c +++ b/sys/alpha/alpha/trap.c @@ -1,4 +1,4 @@ -/* $Id: trap.c,v 1.9 1998/12/16 15:21:50 bde Exp $ */ +/* $Id: trap.c,v 1.10 1998/12/30 10:38:58 dfr Exp $ */ /* $NetBSD: trap.c,v 1.31 1998/03/26 02:21:46 thorpej Exp $ */ /* @@ -418,6 +418,7 @@ trap(a0, a1, a2, entry, framep) /* * Grow the stack if necessary */ +#ifndef VM_STACK if ((caddr_t)va > vm->vm_maxsaddr && va < USRSTACK) { if (!grow(p, va)) { @@ -426,6 +427,20 @@ trap(a0, a1, a2, entry, framep) 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, diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index 592a089..ed102b1 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/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.6 1998/12/16 15:21:50 bde Exp $ + * $Id: vm_machdep.c,v 1.7 1998/12/30 10:38:58 dfr Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -365,6 +365,7 @@ cpu_reset() prom_halt(0); } +#ifndef VM_STACK /* * Grow the user stack to allow for 'sp'. This version grows the stack in * chunks of SGROWSIZ. @@ -417,6 +418,22 @@ grow(p, sp) return (1); } +#else +int +grow_stack(p, sp) + struct proc *p; + size_t sp; +{ + int rv; + + rv = vm_map_growstack (p, sp); + if (rv != KERN_SUCCESS) + return (0); + + return (1); +} +#endif + static int cnt_prezero; diff --git a/sys/conf/Makefile.i386 b/sys/conf/Makefile.i386 index c0ae571..77f2e3e 100644 --- a/sys/conf/Makefile.i386 +++ b/sys/conf/Makefile.i386 @@ -1,7 +1,7 @@ # Makefile.i386 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.136 1999/01/19 17:08:28 peter Exp $ +# $Id: Makefile.i386,v 1.137 1999/01/25 04:08:28 peter Exp $ # # Makefile for FreeBSD # @@ -38,7 +38,7 @@ INCLUDES+= -I$S/../include .else INCLUDES+= -I/usr/include .endif -COPTS= ${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h +COPTS= ${INCLUDES} ${IDENT} -DKERNEL -DVM_STACK -include opt_global.h CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} # XXX LOCORE means "don't declare C stuff" not "for locore.s". diff --git a/sys/conf/Makefile.powerpc b/sys/conf/Makefile.powerpc index c0ae571..77f2e3e 100644 --- a/sys/conf/Makefile.powerpc +++ b/sys/conf/Makefile.powerpc @@ -1,7 +1,7 @@ # Makefile.i386 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.136 1999/01/19 17:08:28 peter Exp $ +# $Id: Makefile.i386,v 1.137 1999/01/25 04:08:28 peter Exp $ # # Makefile for FreeBSD # @@ -38,7 +38,7 @@ INCLUDES+= -I$S/../include .else INCLUDES+= -I/usr/include .endif -COPTS= ${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h +COPTS= ${INCLUDES} ${IDENT} -DKERNEL -DVM_STACK -include opt_global.h CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} # XXX LOCORE means "don't declare C stuff" not "for locore.s". diff --git a/sys/i386/conf/Makefile.i386 b/sys/i386/conf/Makefile.i386 index c0ae571..77f2e3e 100644 --- a/sys/i386/conf/Makefile.i386 +++ b/sys/i386/conf/Makefile.i386 @@ -1,7 +1,7 @@ # Makefile.i386 -- with config changes. # Copyright 1990 W. Jolitz # from: @(#)Makefile.i386 7.1 5/10/91 -# $Id: Makefile.i386,v 1.136 1999/01/19 17:08:28 peter Exp $ +# $Id: Makefile.i386,v 1.137 1999/01/25 04:08:28 peter Exp $ # # Makefile for FreeBSD # @@ -38,7 +38,7 @@ INCLUDES+= -I$S/../include .else INCLUDES+= -I/usr/include .endif -COPTS= ${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h +COPTS= ${INCLUDES} ${IDENT} -DKERNEL -DVM_STACK -include opt_global.h CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS} # XXX LOCORE means "don't declare C stuff" not "for locore.s". diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c index 592a089..ed102b1 100644 --- a/sys/powerpc/aim/vm_machdep.c +++ b/sys/powerpc/aim/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.6 1998/12/16 15:21:50 bde Exp $ + * $Id: vm_machdep.c,v 1.7 1998/12/30 10:38:58 dfr Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -365,6 +365,7 @@ cpu_reset() prom_halt(0); } +#ifndef VM_STACK /* * Grow the user stack to allow for 'sp'. This version grows the stack in * chunks of SGROWSIZ. @@ -417,6 +418,22 @@ grow(p, sp) return (1); } +#else +int +grow_stack(p, sp) + struct proc *p; + size_t sp; +{ + int rv; + + rv = vm_map_growstack (p, sp); + if (rv != KERN_SUCCESS) + return (0); + + return (1); +} +#endif + static int cnt_prezero; diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c index 592a089..ed102b1 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/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.6 1998/12/16 15:21:50 bde Exp $ + * $Id: vm_machdep.c,v 1.7 1998/12/30 10:38:58 dfr Exp $ */ /* * Copyright (c) 1994, 1995, 1996 Carnegie-Mellon University. @@ -365,6 +365,7 @@ cpu_reset() prom_halt(0); } +#ifndef VM_STACK /* * Grow the user stack to allow for 'sp'. This version grows the stack in * chunks of SGROWSIZ. @@ -417,6 +418,22 @@ grow(p, sp) return (1); } +#else +int +grow_stack(p, sp) + struct proc *p; + size_t sp; +{ + int rv; + + rv = vm_map_growstack (p, sp); + if (rv != KERN_SUCCESS) + return (0); + + return (1); +} +#endif + static int cnt_prezero; diff --git a/sys/sys/mman.h b/sys/sys/mman.h index c659243..7329d8f 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)mman.h 8.2 (Berkeley) 1/9/95 - * $Id: mman.h,v 1.23 1998/03/28 11:50:38 dufault Exp $ + * $Id: mman.h,v 1.24 1999/01/06 23:05:40 julian Exp $ */ #ifndef _SYS_MMAN_H_ @@ -64,9 +64,7 @@ #define MAP_INHERIT 0x0080 /* region is retained after exec */ #define MAP_NOEXTEND 0x0100 /* for MAP_FILE, don't change file size */ #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ -#ifdef VM_STACK #define MAP_STACK 0x0400 /* region grows down, like a stack */ -#endif #ifdef _P1003_1B_VISIBLE /* diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h index ca5a53e..69a5ebb 100644 --- a/sys/vm/vm_extern.h +++ b/sys/vm/vm_extern.h @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94 - * $Id: vm_extern.h,v 1.38 1998/06/07 17:13:09 dfr Exp $ + * $Id: vm_extern.h,v 1.39 1999/01/06 23:05:41 julian Exp $ */ #ifndef _VM_EXTERN_H_ @@ -61,11 +61,8 @@ int swapon __P((struct proc *, void *, int *)); #endif void faultin __P((struct proc *p)); -#ifndef VM_STACK int grow __P((struct proc *, size_t)); -#else int grow_stack __P((struct proc *, size_t)); -#endif int kernacc __P((caddr_t, int, int)); vm_offset_t kmem_alloc __P((vm_map_t, vm_size_t)); vm_offset_t kmem_alloc_pageable __P((vm_map_t, vm_size_t)); diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 6a287b8..b1c4d82 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_map.c,v 1.141 1999/01/21 09:40:48 dillon Exp $ + * $Id: vm_map.c,v 1.142 1999/01/24 06:04:52 dillon Exp $ */ /* @@ -75,9 +75,7 @@ #include <sys/vmmeter.h> #include <sys/mman.h> #include <sys/vnode.h> -#ifdef VM_STACK #include <sys/resourcevar.h> -#endif #include <vm/vm.h> #include <vm/vm_param.h> @@ -548,9 +546,7 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, new_entry->eflags = protoeflags; new_entry->object.vm_object = object; new_entry->offset = offset; -#ifdef VM_STACK new_entry->avail_ssize = 0; -#endif if (object) { if ((object->ref_count > 1) || (object->shadow_count != 0)) { @@ -589,7 +585,6 @@ vm_map_insert(vm_map_t map, vm_object_t object, vm_ooffset_t offset, return (KERN_SUCCESS); } -#ifdef VM_STACK int vm_map_stack (vm_map_t map, vm_offset_t addrbos, vm_size_t max_ssize, vm_prot_t prot, vm_prot_t max, int cow) @@ -785,7 +780,6 @@ vm_map_growstack (struct proc *p, vm_offset_t addr) return (rv); } -#endif /* * Find sufficient space for `length' bytes in the given map, starting at diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h index 4d61a3f..de3e267 100644 --- a/sys/vm/vm_map.h +++ b/sys/vm/vm_map.h @@ -61,7 +61,7 @@ * any improvements or extensions that they make and grant Carnegie the * rights to redistribute these changes. * - * $Id: vm_map.h,v 1.32 1998/01/22 17:30:38 dyson Exp $ + * $Id: vm_map.h,v 1.33 1999/01/06 23:05:42 julian Exp $ */ /* @@ -102,9 +102,7 @@ struct vm_map_entry { struct vm_map_entry *next; /* next entry */ vm_offset_t start; /* start address */ vm_offset_t end; /* end address */ -#ifdef VM_STACK vm_offset_t avail_ssize; /* amt can grow if this is a stack */ -#endif union vm_map_object object; /* object I point to */ vm_ooffset_t offset; /* offset into object */ u_char eflags; /* map entry flags */ @@ -338,10 +336,8 @@ void vm_map_simplify_entry __P((vm_map_t, vm_map_entry_t)); void vm_init2 __P((void)); int vm_uiomove __P((vm_map_t, vm_object_t, off_t, int, vm_offset_t, int *)); void vm_freeze_copyopts __P((vm_object_t, vm_pindex_t, vm_pindex_t)); -#ifdef VM_STACK int vm_map_stack __P((vm_map_t, vm_offset_t, vm_size_t, vm_prot_t, vm_prot_t, int)); int vm_map_growstack __P((struct proc *p, vm_offset_t addr)); -#endif #endif #endif /* _VM_MAP_ */ diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 1374dfb..ea40147 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -38,7 +38,7 @@ * from: Utah $Hdr: vm_mmap.c 1.6 91/10/21$ * * @(#)vm_mmap.c 8.4 (Berkeley) 1/12/94 - * $Id: vm_mmap.c,v 1.86 1999/01/06 23:05:42 julian Exp $ + * $Id: vm_mmap.c,v 1.87 1999/01/21 08:29:11 dillon Exp $ */ /* @@ -178,15 +178,18 @@ mmap(p, uap) ((flags & MAP_ANON) && uap->fd != -1)) return (EINVAL); -#ifdef VM_STACK if (flags & MAP_STACK) { +#ifdef VM_STACK if ((uap->fd != -1) || ((prot & (PROT_READ | PROT_WRITE)) != (PROT_READ | PROT_WRITE))) return (EINVAL); flags |= MAP_ANON; pos = 0; - } +#else + return (EINVAL); #endif + } + /* * Align the file position to a page boundary, * and save its page offset component. |