17d216f0fSBruce M Simpson.\" 27d216f0fSBruce M Simpson.\" Copyright (c) 2003 Bruce M Simpson <[email protected]> 37d216f0fSBruce M Simpson.\" All rights reserved. 47d216f0fSBruce M Simpson.\" 57d216f0fSBruce M Simpson.\" Redistribution and use in source and binary forms, with or without 67d216f0fSBruce M Simpson.\" modification, are permitted provided that the following conditions 77d216f0fSBruce M Simpson.\" are met: 87d216f0fSBruce M Simpson.\" 1. Redistributions of source code must retain the above copyright 97d216f0fSBruce M Simpson.\" notice, this list of conditions and the following disclaimer. 107d216f0fSBruce M Simpson.\" 2. Redistributions in binary form must reproduce the above copyright 117d216f0fSBruce M Simpson.\" notice, this list of conditions and the following disclaimer in the 127d216f0fSBruce M Simpson.\" documentation and/or other materials provided with the distribution. 137d216f0fSBruce M Simpson.\" 147d216f0fSBruce M Simpson.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 157d216f0fSBruce M Simpson.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 167d216f0fSBruce M Simpson.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 177d216f0fSBruce M Simpson.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 187d216f0fSBruce M Simpson.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 197d216f0fSBruce M Simpson.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 207d216f0fSBruce M Simpson.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 217d216f0fSBruce M Simpson.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 227d216f0fSBruce M Simpson.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 237d216f0fSBruce M Simpson.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 247d216f0fSBruce M Simpson.\" SUCH DAMAGE. 257d216f0fSBruce M Simpson.\" 267d216f0fSBruce M Simpson.\" $FreeBSD$ 277d216f0fSBruce M Simpson.\" 28e86fef2aSSergey Kandaurov.Dd January 11, 2013 29a970c85cSRuslan Ermilov.Dt VM_MAP_STACK 9 30b4ca3754SRuslan Ermilov.Os 317d216f0fSBruce M Simpson.Sh NAME 327d216f0fSBruce M Simpson.Nm vm_map_stack , 337d216f0fSBruce M Simpson.Nm vm_map_growstack 347d216f0fSBruce M Simpson.Nd manage process stacks 357d216f0fSBruce M Simpson.Sh SYNOPSIS 367d216f0fSBruce M Simpson.In sys/param.h 377d216f0fSBruce M Simpson.In vm/vm.h 387d216f0fSBruce M Simpson.In vm/vm_map.h 397d216f0fSBruce M Simpson.Ft int 40a970c85cSRuslan Ermilov.Fo vm_map_stack 41a970c85cSRuslan Ermilov.Fa "vm_map_t map" "vm_offset_t addrbos" "vm_size_t max_ssize" "vm_prot_t prot" 42a970c85cSRuslan Ermilov.Fa "vm_prot_t max" "int cow" 43a970c85cSRuslan Ermilov.Fc 447d216f0fSBruce M Simpson.Ft int 457d216f0fSBruce M Simpson.Fn vm_map_growstack "struct proc *p" "vm_offset_t addr" 467d216f0fSBruce M Simpson.Sh DESCRIPTION 477d216f0fSBruce M SimpsonThe 48a970c85cSRuslan Ermilov.Fn vm_map_stack 497d216f0fSBruce M Simpsonfunction maps a process stack for a new process image. 507d216f0fSBruce M SimpsonThe stack is mapped 517d216f0fSBruce M Simpson.Fa addrbos 527d216f0fSBruce M Simpsonin 537d216f0fSBruce M Simpson.Fa map , 547d216f0fSBruce M Simpsonwith a maximum size of 557d216f0fSBruce M Simpson.Fa max_ssize . 567d216f0fSBruce M SimpsonCopy-on-write flags passed in 577d216f0fSBruce M Simpson.Fa cow 587d216f0fSBruce M Simpsonare also applied to the new mapping. 597d216f0fSBruce M SimpsonProtection bits are supplied by 607d216f0fSBruce M Simpson.Fa prot 617d216f0fSBruce M Simpsonand 627d216f0fSBruce M Simpson.Fa max . 637d216f0fSBruce M Simpson.Pp 647d216f0fSBruce M SimpsonIt is typically called by 65a970c85cSRuslan Ermilov.Xr execve 2 . 667d216f0fSBruce M Simpson.Pp 677d216f0fSBruce M SimpsonThe 687d216f0fSBruce M Simpson.Fn vm_map_growstack 697d216f0fSBruce M Simpsonfunction is responsible for growing a stack for the process 707d216f0fSBruce M Simpson.Fa p 717d216f0fSBruce M Simpsonto the desired address 727d216f0fSBruce M Simpson.Fa addr , 737d216f0fSBruce M Simpsonsimilar to the legacy 747d216f0fSBruce M Simpson.Xr sbrk 2 757d216f0fSBruce M Simpsoncall. 767d216f0fSBruce M Simpson.Sh IMPLEMENTATION NOTES 777d216f0fSBruce M SimpsonThe 787d216f0fSBruce M Simpson.Fn vm_map_stack 797d216f0fSBruce M Simpsonfunction calls 807d216f0fSBruce M Simpson.Xr vm_map_insert 9 817d216f0fSBruce M Simpsonto create its mappings. 827d216f0fSBruce M Simpson.Pp 837d216f0fSBruce M SimpsonThe 84e86fef2aSSergey Kandaurov.Fn vm_map_stack 85e86fef2aSSergey Kandaurovand 867d216f0fSBruce M Simpson.Fn vm_map_growstack 87e86fef2aSSergey Kandaurovfunctions acquire the process lock on 88e86fef2aSSergey Kandaurov.Fa p 897d216f0fSBruce M Simpsonfor the duration of the call. 907d216f0fSBruce M Simpson.Sh RETURN VALUES 917d216f0fSBruce M SimpsonThe 927d216f0fSBruce M Simpson.Fn vm_map_stack 937d216f0fSBruce M Simpsonfunction returns 947d216f0fSBruce M Simpson.Dv KERN_SUCCESS 957d216f0fSBruce M Simpsonif the mapping was allocated successfully. 967d216f0fSBruce M Simpson.Pp 977d216f0fSBruce M SimpsonOtherwise, 987d216f0fSBruce M Simpsonif mapping the stack would exceed the process's VMEM resource limit, 997d216f0fSBruce M Simpsonor if the specified bottom-of-stack address is out of range for the map, 1007d216f0fSBruce M Simpsonor if there is already a mapping at the address which would result, 1017d216f0fSBruce M Simpsonor if 1027d216f0fSBruce M Simpson.Fa max_ssize 1039280e5faSMike Pritchardcould not be accommodated within the current mapping, 1047d216f0fSBruce M Simpson.Dv KERN_NO_SPACE 1057d216f0fSBruce M Simpsonis returned. 1067d216f0fSBruce M Simpson.Pp 1077d216f0fSBruce M SimpsonOther possible return values for this function are documented in 1087d216f0fSBruce M Simpson.Xr vm_map_insert 9 . 1097d216f0fSBruce M Simpson.Pp 1107d216f0fSBruce M SimpsonThe 1117d216f0fSBruce M Simpson.Fn vm_map_growstack 1127d216f0fSBruce M Simpsonfunction returns 1137d216f0fSBruce M Simpson.Dv KERN_SUCCESS 1147d216f0fSBruce M Simpsonif 1157d216f0fSBruce M Simpson.Fa addr 1167d216f0fSBruce M Simpsonis already mapped, or if the stack was grown successfully. 1177d216f0fSBruce M Simpson.Pp 1187d216f0fSBruce M SimpsonIt also returns 1197d216f0fSBruce M Simpson.Dv KERN_SUCCESS 1207d216f0fSBruce M Simpsonif 1217d216f0fSBruce M Simpson.Fa addr 1227d216f0fSBruce M Simpsonis outside the stack range; this is done in order to preserve 1237d216f0fSBruce M Simpsoncompatibility with the deprecated 1247d216f0fSBruce M Simpson.Fn grow 1257d216f0fSBruce M Simpsonfunction previously located in the file 126a970c85cSRuslan Ermilov.Pa vm_machdep.c . 1277d216f0fSBruce M Simpson.Sh SEE ALSO 1287d216f0fSBruce M Simpson.Xr vm_map 9 , 1297d216f0fSBruce M Simpson.Xr vm_map_insert 9 1307d216f0fSBruce M Simpson.Sh AUTHORS 131571dba6eSHiten PandyaThis manual page was written by 132*8a7314fcSBaptiste Daroussin.An Bruce M Simpson Aq Mt [email protected] . 133