From 459f5c1e28a5dd43910204640a48e6ed4298d22b Mon Sep 17 00:00:00 2001 From: Simon Schubert Date: Mon, 1 Dec 2008 13:12:24 +0100 Subject: [PATCH] Add support for MAP_TRYFIXED MAP_TRYFIXED signals to the kernel that the process is well aware that the hint might fall into the heap area, but that it would still like to map the area. I think this is necessary for wine. --- sys/sys/mman.h | 1 + sys/vm/vm_mmap.c | 25 +++++++++++++------------ 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/sys/mman.h b/sys/sys/mman.h index 805d5a26df..8ce6a0d038 100644 --- a/sys/sys/mman.h +++ b/sys/sys/mman.h @@ -82,6 +82,7 @@ #define MAP_HASSEMAPHORE 0x0200 /* region may contain semaphores */ #define MAP_STACK 0x0400 /* region grows down, like a stack */ #define MAP_NOSYNC 0x0800 /* page to but do not sync underlying file */ +#define MAP_TRYFIXED 0x10000 /* attempt hint address, even within heap */ #ifdef _P1003_1B_VISIBLE /* diff --git a/sys/vm/vm_mmap.c b/sys/vm/vm_mmap.c index 4d0cd00ca7..758d844fe0 100644 --- a/sys/vm/vm_mmap.c +++ b/sys/vm/vm_mmap.c @@ -229,19 +229,20 @@ kern_mmap(struct vmspace *vms, caddr_t uaddr, size_t ulen, return (EINVAL); if (addr + size < addr) return (EINVAL); + } else if ((flags & MAP_TRYFIXED) == 0) { + /* + * XXX for non-fixed mappings where no hint is provided or + * the hint would fall in the potential heap space, + * place it after the end of the largest possible heap. + * + * There should really be a pmap call to determine a reasonable + * location. + */ + if (addr == 0 || + (addr >= round_page((vm_offset_t)vms->vm_taddr) && + addr < round_page((vm_offset_t)vms->vm_daddr + maxdsiz))) + addr = round_page((vm_offset_t)vms->vm_daddr + maxdsiz); } - /* - * XXX for non-fixed mappings where no hint is provided or - * the hint would fall in the potential heap space, - * place it after the end of the largest possible heap. - * - * There should really be a pmap call to determine a reasonable - * location. - */ - else if (addr == 0 || - (addr >= round_page((vm_offset_t)vms->vm_taddr) && - addr < round_page((vm_offset_t)vms->vm_daddr + maxdsiz))) - addr = round_page((vm_offset_t)vms->vm_daddr + maxdsiz); if (flags & MAP_ANON) { /* -- 2.41.0