Module Name: src Committed By: reinoud Date: Mon Sep 19 12:52:32 UTC 2011
Modified Files: src/sys/arch/usermode/usermode: pmap.c Log Message: Small cleanups on memory initialisation by using munmap() instead of mapping unaccessible anon memory that we're never going to use anyway! To generate a diff of this commit: cvs rdiff -u -r1.72 -r1.73 src/sys/arch/usermode/usermode/pmap.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/usermode/pmap.c diff -u src/sys/arch/usermode/usermode/pmap.c:1.72 src/sys/arch/usermode/usermode/pmap.c:1.73 --- src/sys/arch/usermode/usermode/pmap.c:1.72 Fri Sep 16 16:27:39 2011 +++ src/sys/arch/usermode/usermode/pmap.c Mon Sep 19 12:52:32 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: pmap.c,v 1.72 2011/09/16 16:27:39 reinoud Exp $ */ +/* $NetBSD: pmap.c,v 1.73 2011/09/19 12:52:32 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk <rein...@netbsd.org> @@ -27,7 +27,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.72 2011/09/16 16:27:39 reinoud Exp $"); +__KERNEL_RCSID(0, "$NetBSD: pmap.c,v 1.73 2011/09/19 12:52:32 reinoud Exp $"); #include "opt_memsize.h" #include "opt_kmempages.h" @@ -127,6 +127,7 @@ vaddr_t va; uintptr_t pg; void *addr; + int err; extern void _start(void); /* start of kernel */ extern int etext; /* end of the kernel */ @@ -157,7 +158,7 @@ /* calculate memory lengths */ barrier_len = 2 * 1024 * 1024; - user_len = kmem_k_start - barrier_len; + user_len = kmem_k_start - vm_min_addr - barrier_len; /* devide memory */ mem_uvm = (void *) vm_min_addr; @@ -188,27 +189,17 @@ aprint_verbose("\n\n"); -#if 1 /* protect user memory UVM area (---) */ - addr = thunk_mmap((void*) mem_uvm, - kmem_user_end - vm_min_addr, - THUNK_PROT_NONE, - THUNK_MAP_ANON | THUNK_MAP_FIXED | THUNK_MAP_PRIVATE, - -1, 0); - if (addr != (void *) mem_uvm) + err = thunk_munmap(mem_uvm, kmem_user_end - vm_min_addr); + if (err) panic("pmap_bootstrap: userland uvm space protection " - "failed (%p)\n", (void *)addr); + "failed (%d)\n", thunk_geterrno()); - /* protect user memory UVM area (---) */ - addr = thunk_mmap((void*) kmem_ext_start, - KVMSIZE, - THUNK_PROT_NONE, - THUNK_MAP_ANON | THUNK_MAP_FIXED | THUNK_MAP_PRIVATE, - -1, 0); - if (addr != (void *) kmem_ext_start) + /* protect kvm UVM area (---) */ + err = thunk_munmap((void *) kmem_ext_start, KVMSIZE); + if (err) panic("pmap_bootstrap: kvm uvm space protection " - "failed (%p)\n", (void *)addr); -#endif + "failed (%d)\n", thunk_geterrno()); dprintf_debug("Creating memory mapped backend\n"); @@ -1056,7 +1047,7 @@ panic("%s: couldn't get src mapping", __func__); dblob = thunk_mmap(NULL, PAGE_SIZE, - THUNK_PROT_WRITE, + THUNK_PROT_READ | THUNK_PROT_WRITE, THUNK_MAP_FILE | THUNK_MAP_SHARED, mem_fh, dst_pa); if (!dblob)