summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2003-09-27 22:28:14 +0000
committermarcel <marcel@FreeBSD.org>2003-09-27 22:28:14 +0000
commitd75cf983076733a922bb61d7b8d2683e3200de71 (patch)
treeca87952e7714e85716c318c18850085a80633493 /sys/kern/kern_exec.c
parent9d6689c4a78aa15eeea04d8fc8d55500ebf7b56c (diff)
downloadFreeBSD-src-d75cf983076733a922bb61d7b8d2683e3200de71.zip
FreeBSD-src-d75cf983076733a922bb61d7b8d2683e3200de71.tar.gz
Part 2 of implementing rstacks: add the ability to create rstacks and
use the ability on ia64 to map the register stack. The orientation of the stack (i.e. its grow direction) is passed to vm_map_stack() in the overloaded cow argument. Since the grow direction is represented by bits, it is possible and allowed to create bi-directional stacks. This is not an advertised feature, more of a side-effect. Fix a bug in vm_map_growstack() that's specific to rstacks and which we could only find by having the ability to create rstacks: when the mapped stack ends at the faulting address, we have not actually mapped the faulting address. we need to include or cover the faulting address. Note that at this time mmap(2) has not been extended to allow the creation of rstacks by processes. If such a need arises, this can be done. Tested on: alpha, i386, ia64, sparc64
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 5b0d44f..4dfb9a1 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -835,8 +835,6 @@ exec_new_vmspace(imgp, sv)
GIANT_REQUIRED;
- stack_addr = sv->sv_usrstack - maxssiz;
-
imgp->vmspace_destroyed = 1;
EVENTHANDLER_INVOKE(process_exec, p);
@@ -871,24 +869,20 @@ exec_new_vmspace(imgp, sv)
}
/* Allocate a new stack */
+ stack_addr = sv->sv_usrstack - maxssiz;
error = vm_map_stack(map, stack_addr, (vm_size_t)maxssiz,
- sv->sv_stackprot, VM_PROT_ALL, 0);
+ sv->sv_stackprot, VM_PROT_ALL, MAP_STACK_GROWS_DOWN);
if (error)
return (error);
#ifdef __ia64__
- {
- /*
- * Allocate backing store. We really need something
- * similar to vm_map_stack which can allow the backing
- * store to grow upwards. This will do for now.
- */
- vm_offset_t bsaddr;
- bsaddr = p->p_sysent->sv_usrstack - 2 * maxssiz;
- error = vm_map_find(map, 0, 0, &bsaddr,
- regstkpages * PAGE_SIZE, 0, VM_PROT_ALL, VM_PROT_ALL, 0);
- FIRST_THREAD_IN_PROC(p)->td_md.md_bspstore = bsaddr;
- }
+ /* Allocate a new register stack */
+ stack_addr = sv->sv_usrstack - 2 * maxssiz;
+ error = vm_map_stack(map, stack_addr, (vm_size_t)maxssiz,
+ sv->sv_stackprot, VM_PROT_ALL, MAP_STACK_GROWS_UP);
+ if (error)
+ return (error);
+ FIRST_THREAD_IN_PROC(p)->td_md.md_bspstore = stack_addr;
#endif
/* vm_ssize and vm_maxsaddr are somewhat antiquated concepts in the
OpenPOWER on IntegriCloud