xref: /freebsd-13.1/share/man/man9/vm_map_stack.9 (revision a970c85c)
1.\"
2.\" Copyright (c) 2003 Bruce M Simpson <[email protected]>
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.Fo vm_map_stack
40.Fa "vm_map_t map" "vm_offset_t addrbos" "vm_size_t max_ssize" "vm_prot_t prot"
41.Fa "vm_prot_t max" "int cow"
42.Fc
43.Ft int
44.Fn vm_map_growstack "struct proc *p" "vm_offset_t addr"
45.Sh DESCRIPTION
46The
47.Fn vm_map_stack
48function maps a process stack for a new process image.
49The stack is mapped
50.Fa addrbos
51in
52.Fa map ,
53with a maximum size of
54.Fa max_ssize .
55Copy-on-write flags passed in
56.Fa cow
57are also applied to the new mapping.
58Protection bits are supplied by
59.Fa prot
60and
61.Fa max .
62.Pp
63It is typically called by
64.Xr execve 2 .
65.Pp
66The
67.Fn vm_map_growstack
68function is responsible for growing a stack for the process
69.Fa p
70to the desired address
71.Fa addr ,
72similar to the legacy
73.Xr sbrk 2
74call.
75.Sh IMPLEMENTATION NOTES
76The
77.Fn vm_map_stack
78function calls
79.Xr vm_map_insert 9
80to create its mappings.
81.Pp
82The
83.Fn vm_map_growstack
84function acquires the
85.Va Giant
86lock, and the process lock on
87.Fa p ,
88for the duration of the call.
89.Sh RETURN VALUES
90The
91.Fn vm_map_stack
92function returns
93.Dv KERN_SUCCESS
94if the mapping was allocated successfully.
95.Pp
96Otherwise,
97if mapping the stack would exceed the process's VMEM resource limit,
98or if the specified bottom-of-stack address is out of range for the map,
99or if there is already a mapping at the address which would result,
100or if
101.Fa max_ssize
102could not be accomodated within the current mapping,
103.Dv KERN_NO_SPACE
104is returned.
105.Pp
106Other possible return values for this function are documented in
107.Xr vm_map_insert 9 .
108.Pp
109The
110.Fn vm_map_growstack
111function returns
112.Dv KERN_SUCCESS
113if
114.Fa addr
115is already mapped, or if the stack was grown successfully.
116.Pp
117It also returns
118.Dv KERN_SUCCESS
119if
120.Fa addr
121is outside the stack range; this is done in order to preserve
122compatibility with the deprecated
123.Fn grow
124function previously located in the file
125.Pa vm_machdep.c .
126.Sh SEE ALSO
127.Xr vm_map 9 ,
128.Xr vm_map_insert 9
129.Sh AUTHORS
130This man page was written by
131.An Bruce M Simpson Aq [email protected] .
132