xref: /freebsd/share/man/man9/vm_map_stack.9 (revision d37ea99837e6ad50837fd9fe1771ddf1c3ba6002)
1.\"
2.\" Copyright (c) 2003 Bruce M Simpson <bms@spc.org>
3.\" All rights reserved.
4.\"
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.\" $FreeBSD$
27.\"
28.Dd July 19, 2003
29.Dt vm_map_stack 9
30.Sh NAME
31.Nm vm_map_stack ,
32.Nm vm_map_growstack
33.Nd manage process stacks
34.Sh SYNOPSIS
35.In sys/param.h
36.In vm/vm.h
37.In vm/vm_map.h
38.Ft int
39.Fn 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"
40.Ft int
41.Fn vm_map_growstack "struct proc *p" "vm_offset_t addr"
42.Sh DESCRIPTION
43The
44.Fn
45function maps a process stack for a new process image.
46The stack is mapped
47.Fa addrbos
48in
49.Fa map ,
50with a maximum size of
51.Fa max_ssize .
52Copy-on-write flags passed in
53.Fa cow
54are also applied to the new mapping.
55Protection bits are supplied by
56.Fa prot
57and
58.Fa max .
59.Pp
60It is typically called by
61.Xr exec 2 .
62.Pp
63The
64.Fn vm_map_growstack
65function is responsible for growing a stack for the process
66.Fa p
67to the desired address
68.Fa addr ,
69similar to the legacy
70.Xr sbrk 2
71call.
72.Sh IMPLEMENTATION NOTES
73The
74.Fn vm_map_stack
75function calls
76.Xr vm_map_insert 9
77to create its mappings.
78.Pp
79The
80.Fn vm_map_growstack
81function acquires the
82.Dv Giant
83lock, and the process lock on
84.Fa p ,
85for the duration of the call.
86.Sh RETURN VALUES
87The
88.Fn vm_map_stack
89function returns
90.Dv KERN_SUCCESS
91if the mapping was allocated successfully.
92.Pp
93Otherwise,
94if mapping the stack would exceed the process's VMEM resource limit,
95or if the specified bottom-of-stack address is out of range for the map,
96or if there is already a mapping at the address which would result,
97or if
98.Fa max_ssize
99could not be accomodated within the current mapping,
100.Dv KERN_NO_SPACE
101is returned.
102.Pp
103Other possible return values for this function are documented in
104.Xr vm_map_insert 9 .
105.Pp
106The
107.Fn vm_map_growstack
108function returns
109.Dv KERN_SUCCESS
110if
111.Fa addr
112is already mapped, or if the stack was grown successfully.
113.Pp
114It also returns
115.Dv KERN_SUCCESS
116if
117.Fa addr
118is outside the stack range; this is done in order to preserve
119compatibility with the deprecated
120.Fn grow
121function previously located in the file
122.Li vm_machdep.c .
123.Sh SEE ALSO
124.Xr vm_map 9 ,
125.Xr vm_map_insert 9
126.Sh AUTHORS
127This man page was written by
128.An Bruce M Simpson Aq bms@spc.org .
129