2003-09-30 00:51:31 +00:00
|
|
|
.\"
|
|
|
|
.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
|
|
|
|
.\" All rights reserved.
|
|
|
|
.\"
|
|
|
|
.\" 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.
|
|
|
|
.\"
|
|
|
|
.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
|
|
|
|
.\"
|
|
|
|
.\" $FreeBSD$
|
|
|
|
.\"
|
2013-01-10 22:36:30 +00:00
|
|
|
.Dd January 11, 2013
|
2004-07-06 06:53:42 +00:00
|
|
|
.Dt VM_MAP_STACK 9
|
2004-07-06 07:02:31 +00:00
|
|
|
.Os
|
2003-09-30 00:51:31 +00:00
|
|
|
.Sh NAME
|
|
|
|
.Nm vm_map_stack ,
|
|
|
|
.Nm vm_map_growstack
|
|
|
|
.Nd manage process stacks
|
|
|
|
.Sh SYNOPSIS
|
|
|
|
.In sys/param.h
|
|
|
|
.In vm/vm.h
|
|
|
|
.In vm/vm_map.h
|
|
|
|
.Ft int
|
2004-07-06 06:53:42 +00:00
|
|
|
.Fo vm_map_stack
|
|
|
|
.Fa "vm_map_t map" "vm_offset_t addrbos" "vm_size_t max_ssize" "vm_prot_t prot"
|
|
|
|
.Fa "vm_prot_t max" "int cow"
|
|
|
|
.Fc
|
2003-09-30 00:51:31 +00:00
|
|
|
.Ft int
|
|
|
|
.Fn vm_map_growstack "struct proc *p" "vm_offset_t addr"
|
|
|
|
.Sh DESCRIPTION
|
|
|
|
The
|
2004-07-06 06:53:42 +00:00
|
|
|
.Fn vm_map_stack
|
2003-09-30 00:51:31 +00:00
|
|
|
function maps a process stack for a new process image.
|
|
|
|
The stack is mapped
|
|
|
|
.Fa addrbos
|
|
|
|
in
|
|
|
|
.Fa map ,
|
|
|
|
with a maximum size of
|
|
|
|
.Fa max_ssize .
|
|
|
|
Copy-on-write flags passed in
|
|
|
|
.Fa cow
|
|
|
|
are also applied to the new mapping.
|
|
|
|
Protection bits are supplied by
|
|
|
|
.Fa prot
|
|
|
|
and
|
|
|
|
.Fa max .
|
|
|
|
.Pp
|
|
|
|
It is typically called by
|
2004-07-06 06:53:42 +00:00
|
|
|
.Xr execve 2 .
|
2003-09-30 00:51:31 +00:00
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn vm_map_growstack
|
|
|
|
function is responsible for growing a stack for the process
|
|
|
|
.Fa p
|
|
|
|
to the desired address
|
|
|
|
.Fa addr ,
|
|
|
|
similar to the legacy
|
|
|
|
.Xr sbrk 2
|
|
|
|
call.
|
|
|
|
.Sh IMPLEMENTATION NOTES
|
|
|
|
The
|
|
|
|
.Fn vm_map_stack
|
|
|
|
function calls
|
|
|
|
.Xr vm_map_insert 9
|
|
|
|
to create its mappings.
|
|
|
|
.Pp
|
|
|
|
The
|
2013-01-10 22:36:30 +00:00
|
|
|
.Fn vm_map_stack
|
|
|
|
and
|
2003-09-30 00:51:31 +00:00
|
|
|
.Fn vm_map_growstack
|
2013-01-10 22:36:30 +00:00
|
|
|
functions acquire the process lock on
|
|
|
|
.Fa p
|
2003-09-30 00:51:31 +00:00
|
|
|
for the duration of the call.
|
|
|
|
.Sh RETURN VALUES
|
|
|
|
The
|
|
|
|
.Fn vm_map_stack
|
|
|
|
function returns
|
|
|
|
.Dv KERN_SUCCESS
|
|
|
|
if the mapping was allocated successfully.
|
|
|
|
.Pp
|
|
|
|
Otherwise,
|
|
|
|
if mapping the stack would exceed the process's VMEM resource limit,
|
|
|
|
or if the specified bottom-of-stack address is out of range for the map,
|
|
|
|
or if there is already a mapping at the address which would result,
|
|
|
|
or if
|
|
|
|
.Fa max_ssize
|
2006-12-14 14:33:13 +00:00
|
|
|
could not be accommodated within the current mapping,
|
2003-09-30 00:51:31 +00:00
|
|
|
.Dv KERN_NO_SPACE
|
|
|
|
is returned.
|
|
|
|
.Pp
|
|
|
|
Other possible return values for this function are documented in
|
|
|
|
.Xr vm_map_insert 9 .
|
|
|
|
.Pp
|
|
|
|
The
|
|
|
|
.Fn vm_map_growstack
|
|
|
|
function returns
|
|
|
|
.Dv KERN_SUCCESS
|
|
|
|
if
|
|
|
|
.Fa addr
|
|
|
|
is already mapped, or if the stack was grown successfully.
|
|
|
|
.Pp
|
|
|
|
It also returns
|
|
|
|
.Dv KERN_SUCCESS
|
|
|
|
if
|
|
|
|
.Fa addr
|
|
|
|
is outside the stack range; this is done in order to preserve
|
|
|
|
compatibility with the deprecated
|
|
|
|
.Fn grow
|
|
|
|
function previously located in the file
|
2004-07-06 06:53:42 +00:00
|
|
|
.Pa vm_machdep.c .
|
2003-09-30 00:51:31 +00:00
|
|
|
.Sh SEE ALSO
|
|
|
|
.Xr vm_map 9 ,
|
|
|
|
.Xr vm_map_insert 9
|
|
|
|
.Sh AUTHORS
|
2005-06-28 20:15:19 +00:00
|
|
|
This manual page was written by
|
2003-09-30 00:51:31 +00:00
|
|
|
.An Bruce M Simpson Aq bms@spc.org .
|