Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/kern_exec.c
Show First 20 Lines • Show All 1,054 Lines • ▼ Show 20 Lines | exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) | ||||
u_long ssiz; | u_long ssiz; | ||||
imgp->vmspace_destroyed = 1; | imgp->vmspace_destroyed = 1; | ||||
imgp->sysent = sv; | imgp->sysent = sv; | ||||
sigfastblock_clear(td); | sigfastblock_clear(td); | ||||
umtx_exec(p); | umtx_exec(p); | ||||
itimers_exec(p); | itimers_exec(p); | ||||
if (sv->sv_onexec != NULL) | |||||
sv->sv_onexec(p, imgp); | |||||
EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp); | EVENTHANDLER_DIRECT_INVOKE(process_exec, p, imgp); | ||||
/* | /* | ||||
* Blow away entire process VM, if address space not shared, | * Blow away entire process VM, if address space not shared, | ||||
* otherwise, create a new VM space so that other threads are | * otherwise, create a new VM space so that other threads are | ||||
* not disrupted | * not disrupted | ||||
*/ | */ | ||||
Show All 37 Lines | error = vm_map_fixed(map, obj, 0, | ||||
MAP_INHERIT_SHARE | MAP_ACC_NO_CHARGE); | MAP_INHERIT_SHARE | MAP_ACC_NO_CHARGE); | ||||
if (error != KERN_SUCCESS) { | if (error != KERN_SUCCESS) { | ||||
vm_object_deallocate(obj); | vm_object_deallocate(obj); | ||||
return (vm_mmap_to_errno(error)); | return (vm_mmap_to_errno(error)); | ||||
} | } | ||||
} | } | ||||
/* Allocate a new stack */ | /* Allocate a new stack */ | ||||
if (imgp->stack_sz != 0) { | if (imgp->stack_sz != 0) { | ||||
kib: This is weird place to put the call. The vmspace is indeed constructed, but not everything yet… | |||||
Not Done Inline Actionswell, I can put it right after the stack creation or change clarification, for linux_on_exec() it doesn't matter dchagin: well, I can put it right after the stack creation or change clarification, for linux_on_exec()… | |||||
Not Done Inline ActionsThen move it to the very end of the function, right before return. kib: Then move it to the very end of the function, right before return. | |||||
ssiz = trunc_page(imgp->stack_sz); | ssiz = trunc_page(imgp->stack_sz); | ||||
PROC_LOCK(p); | PROC_LOCK(p); | ||||
lim_rlimit_proc(p, RLIMIT_STACK, &rlim_stack); | lim_rlimit_proc(p, RLIMIT_STACK, &rlim_stack); | ||||
PROC_UNLOCK(p); | PROC_UNLOCK(p); | ||||
if (ssiz > rlim_stack.rlim_max) | if (ssiz > rlim_stack.rlim_max) | ||||
ssiz = rlim_stack.rlim_max; | ssiz = rlim_stack.rlim_max; | ||||
if (ssiz > rlim_stack.rlim_cur) { | if (ssiz > rlim_stack.rlim_cur) { | ||||
rlim_stack.rlim_cur = ssiz; | rlim_stack.rlim_cur = ssiz; | ||||
Show All 13 Lines | exec_new_vmspace(struct image_params *imgp, struct sysentvec *sv) | ||||
error = vm_map_stack(map, stack_addr, (vm_size_t)ssiz, stack_prot, | error = vm_map_stack(map, stack_addr, (vm_size_t)ssiz, stack_prot, | ||||
VM_PROT_ALL, MAP_STACK_GROWS_DOWN); | VM_PROT_ALL, MAP_STACK_GROWS_DOWN); | ||||
if (error != KERN_SUCCESS) { | if (error != KERN_SUCCESS) { | ||||
uprintf("exec_new_vmspace: mapping stack size %#jx prot %#x " | uprintf("exec_new_vmspace: mapping stack size %#jx prot %#x " | ||||
"failed mach error %d errno %d\n", (uintmax_t)ssiz, | "failed mach error %d errno %d\n", (uintmax_t)ssiz, | ||||
stack_prot, error, vm_mmap_to_errno(error)); | stack_prot, error, vm_mmap_to_errno(error)); | ||||
return (vm_mmap_to_errno(error)); | return (vm_mmap_to_errno(error)); | ||||
} | } | ||||
if (sv->sv_onexec != NULL) | |||||
sv->sv_onexec(p, imgp); | |||||
/* | /* | ||||
* vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they | * vm_ssize and vm_maxsaddr are somewhat antiquated concepts, but they | ||||
* are still used to enforce the stack rlimit on the process stack. | * are still used to enforce the stack rlimit on the process stack. | ||||
*/ | */ | ||||
vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT; | vmspace->vm_ssize = sgrowsiz >> PAGE_SHIFT; | ||||
vmspace->vm_maxsaddr = (char *)stack_addr; | vmspace->vm_maxsaddr = (char *)stack_addr; | ||||
return (0); | return (0); | ||||
kibUnsubmitted Not Done Inline ActionsMove the call right before this return. kib: Move the call right before this return. | |||||
} | } | ||||
/* | /* | ||||
* Copy out argument and environment strings from the old process address | * Copy out argument and environment strings from the old process address | ||||
* space into the temporary string buffer. | * space into the temporary string buffer. | ||||
*/ | */ | ||||
int | int | ||||
exec_copyin_args(struct image_args *args, const char *fname, | exec_copyin_args(struct image_args *args, const char *fname, | ||||
▲ Show 20 Lines • Show All 859 Lines • Show Last 20 Lines |
This is weird place to put the call. The vmspace is indeed constructed, but not everything yet mapped into it. It is not quite logical to have e.g. shared page mapped, but stack not, when claiming that you put the callback after the vmspace is constructed.