diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2003-04-17 03:50:55 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2003-04-17 03:50:55 +0000 |
commit | e2138a2a4d692e07b68120def684697144681f28 (patch) | |
tree | b7d155f2fbfc007d1bab3ed20819cec9049d2e96 /sys/uvm | |
parent | fdc66d4b31102193dfc9dbcd64c32a4b19a901bb (diff) |
changes to support mquery with 1Gsep on i386. avoid heap on mappings.
Diffstat (limited to 'sys/uvm')
-rw-r--r-- | sys/uvm/uvm_map.c | 11 | ||||
-rw-r--r-- | sys/uvm/uvm_mmap.c | 15 |
2 files changed, 24 insertions, 2 deletions
diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 30af50d1508..9dc0d92fa4f 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_map.c,v 1.57 2003/04/14 04:53:51 art Exp $ */ +/* $OpenBSD: uvm_map.c,v 1.58 2003/04/17 03:50:54 drahn Exp $ */ /* $NetBSD: uvm_map.c,v 1.86 2000/11/27 08:40:03 chs Exp $ */ /* @@ -1078,6 +1078,15 @@ uvm_map_spacefits(vm_map_t map, vaddr_t *phint, vsize_t length, vaddr_t uvm_map_hint(struct proc *p, vm_prot_t prot) { +#ifdef __i386__ + /* + * If executable skip first two pages, otherwise start + * after data + heap region. + */ + if ((prot & VM_PROT_EXECUTE) && + ((vaddr_t)p->p_vmspace->vm_daddr >= 0x40000000)) + return (round_page(PAGE_SIZE*2)); +#endif return (round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ)); } diff --git a/sys/uvm/uvm_mmap.c b/sys/uvm/uvm_mmap.c index 0a68cc18275..680f8d5ff87 100644 --- a/sys/uvm/uvm_mmap.c +++ b/sys/uvm/uvm_mmap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uvm_mmap.c,v 1.40 2003/04/14 04:53:51 art Exp $ */ +/* $OpenBSD: uvm_mmap.c,v 1.41 2003/04/17 03:50:54 drahn Exp $ */ /* $NetBSD: uvm_mmap.c,v 1.49 2001/02/18 21:19:08 chs Exp $ */ /* @@ -166,10 +166,23 @@ sys_mquery(struct proc *p, void *v, register_t *retval) if (vaddr == 0) vaddr = uvm_map_hint(p, prot); + /* prevent a user requested address from falling in heap space */ + if ((vaddr + SCARG(uap, size) > (vaddr_t)p->p_vmspace->vm_daddr) && + (vaddr < (vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ)) + vaddr = round_page((vaddr_t)p->p_vmspace->vm_daddr + MAXDSIZ); + if (uvm_map_findspace(&p->p_vmspace->vm_map, vaddr, SCARG(uap, size), &vaddr, uobj, uoff, 0, flags) == NULL) { error = ENOMEM; } else { + /* + * XXX? + * is it possible for uvm_map_findspace() to return + * an address in vm_addr - vm_addr+MAXDSIZ ? + * if all of the memory below 1G (i386) is used, + * this could occur. In this case, could this loop + * changing the hint to above daddr in that case? + */ error = copyout(&vaddr, SCARG(uap, addr), sizeof(void *)); } |