From 145bbb28313dd2ecb166946351c098f3118789e4 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Tue, 16 Apr 2024 20:21:16 -0400 Subject: kernel: vm_map: Allocate physmem for MAP_ANONYMOUS Only allocate physical memory during an anonymous map request Signed-off-by: Ian Moffett --- sys/vm/vm_map.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'sys/vm') diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c index 266d696..49d1149 100644 --- a/sys/vm/vm_map.c +++ b/sys/vm/vm_map.c @@ -187,11 +187,6 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) /* Invalid prot */ return MAP_FAILED; - /* Allocate the physical memory */ - physmem = vm_alloc_pageframe(len / GRANULE); - if (physmem == 0) - return MAP_FAILED; - /* * Handle address being NULL. * @@ -204,6 +199,11 @@ mmap(void *addr, size_t len, int prot, int flags, int fildes, off_t off) /* Handle an anonymous map request */ if (__TEST(flags, MAP_ANONYMOUS)) { + /* Allocate the physical memory */ + physmem = vm_alloc_pageframe(len / GRANULE); + if (physmem == 0) + return MAP_FAILED; + /* * XXX: There is no need to worry about alignment yet * as vm_map_create() handles that internally. -- cgit v1.2.3