diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 46c24770c004..e0b27c060d02 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -528,16 +528,10 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, imgp->userspace_envv = NULL; imgp->attr = attr; imgp->firstpage = NULL; - imgp->image_header = (char *)kmem_alloc_wait(exec_map, PAGE_SIZE); + imgp->image_header = NULL; imgp->object = NULL; imgp->execlabel = NULL; - if (imgp->image_header == NULL) { - nd->ni_vp = NULL; - error = ENOMEM; - goto fail; - } - /* XXXKSE */ NDINIT(nd, LOOKUP, LOCKLEAF|FOLLOW, UIO_SYSSPACE, file, curthread); @@ -626,9 +620,6 @@ __elfN(load_file)(struct proc *p, const char *file, u_long *addr, fail: if (imgp->firstpage) exec_unmap_first_page(imgp); - if (imgp->image_header) - kmem_free_wakeup(exec_map, (vm_offset_t)imgp->image_header, - PAGE_SIZE); if (imgp->object) vm_object_deallocate(imgp->object); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 757aa4ee620c..dac4475112d4 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -51,6 +51,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -303,8 +304,7 @@ kern_execve(td, fname, argv, envv, mac_p) * Allocate temporary demand zeroed space for argument and * environment strings */ - imgp->stringbase = (char *)kmem_alloc_wait(exec_map, ARG_MAX + - PAGE_SIZE); + imgp->stringbase = (char *)kmem_alloc_wait(exec_map, ARG_MAX); if (imgp->stringbase == NULL) { error = ENOMEM; mtx_lock(&Giant); @@ -312,7 +312,7 @@ kern_execve(td, fname, argv, envv, mac_p) } imgp->stringp = imgp->stringbase; imgp->stringspace = ARG_MAX; - imgp->image_header = imgp->stringbase + ARG_MAX; + imgp->image_header = NULL; /* * Translate the file name. namei() returns a vnode pointer @@ -328,7 +328,7 @@ interpret: error = namei(ndp); if (error) { kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX + PAGE_SIZE); + ARG_MAX); goto exec_fail; } @@ -699,7 +699,7 @@ exec_fail_dealloc: if (imgp->stringbase != NULL) kmem_free_wakeup(exec_map, (vm_offset_t)imgp->stringbase, - ARG_MAX + PAGE_SIZE); + ARG_MAX); if (imgp->object != NULL) vm_object_deallocate(imgp->object); @@ -800,8 +800,8 @@ exec_map_first_page(imgp) vm_page_unlock_queues(); VM_OBJECT_UNLOCK(object); - pmap_qenter((vm_offset_t)imgp->image_header, ma, 1); - imgp->firstpage = ma[0]; + imgp->firstpage = sf_buf_alloc(ma[0], 0); + imgp->image_header = (char *)sf_buf_kva(imgp->firstpage); return (0); } @@ -810,13 +810,15 @@ void exec_unmap_first_page(imgp) struct image_params *imgp; { + vm_page_t m; if (imgp->firstpage != NULL) { - pmap_qremove((vm_offset_t)imgp->image_header, 1); - vm_page_lock_queues(); - vm_page_unhold(imgp->firstpage); - vm_page_unlock_queues(); + m = sf_buf_page(imgp->firstpage); + sf_buf_free(imgp->firstpage); imgp->firstpage = NULL; + vm_page_lock_queues(); + vm_page_unhold(m); + vm_page_unlock_queues(); } } diff --git a/sys/sys/imgact.h b/sys/sys/imgact.h index 417e934ed259..80bc6d8da644 100644 --- a/sys/sys/imgact.h +++ b/sys/sys/imgact.h @@ -35,6 +35,7 @@ #define MAXSHELLCMDLEN 128 struct label; +struct sf_buf; struct sysentvec; struct thread; struct vm_object; @@ -59,7 +60,7 @@ struct image_params { char interpreted; /* flag - this executable is interpreted */ char interpreter_name[MAXSHELLCMDLEN]; /* name of the interpreter */ void *auxargs; /* ELF Auxinfo structure pointer */ - struct vm_page *firstpage; /* first page that we mapped */ + struct sf_buf *firstpage; /* first page that we mapped */ char *fname; /* pointer to filename of executable (user space) */ unsigned long ps_strings; /* PS_STRINGS for BSD/OS binaries */ size_t auxarg_size;