From 5ada17916af15077da6ec443ee094e69dc6ed704 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 25 Apr 2024 14:26:33 -0400 Subject: kernel: vm_map: Refactor mmap() Signed-off-by: Ian Moffett --- sys/vm/vm_map.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'sys') diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index f022e7a..4f7aadc 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -333,7 +333,6 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) { const int PROT_MASK = PROT_WRITE | PROT_EXEC; const size_t GRANULE = vm_get_page_size(); - uintptr_t map_end, map_start; struct proc *td = this_td(); @@ -355,9 +354,8 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) if (mapping == NULL) return MAP_FAILED; + /* Setup prot and mapping start */ mapping->prot = prot | PROT_USER; - - /* Setup mapping start */ map_start = __ALIGN_DOWN(va, GRANULE); /* @@ -386,7 +384,9 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) mapping->vmobj = vmobj; mapping->physmem_base = 0; - } else if (physmem != 0) { + } + + if (addr == NULL && physmem != 0) { map_start = physmem + mapoff; vm_map((void *)map_start, physmem, prot, len); addr = (void *)physmem; -- cgit v1.2.3