From e2138a2a4d692e07b68120def684697144681f28 Mon Sep 17 00:00:00 2001 From: Dale Rahn Date: Thu, 17 Apr 2003 03:50:55 +0000 Subject: changes to support mquery with 1Gsep on i386. avoid heap on mappings. --- sys/uvm/uvm_map.c | 11 ++++++++++- sys/uvm/uvm_mmap.c | 15 ++++++++++++++- 2 files changed, 24 insertions(+), 2 deletions(-) (limited to 'sys/uvm') 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 *)); } -- cgit v1.2.3