Module Name: src Committed By: uebayasi Date: Fri Apr 11 17:28:24 UTC 2014
Modified Files: src/sys/kern: kern_exec.c Log Message: execve_runproc: The stack address passed to the newly execve()'ed process, via the 3rd register argument, always points to the stack base address (== minsaddr (min stack address) + ssize (stack size)). Clarify that. To generate a diff of this commit: cvs rdiff -u -r1.383 -r1.384 src/sys/kern/kern_exec.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/kern/kern_exec.c diff -u src/sys/kern/kern_exec.c:1.383 src/sys/kern/kern_exec.c:1.384 --- src/sys/kern/kern_exec.c:1.383 Fri Apr 11 17:06:02 2014 +++ src/sys/kern/kern_exec.c Fri Apr 11 17:28:24 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: kern_exec.c,v 1.383 2014/04/11 17:06:02 uebayasi Exp $ */ +/* $NetBSD: kern_exec.c,v 1.384 2014/04/11 17:28:24 uebayasi Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -59,7 +59,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.383 2014/04/11 17:06:02 uebayasi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_exec.c,v 1.384 2014/04/11 17:28:24 uebayasi Exp $"); #include "opt_exec.h" #include "opt_execfmt.h" @@ -909,7 +909,6 @@ execve_runproc(struct lwp *l, struct exe struct exec_package * const epp = &data->ed_pack; int error = 0; struct proc *p; - char *stack; struct vmspace *vm; /* @@ -1116,6 +1115,9 @@ execve_runproc(struct lwp *l, struct exe } } + { + char *stack; + stack = (char *)STACK_ALLOC(STACK_GROW(vm->vm_minsaddr, STACK_PTHREADSPACE + data->ed_ps_strings_sz + data->ed_szsigcode), epp->ep_ssize - (data->ed_ps_strings_sz + data->ed_szsigcode)); @@ -1158,8 +1160,7 @@ execve_runproc(struct lwp *l, struct exe DPRINTF(("%s: copyargs failed %d\n", __func__, error)); goto exec_abort; } - /* Move the stack back to original point */ - stack = (char *)STACK_GROW(vm->vm_minsaddr, epp->ep_ssize); + } /* fill process ps_strings info */ p->p_psstrp = (vaddr_t)STACK_ALLOC(STACK_GROW(vm->vm_minsaddr, @@ -1324,12 +1325,17 @@ execve_runproc(struct lwp *l, struct exe doexechooks(p); + { + char * const stack = (char *)STACK_GROW( + (void *)epp->ep_minsaddr, epp->ep_ssize); + /* setup new registers and do misc. setup. */ (*epp->ep_esch->es_emul->e_setregs)(l, epp, (vaddr_t)stack); if (epp->ep_esch->es_setregs) (*epp->ep_esch->es_setregs)(l, epp, (vaddr_t)stack); + } /* Provide a consistent LWP private setting */ (void)lwp_setprivate(l, NULL);