mirror of
https://git.hardenedbsd.org/hardenedbsd/HardenedBSD.git
synced 2025-01-01 00:18:15 +01:00
Use of vm_allocate() and vm_deallocate() has been deprecated.
This commit is contained in:
parent
7335113fc2
commit
68940ac1a0
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
|
||||
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
|
||||
* $Id: vm_machdep.c,v 1.30 1995/01/09 16:04:40 davidg Exp $
|
||||
* $Id: vm_machdep.c,v 1.31 1995/01/21 15:34:03 bde Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -861,8 +861,8 @@ grow(p, sp)
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PAGE_SHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, (vm_offset_t *)&v,
|
||||
grow_amount, FALSE) != KERN_SUCCESS) {
|
||||
if ((grow_amount == 0) || (vm_map_find(&vm->vm_map, NULL, 0, (vm_offset_t *)&v,
|
||||
grow_amount, FALSE) != KERN_SUCCESS)) {
|
||||
return (0);
|
||||
}
|
||||
vm->vm_ssize += grow_amount >> PAGE_SHIFT;
|
||||
|
@ -38,7 +38,7 @@
|
||||
*
|
||||
* from: @(#)vm_machdep.c 7.3 (Berkeley) 5/13/91
|
||||
* Utah $Hdr: vm_machdep.c 1.16.1.1 89/06/23$
|
||||
* $Id: vm_machdep.c,v 1.30 1995/01/09 16:04:40 davidg Exp $
|
||||
* $Id: vm_machdep.c,v 1.31 1995/01/21 15:34:03 bde Exp $
|
||||
*/
|
||||
|
||||
#include "npx.h"
|
||||
@ -861,8 +861,8 @@ grow(p, sp)
|
||||
v = vm->vm_maxsaddr;
|
||||
grow_amount = MAXSSIZ - (vm->vm_ssize << PAGE_SHIFT);
|
||||
}
|
||||
if (vm_allocate(&vm->vm_map, (vm_offset_t *)&v,
|
||||
grow_amount, FALSE) != KERN_SUCCESS) {
|
||||
if ((grow_amount == 0) || (vm_map_find(&vm->vm_map, NULL, 0, (vm_offset_t *)&v,
|
||||
grow_amount, FALSE) != KERN_SUCCESS)) {
|
||||
return (0);
|
||||
}
|
||||
vm->vm_ssize += grow_amount >> PAGE_SHIFT;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: imgact_aout.c,v 1.9 1994/09/25 19:33:31 phk Exp $
|
||||
* $Id: imgact_aout.c,v 1.10 1995/02/14 19:22:27 sos Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -170,15 +170,17 @@ exec_aout_imgact(iparams)
|
||||
if (error)
|
||||
return (error);
|
||||
|
||||
/*
|
||||
* Allocate demand-zeroed area for uninitialized data
|
||||
* "bss" = 'block started by symbol' - named after the IBM 7090
|
||||
* instruction of the same name.
|
||||
*/
|
||||
vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
|
||||
error = vm_allocate(&vmspace->vm_map, &vmaddr, bss_size, FALSE);
|
||||
if (error)
|
||||
return (error);
|
||||
if (bss_size != 0) {
|
||||
/*
|
||||
* Allocate demand-zeroed area for uninitialized data
|
||||
* "bss" = 'block started by symbol' - named after the IBM 7090
|
||||
* instruction of the same name.
|
||||
*/
|
||||
vmaddr = virtual_offset + a_out->a_text + a_out->a_data;
|
||||
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr, bss_size, FALSE);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
||||
/* Fill in process VM information */
|
||||
vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT;
|
||||
|
@ -6,7 +6,7 @@
|
||||
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
||||
* ----------------------------------------------------------------------------
|
||||
*
|
||||
* $Id: imgact_gzip.c,v 1.10 1994/10/22 11:55:16 phk Exp $
|
||||
* $Id: imgact_gzip.c,v 1.11 1995/02/13 07:40:33 phk Exp $
|
||||
*
|
||||
* This module handles execution of a.out files which have been run through
|
||||
* "gzip". This saves diskspace, but wastes cpu-cycles and VM.
|
||||
@ -109,8 +109,8 @@ exec_gzip_imgact(iparams)
|
||||
|
||||
if (igz.inbuf) {
|
||||
error2 =
|
||||
vm_deallocate(kernel_map, (vm_offset_t) igz.inbuf,
|
||||
PAGE_SIZE);
|
||||
vm_map_remove(kernel_map, (vm_offset_t) igz.inbuf,
|
||||
(vm_offset_t) igz.inbuf + PAGE_SIZE);
|
||||
}
|
||||
if (igz.error || error || error2) {
|
||||
printf("Output=%lu ", igz.output);
|
||||
@ -243,16 +243,18 @@ do_aout_hdr(struct imgact_gzip * gz)
|
||||
gz->where = __LINE__;
|
||||
return (error);
|
||||
}
|
||||
/*
|
||||
* Allocate demand-zeroed area for uninitialized data "bss" = 'block
|
||||
* started by symbol' - named after the IBM 7090 instruction of the
|
||||
* same name.
|
||||
*/
|
||||
vmaddr = gz->virtual_offset + gz->a_out.a_text + gz->a_out.a_data;
|
||||
error = vm_allocate(&vmspace->vm_map, &vmaddr, gz->bss_size, FALSE);
|
||||
if (error) {
|
||||
gz->where = __LINE__;
|
||||
return (error);
|
||||
if (gz->bss_size != 0) {
|
||||
/*
|
||||
* Allocate demand-zeroed area for uninitialized data "bss" = 'block
|
||||
* started by symbol' - named after the IBM 7090 instruction of the
|
||||
* same name.
|
||||
*/
|
||||
vmaddr = gz->virtual_offset + gz->a_out.a_text + gz->a_out.a_data;
|
||||
error = vm_map_find(&vmspace->vm_map, NULL, 0, &vmaddr, gz->bss_size, FALSE);
|
||||
if (error) {
|
||||
gz->where = __LINE__;
|
||||
return (error);
|
||||
}
|
||||
}
|
||||
/* Fill in process VM information */
|
||||
vmspace->vm_tsize = gz->a_out.a_text >> PAGE_SHIFT;
|
||||
@ -283,8 +285,8 @@ NextByte(void *vp)
|
||||
return igz->inbuf[(igz->idx++) - igz->offset];
|
||||
}
|
||||
if (igz->inbuf) {
|
||||
error = vm_deallocate(kernel_map,
|
||||
(vm_offset_t) igz->inbuf, PAGE_SIZE);
|
||||
error = vm_map_remove(kernel_map, (vm_offset_t) igz->inbuf,
|
||||
(vm_offset_t) igz->inbuf + PAGE_SIZE);
|
||||
if (error) {
|
||||
igz->where = __LINE__;
|
||||
igz->error = error;
|
||||
|
@ -36,7 +36,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)init_main.c 8.9 (Berkeley) 1/21/94
|
||||
* $Id: init_main.c,v 1.16 1994/11/06 05:01:58 davidg Exp $
|
||||
* $Id: init_main.c,v 1.17 1994/11/25 07:58:16 davidg Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -392,7 +392,7 @@ start_init(p, framep)
|
||||
* Need just enough stack to hold the faked-up "execve()" arguments.
|
||||
*/
|
||||
addr = trunc_page(VM_MAXUSER_ADDRESS - PAGE_SIZE);
|
||||
if (vm_allocate(&p->p_vmspace->vm_map, &addr, PAGE_SIZE, FALSE) != 0)
|
||||
if (vm_map_find(&p->p_vmspace->vm_map, NULL, 0, &addr, PAGE_SIZE, FALSE) != 0)
|
||||
panic("init: couldn't allocate argument space");
|
||||
p->p_vmspace->vm_maxsaddr = (caddr_t)addr;
|
||||
p->p_vmspace->vm_ssize = 1;
|
||||
|
@ -28,7 +28,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: kern_exec.c,v 1.11 1995/01/09 16:04:49 davidg Exp $
|
||||
* $Id: kern_exec.c,v 1.12 1995/02/14 19:22:28 sos Exp $
|
||||
*/
|
||||
|
||||
#include <sys/param.h>
|
||||
@ -98,8 +98,9 @@ execve(p, uap, retval)
|
||||
* Allocate temporary demand zeroed space for argument and
|
||||
* environment strings
|
||||
*/
|
||||
error = vm_allocate(exec_map, (vm_offset_t *)&iparams->stringbase,
|
||||
ARG_MAX, TRUE);
|
||||
iparams->stringbase = (char *)vm_map_min(exec_map);
|
||||
error = vm_map_find(exec_map, NULL, 0, (vm_offset_t *)&iparams->stringbase,
|
||||
ARG_MAX, TRUE);
|
||||
if (error) {
|
||||
log(LOG_WARNING, "execve: failed to allocate string space\n");
|
||||
return (error);
|
||||
@ -128,8 +129,8 @@ interpret:
|
||||
|
||||
error = namei(ndp);
|
||||
if (error) {
|
||||
vm_deallocate(exec_map, (vm_offset_t)iparams->stringbase,
|
||||
ARG_MAX);
|
||||
vm_map_remove(exec_map, (vm_offset_t)iparams->stringbase,
|
||||
(vm_offset_t)iparams->stringbase + ARG_MAX);
|
||||
goto exec_fail;
|
||||
}
|
||||
|
||||
@ -187,8 +188,8 @@ interpret:
|
||||
/* free old vnode and name buffer */
|
||||
vput(ndp->ni_vp);
|
||||
FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
if (vm_deallocate(kernel_map,
|
||||
(vm_offset_t)image_header, PAGE_SIZE))
|
||||
if (vm_map_remove(kernel_map, (vm_offset_t)image_header,
|
||||
(vm_offset_t)image_header + PAGE_SIZE))
|
||||
panic("execve: header dealloc failed (1)");
|
||||
|
||||
/* set new name to that of the interpreter */
|
||||
@ -302,9 +303,11 @@ interpret:
|
||||
/*
|
||||
* free various allocated resources
|
||||
*/
|
||||
if (vm_deallocate(exec_map, (vm_offset_t)iparams->stringbase, ARG_MAX))
|
||||
if (vm_map_remove(exec_map, (vm_offset_t)iparams->stringbase,
|
||||
(vm_offset_t)iparams->stringbase + ARG_MAX))
|
||||
panic("execve: string buffer dealloc failed (1)");
|
||||
if (vm_deallocate(kernel_map, (vm_offset_t)image_header, PAGE_SIZE))
|
||||
if (vm_map_remove(kernel_map, (vm_offset_t)image_header,
|
||||
(vm_offset_t)image_header + PAGE_SIZE))
|
||||
panic("execve: header dealloc failed (2)");
|
||||
vput(ndp->ni_vp);
|
||||
FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
@ -313,12 +316,12 @@ interpret:
|
||||
|
||||
exec_fail_dealloc:
|
||||
if (iparams->stringbase && iparams->stringbase != (char *)-1)
|
||||
if (vm_deallocate(exec_map, (vm_offset_t)iparams->stringbase,
|
||||
ARG_MAX))
|
||||
if (vm_map_remove(exec_map, (vm_offset_t)iparams->stringbase,
|
||||
(vm_offset_t)iparams->stringbase + ARG_MAX))
|
||||
panic("execve: string buffer dealloc failed (2)");
|
||||
if (iparams->image_header && iparams->image_header != (char *)-1)
|
||||
if (vm_deallocate(kernel_map,
|
||||
(vm_offset_t)iparams->image_header, PAGE_SIZE))
|
||||
if (vm_map_remove(kernel_map, (vm_offset_t)image_header,
|
||||
(vm_offset_t)image_header + PAGE_SIZE))
|
||||
panic("execve: header dealloc failed (3)");
|
||||
vput(ndp->ni_vp);
|
||||
FREE(ndp->ni_cnd.cn_pnbuf, M_NAMEI);
|
||||
@ -326,9 +329,6 @@ exec_fail_dealloc:
|
||||
exec_fail:
|
||||
if (iparams->vmspace_destroyed) {
|
||||
/* sorry, no more process anymore. exit gracefully */
|
||||
#if 0 /* XXX */
|
||||
vm_deallocate(&vs->vm_map, USRSTACK - MAXSSIZ, MAXSSIZ);
|
||||
#endif
|
||||
exit1(p, W_EXITCODE(0, SIGABRT));
|
||||
/* NOT REACHED */
|
||||
return(0);
|
||||
@ -357,11 +357,11 @@ exec_new_vmspace(iparams)
|
||||
if (vmspace->vm_shm)
|
||||
shmexit(iparams->proc);
|
||||
#endif
|
||||
vm_deallocate(&vmspace->vm_map, 0, USRSTACK);
|
||||
vm_map_remove(&vmspace->vm_map, 0, USRSTACK);
|
||||
|
||||
/* Allocate a new stack */
|
||||
error = vm_allocate(&vmspace->vm_map, (vm_offset_t *)&stack_addr,
|
||||
SGROWSIZ, FALSE);
|
||||
error = vm_map_find(&vmspace->vm_map, NULL, 0, (vm_offset_t *)&stack_addr,
|
||||
SGROWSIZ, FALSE);
|
||||
if (error)
|
||||
return(error);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $Id: sysv_shm.c,v 1.2 1994/09/16 17:43:22 dfr Exp $ */
|
||||
/* $Id: sysv_shm.c,v 1.3 1994/10/02 17:35:28 phk Exp $ */
|
||||
/* $NetBSD: sysv_shm.c,v 1.23 1994/07/04 23:25:12 glass Exp $ */
|
||||
|
||||
/*
|
||||
@ -127,7 +127,7 @@ shm_deallocate_segment(shmseg)
|
||||
|
||||
shm_handle = shmseg->shm_internal;
|
||||
size = (shmseg->shm_segsz + CLOFSET) & ~CLOFSET;
|
||||
vm_deallocate(sysvshm_map, shm_handle->kva, size);
|
||||
(void) vm_map_remove(sysvshm_map, shm_handle->kva, shm_handle->kva + size);
|
||||
free((caddr_t)shm_handle, M_SHM);
|
||||
shmseg->shm_internal = NULL;
|
||||
shm_committed -= btoc(size);
|
||||
@ -147,7 +147,7 @@ shm_delete_mapping(p, shmmap_s)
|
||||
segnum = IPCID_TO_IX(shmmap_s->shmid);
|
||||
shmseg = &shmsegs[segnum];
|
||||
size = (shmseg->shm_segsz + CLOFSET) & ~CLOFSET;
|
||||
result = vm_deallocate(&p->p_vmspace->vm_map, shmmap_s->va, size);
|
||||
result = vm_map_remove(&p->p_vmspace->vm_map, shmmap_s->va, shmmap_s->va + size);
|
||||
if (result != KERN_SUCCESS)
|
||||
return EINVAL;
|
||||
shmmap_s->shmid = -1;
|
||||
|
Loading…
Reference in New Issue
Block a user