Module Name: src Committed By: rmind Date: Sun Apr 25 15:27:38 UTC 2010
Modified Files: src/sys/arch/acorn26/acorn26 [rmind-uvmplock]: machdep.c src/sys/arch/alpha/alpha [rmind-uvmplock]: machdep.c src/sys/arch/amd64/amd64 [rmind-uvmplock]: machdep.c src/sys/arch/hp300/hp300 [rmind-uvmplock]: machdep.c src/sys/arch/hp700/hp700 [rmind-uvmplock]: machdep.c src/sys/arch/hp700/include [rmind-uvmplock]: types.h src/sys/arch/luna68k/luna68k [rmind-uvmplock]: machdep.c src/sys/arch/mips/mips [rmind-uvmplock]: mips_machdep.c src/sys/arch/mvme68k/mvme68k [rmind-uvmplock]: machdep.c src/sys/arch/news68k/news68k [rmind-uvmplock]: machdep.c src/sys/arch/next68k/next68k [rmind-uvmplock]: machdep.c src/sys/arch/powerpc/powerpc [rmind-uvmplock]: powerpc_machdep.c src/sys/arch/sh3/sh3 [rmind-uvmplock]: vm_machdep.c src/sys/arch/sparc/sparc [rmind-uvmplock]: machdep.c src/sys/arch/sparc64/sparc64 [rmind-uvmplock]: machdep.c src/sys/arch/vax/include [rmind-uvmplock]: types.h src/sys/arch/vax/vax [rmind-uvmplock]: machdep.c src/sys/arch/x68k/x68k [rmind-uvmplock]: machdep.c src/sys/dev [rmind-uvmplock]: mm.c mm.h src/sys/uvm [rmind-uvmplock]: uvm_glue.c Log Message: - Invent mm_md_getva() and mm_md_relva() routines, provided by MD and indicated with __HAVE_MM_MD_PREFER_VA. It will be used to deal with cache aliasing issues and thus fix little MIPS, ARM and friends. - Convert dev_mem_readwrite() to use unmanaged mappings. Fix a missed offset addition in a case of direct map. Sprinkle various comments in the memory device driver. - Add missing direct map handling on hp700 and vax. Make checks across m68k ports more consistent, reduce the diffs. Fix kernacc check miss on news68k. Minor off-by-one fix for alpha. Add MEMC_PHYS_BASE for mmap() case check on acorn26. Misc clean-up. To generate a diff of this commit: cvs rdiff -u -r1.33.2.1 -r1.33.2.2 src/sys/arch/acorn26/acorn26/machdep.c cvs rdiff -u -r1.326.2.1 -r1.326.2.2 src/sys/arch/alpha/alpha/machdep.c cvs rdiff -u -r1.143.2.1 -r1.143.2.2 src/sys/arch/amd64/amd64/machdep.c cvs rdiff -u -r1.211.2.1 -r1.211.2.2 src/sys/arch/hp300/hp300/machdep.c cvs rdiff -u -r1.79.2.1 -r1.79.2.2 src/sys/arch/hp700/hp700/machdep.c cvs rdiff -u -r1.10 -r1.10.32.1 src/sys/arch/hp700/include/types.h cvs rdiff -u -r1.74.2.1 -r1.74.2.2 src/sys/arch/luna68k/luna68k/machdep.c cvs rdiff -u -r1.225.4.1 -r1.225.4.2 src/sys/arch/mips/mips/mips_machdep.c cvs rdiff -u -r1.142.2.1 -r1.142.2.2 src/sys/arch/mvme68k/mvme68k/machdep.c cvs rdiff -u -r1.85.2.1 -r1.85.2.2 src/sys/arch/news68k/news68k/machdep.c cvs rdiff -u -r1.98.2.1 -r1.98.2.2 src/sys/arch/next68k/next68k/machdep.c cvs rdiff -u -r1.42.4.1 -r1.42.4.2 \ src/sys/arch/powerpc/powerpc/powerpc_machdep.c cvs rdiff -u -r1.66.4.1 -r1.66.4.2 src/sys/arch/sh3/sh3/vm_machdep.c cvs rdiff -u -r1.302.2.1 -r1.302.2.2 src/sys/arch/sparc/sparc/machdep.c cvs rdiff -u -r1.252.2.1 -r1.252.2.2 src/sys/arch/sparc64/sparc64/machdep.c cvs rdiff -u -r1.40.4.1 -r1.40.4.2 src/sys/arch/vax/include/types.h cvs rdiff -u -r1.179.2.1 -r1.179.2.2 src/sys/arch/vax/vax/machdep.c cvs rdiff -u -r1.165.2.1 -r1.165.2.2 src/sys/arch/x68k/x68k/machdep.c cvs rdiff -u -r1.13.16.1 -r1.13.16.2 src/sys/dev/mm.c cvs rdiff -u -r1.1.2.1 -r1.1.2.2 src/sys/dev/mm.h cvs rdiff -u -r1.144.2.1 -r1.144.2.2 src/sys/uvm/uvm_glue.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/acorn26/acorn26/machdep.c diff -u src/sys/arch/acorn26/acorn26/machdep.c:1.33.2.1 src/sys/arch/acorn26/acorn26/machdep.c:1.33.2.2 --- src/sys/arch/acorn26/acorn26/machdep.c:1.33.2.1 Thu Mar 18 04:36:46 2010 +++ src/sys/arch/acorn26/acorn26/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.33.2.1 2010/03/18 04:36:46 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.33.2.2 2010/04/25 15:27:36 rmind Exp $ */ /*- * Copyright (c) 1998 Ben Harris @@ -32,7 +32,7 @@ #include <sys/param.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.33.2.1 2010/03/18 04:36:46 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.33.2.2 2010/04/25 15:27:36 rmind Exp $"); #include <sys/buf.h> #include <sys/kernel.h> @@ -217,18 +217,14 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot) { - return (atop(pa) >= physmem) ? EFAULT : 0; + return (pa > MEMC_PHYS_BASE + ptoa(physmem)) ? EFAULT : 0; } int mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) { + const vaddr_t v = ptr; - if (ptr >= MEMC_PHYS_BASE && - (char *)ptr < (char *)MEMC_PHYS_BASE + ptoa(physmem)) { - *handled = true; - } else { - *handled = false; - } + *handled = (v >= MEMC_PHYS_BASE && v < MEMC_PHYS_BASE + ptoa(physmem)); return 0; } Index: src/sys/arch/alpha/alpha/machdep.c diff -u src/sys/arch/alpha/alpha/machdep.c:1.326.2.1 src/sys/arch/alpha/alpha/machdep.c:1.326.2.2 --- src/sys/arch/alpha/alpha/machdep.c:1.326.2.1 Thu Mar 18 04:36:46 2010 +++ src/sys/arch/alpha/alpha/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.326.2.1 2010/03/18 04:36:46 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.326.2.2 2010/04/25 15:27:36 rmind Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -68,7 +68,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.326.2.1 2010/03/18 04:36:46 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.326.2.2 2010/04/25 15:27:36 rmind Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -1822,10 +1822,8 @@ continue; if ((prot & mem_clusters[i].size & PAGE_MASK) == prot) return 0; - return EFAULT; } - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + return EFAULT; } bool @@ -1833,7 +1831,7 @@ { vaddr_t va = (vaddr_t)addr; - if (va >= ALPHA_K0SEG_BASE && va < ALPHA_K0SEG_END) { + if (va >= ALPHA_K0SEG_BASE && va <= ALPHA_K0SEG_END) { *paddr = ALPHA_K0SEG_TO_PHYS(va); return true; } Index: src/sys/arch/amd64/amd64/machdep.c diff -u src/sys/arch/amd64/amd64/machdep.c:1.143.2.1 src/sys/arch/amd64/amd64/machdep.c:1.143.2.2 --- src/sys/arch/amd64/amd64/machdep.c:1.143.2.1 Thu Mar 18 04:36:47 2010 +++ src/sys/arch/amd64/amd64/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.143.2.1 2010/03/18 04:36:47 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.143.2.2 2010/04/25 15:27:36 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998, 2000, 2006, 2007, 2008 @@ -107,7 +107,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.143.2.1 2010/03/18 04:36:47 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.143.2.2 2010/04/25 15:27:36 rmind Exp $"); /* #define XENDEBUG_LOW */ @@ -1809,10 +1809,13 @@ *handled = true; if (v < (vaddr_t)&__data_start && (prot & VM_PROT_WRITE)) return EFAULT; + } else if (v >= module_start && v < module_end) { *handled = true; if (!uvm_map_checkprot(module_map, v, v + 1, prot)) return EFAULT; + } else { + *handled = false; } return 0; } Index: src/sys/arch/hp300/hp300/machdep.c diff -u src/sys/arch/hp300/hp300/machdep.c:1.211.2.1 src/sys/arch/hp300/hp300/machdep.c:1.211.2.2 --- src/sys/arch/hp300/hp300/machdep.c:1.211.2.1 Thu Mar 18 04:36:48 2010 +++ src/sys/arch/hp300/hp300/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.211.2.1 2010/03/18 04:36:48 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.211.2.2 2010/04/25 15:27:36 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.2.1 2010/03/18 04:36:48 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.211.2.2 2010/04/25 15:27:36 rmind Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -1294,10 +1294,7 @@ * Do not allow reading intio or dio device space. This could lead * to corruption of device registers. */ - if (ISIIOVA(ptr) || ((uint8_t *)ptr >= extiobase && - (uint8_t *)ptr < extiobase + (EIOMAPSIZE * PAGE_SIZE))) { - *handled = true; - return EFAULT; - } - return 0; + *handled = false; + return (ISIIOVA(ptr) || (ptr >= extiobase && + ptr < (extiobase + (EIOMAPSIZE * PAGE_SIZE)))) ? EFAULT : 0; } Index: src/sys/arch/hp700/hp700/machdep.c diff -u src/sys/arch/hp700/hp700/machdep.c:1.79.2.1 src/sys/arch/hp700/hp700/machdep.c:1.79.2.2 --- src/sys/arch/hp700/hp700/machdep.c:1.79.2.1 Thu Mar 18 04:36:49 2010 +++ src/sys/arch/hp700/hp700/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.79.2.1 2010/03/18 04:36:49 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.79.2.2 2010/04/25 15:27:36 rmind Exp $ */ /*- * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc. @@ -58,7 +58,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.79.2.1 2010/03/18 04:36:49 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.79.2.2 2010/04/25 15:27:36 rmind Exp $"); #include "opt_cputype.h" #include "opt_ddb.h" @@ -1970,9 +1970,25 @@ } #endif /* MODULAR */ +bool +mm_md_direct_mapped_phys(paddr_t paddr, vaddr_t *vaddr) +{ + + *vaddr = ptoa(physmem) - paddr; + return true; +} + int mm_md_physacc(paddr_t pa, vm_prot_t prot) { - return (btoc(pa) > totalphysmem) ? EFAULT : 0; + return (atop(v) > physmem) ? EFAULT : 0; +} + +int +mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) +{ + + *handled = false; + return mm_md_physacc(ptr, prot); } Index: src/sys/arch/hp700/include/types.h diff -u src/sys/arch/hp700/include/types.h:1.10 src/sys/arch/hp700/include/types.h:1.10.32.1 --- src/sys/arch/hp700/include/types.h:1.10 Sun Jan 20 18:09:06 2008 +++ src/sys/arch/hp700/include/types.h Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.10 2008/01/20 18:09:06 joerg Exp $ */ +/* $NetBSD: types.h,v 1.10.32.1 2010/04/25 15:27:36 rmind Exp $ */ #ifndef _HP700_TYPES_H_ #define _HP700_TYPES_H_ @@ -7,4 +7,7 @@ #define __HAVE_DEVICE_REGISTER +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS +#define __HAVE_MM_MD_KERNACC + #endif /* _HP700_TYPES_H_ */ Index: src/sys/arch/luna68k/luna68k/machdep.c diff -u src/sys/arch/luna68k/luna68k/machdep.c:1.74.2.1 src/sys/arch/luna68k/luna68k/machdep.c:1.74.2.2 --- src/sys/arch/luna68k/luna68k/machdep.c:1.74.2.1 Thu Mar 18 04:36:49 2010 +++ src/sys/arch/luna68k/luna68k/machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.74.2.1 2010/03/18 04:36:49 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.74.2.2 2010/04/25 15:27:36 rmind Exp $ */ /*- * Copyright (c) 2000 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.74.2.1 2010/03/18 04:36:49 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.74.2.2 2010/04/25 15:27:36 rmind Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -107,6 +107,8 @@ */ int safepri = PSL_LOWIPL; +extern u_int lowram; + void luna68k_init(void); void identifycpu(void); void dumpsys(void); @@ -864,11 +866,6 @@ int mm_md_physacc(paddr_t pa, vm_prot_t prot) { - extern u_int lowram; - - if (pa >= lowram && pa < 0xfffffffc) - return 0; - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0; } Index: src/sys/arch/mips/mips/mips_machdep.c diff -u src/sys/arch/mips/mips/mips_machdep.c:1.225.4.1 src/sys/arch/mips/mips/mips_machdep.c:1.225.4.2 --- src/sys/arch/mips/mips/mips_machdep.c:1.225.4.1 Thu Mar 18 04:36:50 2010 +++ src/sys/arch/mips/mips/mips_machdep.c Sun Apr 25 15:27:36 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mips_machdep.c,v 1.225.4.1 2010/03/18 04:36:50 rmind Exp $ */ +/* $NetBSD: mips_machdep.c,v 1.225.4.2 2010/04/25 15:27:36 rmind Exp $ */ /* * Copyright 2002 Wasabi Systems, Inc. @@ -112,7 +112,7 @@ #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ -__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.225.4.1 2010/03/18 04:36:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mips_machdep.c,v 1.225.4.2 2010/04/25 15:27:36 rmind Exp $"); #include "opt_cputype.h" #include "opt_compat_netbsd32.h" @@ -2181,20 +2181,11 @@ return curcpu()->ci_idepth != 0; } -#ifdef pmax /* XXX compat_ultrix */ - -const struct cdevsw mem_ultrix_cdevsw = { - nullopen, nullclose, mm_readwrite, mm_readwrite, - mm_ioctl, nostop, notty, nopoll, mm_mmap, nokqfilter, - D_MPSAFE -}; - -#endif - bool mm_md_direct_mapped_phys(paddr_t paddr, vaddr_t *vaddr) { + /* XXX: Broken. */ #ifdef _LP64 *vaddr = MIPS_PHYS_TO_XKPHYS_CACHED(paddr); #else @@ -2214,18 +2205,16 @@ mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) { extern paddr_t avail_end; + const vaddr_t v = ptr; - if (ptr < (void *)MIPS_KSEG0_START) { - *handled = true; + if (v < MIPS_KSEG0_START) { return EFAULT; } - if (ptr < (void *)MIPS_PHYS_TO_KSEG0(avail_end + - mips_round_page(MSGBUFSIZE))) { + if (v < MIPS_PHYS_TO_KSEG0(avail_end + mips_round_page(MSGBUFSIZE))) { *handled = true; return 0; } - if (ptr < (void *)MIPS_KSEG2_START) { - *handled = true; + if (v < MIPS_KSEG2_START) { return EFAULT; } *handled = false; Index: src/sys/arch/mvme68k/mvme68k/machdep.c diff -u src/sys/arch/mvme68k/mvme68k/machdep.c:1.142.2.1 src/sys/arch/mvme68k/mvme68k/machdep.c:1.142.2.2 --- src/sys/arch/mvme68k/mvme68k/machdep.c:1.142.2.1 Thu Mar 18 04:36:50 2010 +++ src/sys/arch/mvme68k/mvme68k/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.142.2.1 2010/03/18 04:36:50 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.142.2.2 2010/04/25 15:27:37 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.142.2.1 2010/03/18 04:36:50 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.142.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_ddb.h" #include "opt_m060sp.h" @@ -1186,7 +1186,5 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (pa >= lowram && pa < 0xfffffffc) - return 0; - return EFAULT; + return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0; } Index: src/sys/arch/news68k/news68k/machdep.c diff -u src/sys/arch/news68k/news68k/machdep.c:1.85.2.1 src/sys/arch/news68k/news68k/machdep.c:1.85.2.2 --- src/sys/arch/news68k/news68k/machdep.c:1.85.2.1 Thu Mar 18 04:36:51 2010 +++ src/sys/arch/news68k/news68k/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.85.2.1 2010/03/18 04:36:51 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.85.2.2 2010/04/25 15:27:37 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.85.2.1 2010/03/18 04:36:51 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.85.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -1086,19 +1086,14 @@ int mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (pa >= lowram && pa < 0xfffffffc) - return 0; - return EFAULT; + + return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0; } int mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) { - if (ISIIOVA(ptr)) { - *handled = true; - return EFAULT; - } *handled = false; - return 0; + return ISIIOVA(ptr) ? EFAULT : 0; } Index: src/sys/arch/next68k/next68k/machdep.c diff -u src/sys/arch/next68k/next68k/machdep.c:1.98.2.1 src/sys/arch/next68k/next68k/machdep.c:1.98.2.2 --- src/sys/arch/next68k/next68k/machdep.c:1.98.2.1 Thu Mar 18 04:36:51 2010 +++ src/sys/arch/next68k/next68k/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.98.2.1 2010/03/18 04:36:51 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.98.2.2 2010/04/25 15:27:37 rmind Exp $ */ /* * Copyright (c) 1998 Darrin B. Jewell @@ -79,7 +79,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98.2.1 2010/03/18 04:36:51 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.98.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -943,7 +943,5 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (pa >= lowram && pa < 0xfffffffc) - return 0; - return EFAULT; + return (pa < lowram || pa >= 0xfffffffc) ? EFAULT : 0; } Index: src/sys/arch/powerpc/powerpc/powerpc_machdep.c diff -u src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.42.4.1 src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.42.4.2 --- src/sys/arch/powerpc/powerpc/powerpc_machdep.c:1.42.4.1 Thu Mar 18 04:36:51 2010 +++ src/sys/arch/powerpc/powerpc/powerpc_machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: powerpc_machdep.c,v 1.42.4.1 2010/03/18 04:36:51 rmind Exp $ */ +/* $NetBSD: powerpc_machdep.c,v 1.42.4.2 2010/04/25 15:27:37 rmind Exp $ */ /* * Copyright (C) 1995, 1996 Wolfgang Solfrank. @@ -32,7 +32,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.42.4.1 2010/03/18 04:36:51 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: powerpc_machdep.c,v 1.42.4.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_altivec.h" #include "opt_modular.h" @@ -319,9 +319,5 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (atop(pa) < physmem) - return 0; - - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + return (atop(pa) < physmem) ? 0 : EFAULT; } Index: src/sys/arch/sh3/sh3/vm_machdep.c diff -u src/sys/arch/sh3/sh3/vm_machdep.c:1.66.4.1 src/sys/arch/sh3/sh3/vm_machdep.c:1.66.4.2 --- src/sys/arch/sh3/sh3/vm_machdep.c:1.66.4.1 Thu Mar 18 04:36:51 2010 +++ src/sys/arch/sh3/sh3/vm_machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: vm_machdep.c,v 1.66.4.1 2010/03/18 04:36:51 rmind Exp $ */ +/* $NetBSD: vm_machdep.c,v 1.66.4.2 2010/04/25 15:27:37 rmind Exp $ */ /*- * Copyright (c) 2002 The NetBSD Foundation, Inc. All rights reserved. @@ -81,7 +81,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.66.4.1 2010/03/18 04:36:51 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: vm_machdep.c,v 1.66.4.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_kstack_debug.h" @@ -399,31 +399,27 @@ mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (atop(pa) < vm_physmem[0].start || PHYS_TO_VM_PAGE(pa) != NULL) + if (atop(pa) < vm_physmem[0].start || PHYS_TO_VM_PAGE(pa) != NULL) { return 0; - - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + } + return EFAULT; } int mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) { - vaddr_t va = (vaddr_t)ptr; + const vaddr_t va = (vaddr_t)ptr; - if (va >= SH3_P1SEG_BASE && va < SH3_P2SEG_BASE) { + if (va < SH3_P1SEG_BASE) { + return EFAULT; + } + if (va < SH3_P2SEG_BASE) { *handled = true; return 0; } - - if (va < SH3_P1SEG_BASE || - (va >= SH3_P2SEG_BASE && va < SH3_P3SEG_BASE)) { - *handled = true; + if (va < SH3_P3SEG_BASE)) { return EFAULT; } - - /* XXX: v < SH3_P3SEG_BASE is physmem, anything special needed? */ - *handled = false; return 0; } Index: src/sys/arch/sparc/sparc/machdep.c diff -u src/sys/arch/sparc/sparc/machdep.c:1.302.2.1 src/sys/arch/sparc/sparc/machdep.c:1.302.2.2 --- src/sys/arch/sparc/sparc/machdep.c:1.302.2.1 Thu Mar 18 04:36:52 2010 +++ src/sys/arch/sparc/sparc/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.302.2.1 2010/03/18 04:36:52 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.302.2.2 2010/04/25 15:27:37 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.302.2.1 2010/03/18 04:36:52 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.302.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_compat_netbsd.h" #include "opt_compat_sunos.h" @@ -2204,19 +2204,10 @@ { extern vaddr_t prom_vstart; extern vaddr_t prom_vend; + const vaddr_t v = ptr; - if (ptr >= (void *)MSGBUF_VA && - (char *)ptr < (char *)MSGBUF_VA + PAGE_SIZE) { - *handled = true; - return 0; - } - - if (ptr >= (void *)prom_vstart && ptr < (void *)prom_vend) { - *handled = true; - return (prot & VM_PROT_WRITE) == 0 ? 0 : EFAULT; - } - - *handled = false; + *handled = (v >= MSGBUF_VA && v < MSGBUF_VA + PAGE_SIZE) || + (v >= prom_vstart && v < prom_vend && (prot & VM_PROT_WRITE) == 0); return 0; } Index: src/sys/arch/sparc64/sparc64/machdep.c diff -u src/sys/arch/sparc64/sparc64/machdep.c:1.252.2.1 src/sys/arch/sparc64/sparc64/machdep.c:1.252.2.2 --- src/sys/arch/sparc64/sparc64/machdep.c:1.252.2.1 Thu Mar 18 04:36:52 2010 +++ src/sys/arch/sparc64/sparc64/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.252.2.1 2010/03/18 04:36:52 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.252.2.2 2010/04/25 15:27:37 rmind Exp $ */ /*- * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252.2.1 2010/03/18 04:36:52 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.252.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_ddb.h" #include "opt_multiprocessor.h" @@ -2066,23 +2066,13 @@ int mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) { - /* Don't know where PROMs are on Ultras. Think it's at f000000 */ - vaddr_t prom_vstart = 0xf000000; - vaddr_t prom_vend = 0xf0100000; - - size_t msgbufsz = msgbufp->msg_bufs + + /* XXX: Don't know where PROMs are on Ultras. Think it's at f000000 */ + const vaddr_t prom_vstart = 0xf000000, prom_vend = 0xf0100000; + const vaddr_t msgbufpv = (vaddr_t)msgbufp, v = ptr; + const size_t msgbufsz = msgbufp->msg_bufs + offsetof(struct kern_msgbuf, msg_bufc); - if ((char *)ptr >= (char *)msgbufp && - (char *)ptr < (char *)msgbufp + msgbufsz) { - *handled = true; - return 0; - } - - if ((vaddr_t)ptr >= prom_vstart && (vaddr_t)ptr < prom_vend) { - *handled = true; - return (prot & VM_PROT_WRITE) == 0 ? 0 : EFAULT; - } - *handled = false; + *handled = (v >= msgbufpv && v < msgbufpv + msgbufsz) || + (v >= prom_vstart && v < prom_vend && (prot & VM_PROT_WRITE) == 0); return 0; } Index: src/sys/arch/vax/include/types.h diff -u src/sys/arch/vax/include/types.h:1.40.4.1 src/sys/arch/vax/include/types.h:1.40.4.2 --- src/sys/arch/vax/include/types.h:1.40.4.1 Thu Mar 18 04:36:53 2010 +++ src/sys/arch/vax/include/types.h Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.40.4.1 2010/03/18 04:36:53 rmind Exp $ */ +/* $NetBSD: types.h,v 1.40.4.2 2010/04/25 15:27:37 rmind Exp $ */ /*- * Copyright (c) 1990 The Regents of the University of California. @@ -77,5 +77,6 @@ #define __HAVE_FAST_SOFTINTS #define __HAVE_MM_MD_READWRITE +#define __HAVE_MM_MD_DIRECT_MAPPED_PHYS #endif /* _MACHTYPES_H_ */ Index: src/sys/arch/vax/vax/machdep.c diff -u src/sys/arch/vax/vax/machdep.c:1.179.2.1 src/sys/arch/vax/vax/machdep.c:1.179.2.2 --- src/sys/arch/vax/vax/machdep.c:1.179.2.1 Thu Mar 18 04:36:53 2010 +++ src/sys/arch/vax/vax/machdep.c Sun Apr 25 15:27:37 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.179.2.1 2010/03/18 04:36:53 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.179.2.2 2010/04/25 15:27:37 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1990 The Regents of the University of California. @@ -83,7 +83,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.179.2.1 2010/03/18 04:36:53 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.179.2.2 2010/04/25 15:27:37 rmind Exp $"); #include "opt_ddb.h" #include "opt_compat_netbsd.h" @@ -782,15 +782,19 @@ __asm("halt"); } +bool +mm_md_direct_mapped_phys(paddr_t paddr, vaddr_t *vaddr) +{ + + *vaddr = paddr + KERNBASE; + return true; +} + int mm_md_physacc(paddr_t pa, vm_prot_t prot) { - if (pa < ctob(physmem)) - return 0; - - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + return (pa < avail_end) ? 0 : EFAULT; } int Index: src/sys/arch/x68k/x68k/machdep.c diff -u src/sys/arch/x68k/x68k/machdep.c:1.165.2.1 src/sys/arch/x68k/x68k/machdep.c:1.165.2.2 --- src/sys/arch/x68k/x68k/machdep.c:1.165.2.1 Thu Mar 18 04:36:53 2010 +++ src/sys/arch/x68k/x68k/machdep.c Sun Apr 25 15:27:38 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.165.2.1 2010/03/18 04:36:53 rmind Exp $ */ +/* $NetBSD: machdep.c,v 1.165.2.2 2010/04/25 15:27:38 rmind Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -77,7 +77,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165.2.1 2010/03/18 04:36:53 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.165.2.2 2010/04/25 15:27:38 rmind Exp $"); #include "opt_ddb.h" #include "opt_kgdb.h" @@ -1250,7 +1250,5 @@ pa < ctob(vm_physmem[i].end)) return 0; } - - return kauth_authorize_machdep(kauth_cred_get(), - KAUTH_MACHDEP_UNMANAGEDMEM, NULL, NULL, NULL, NULL); + return EFAULT; } Index: src/sys/dev/mm.c diff -u src/sys/dev/mm.c:1.13.16.1 src/sys/dev/mm.c:1.13.16.2 --- src/sys/dev/mm.c:1.13.16.1 Thu Mar 18 04:36:54 2010 +++ src/sys/dev/mm.c Sun Apr 25 15:27:35 2010 @@ -1,11 +1,11 @@ -/* $NetBSD: mm.c,v 1.13.16.1 2010/03/18 04:36:54 rmind Exp $ */ +/* $NetBSD: mm.c,v 1.13.16.2 2010/04/25 15:27:35 rmind Exp $ */ /*- * Copyright (c) 2002, 2008, 2010 The NetBSD Foundation, Inc. * All rights reserved. * * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas and Joerg Sonnenberger. + * by Christos Zoulas, Joerg Sonnenberger and Mindaugas Rasiukevicius. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -29,8 +29,12 @@ * POSSIBILITY OF SUCH DAMAGE. */ +/* + * Special /dev/{mem,kmem,zero,null} memory devices. + */ + #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.13.16.1 2010/03/18 04:36:54 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: mm.c,v 1.13.16.2 2010/04/25 15:27:35 rmind Exp $"); #include "opt_compat_netbsd.h" @@ -65,6 +69,16 @@ D_MPSAFE }; +#ifdef pmax /* XXX */ +const struct cdevsw mem_ultrix_cdevsw = { + nullopen, nullclose, mm_readwrite, mm_readwrite, mm_ioctl, + nostop, notty, nopoll, mm_mmap, nokqfilter, D_MPSAFE +}; +#endif + +/* + * mm_init: initialize memory device driver. + */ void mm_init(void) { @@ -72,60 +86,86 @@ mutex_init(&dev_mem_lock, MUTEX_DEFAULT, IPL_NONE); + /* Read-only zero-page. */ pg = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_WIRED|UVM_KMF_ZERO); KASSERT(pg != 0); pmap_protect(pmap_kernel(), pg, pg + PAGE_SIZE, VM_PROT_READ); dev_zero_page = (void *)pg; +#ifndef __HAVE_MM_MD_PREFER_VA + /* KVA for mappings during I/O. */ dev_mem_addr = uvm_km_alloc(kernel_map, PAGE_SIZE, 0, UVM_KMF_VAONLY); KASSERT(dev_mem_addr != 0); +#endif } +/* + * dev_kmem_readwrite: helper for DEV_MEM (/dev/mem) case of R/W. + */ static int dev_mem_readwrite(struct uio *uio, struct iovec *iov) { - bool have_direct; paddr_t paddr; vaddr_t vaddr; vm_prot_t prot; size_t len, offset; + bool have_direct; int error; + /* Check for wrap around. */ if ((intptr_t)uio->uio_offset != uio->uio_offset) { return EFAULT; } paddr = uio->uio_offset & ~PAGE_MASK; - offset = uio->uio_offset & PAGE_MASK; - len = min(uio->uio_resid, PAGE_SIZE - offset); - prot = uio->uio_rw == UIO_WRITE ? VM_PROT_WRITE : VM_PROT_READ; - + prot = (uio->uio_rw == UIO_WRITE) ? VM_PROT_WRITE : VM_PROT_READ; error = mm_md_physacc(paddr, prot); if (error) { return error; } + offset = uio->uio_offset & PAGE_MASK; + len = min(uio->uio_resid, PAGE_SIZE - offset); #ifdef __HAVE_MM_MD_DIRECT_MAPPED_PHYS + /* Is physical address directly mapped? Return VA. */ have_direct = mm_md_direct_mapped_phys(paddr, &vaddr); #else have_direct = false; #endif if (!have_direct) { +#ifndef __HAVE_MM_MD_PREFER_VA + const vaddr_t va = dev_mem_addr; +#else + /* Get a special virtual address. */ + const vaddr_t va = mm_md_getva(paddr); +#endif + /* Map selected KVA to physical address. */ mutex_enter(&dev_mem_lock); - pmap_enter(pmap_kernel(), dev_mem_addr, paddr, prot, - prot | PMAP_WIRED); + pmap_kenter_pa(va, paddr, prot, 0); pmap_update(pmap_kernel()); - vaddr = dev_mem_addr + offset; + /* Perform I/O. */ + vaddr = va + offset; error = uiomove((void *)vaddr, len, uio); - pmap_remove(pmap_kernel(), dev_mem_addr, PAGE_SIZE); + /* Unmap. Note: no need for pmap_update(). */ + pmap_kremove(va, PAGE_SIZE); mutex_exit(&dev_mem_lock); + +#ifdef __HAVE_MM_MD_PREFER_VA + /* "Release" the virtual address. */ + mm_md_relva(va); +#endif } else { + /* Direct map, just perform I/O. */ + vaddr += offset; error = uiomove((void *)vaddr, len, uio); } return error; } +/* + * dev_kmem_readwrite: helper for DEV_KMEM (/dev/kmem) case of R/W. + */ static int dev_kmem_readwrite(struct uio *uio, struct iovec *iov) { @@ -135,51 +175,76 @@ int error; bool md_kva; + /* Check for wrap around. */ addr = (void *)(intptr_t)uio->uio_offset; if ((uintptr_t)addr != uio->uio_offset) { return EFAULT; } + /* + * Handle non-page aligned offset. + * Otherwise, we operate in page-by-page basis. + */ offset = uio->uio_offset & PAGE_MASK; len = min(uio->uio_resid, PAGE_SIZE - offset); - prot = uio->uio_rw == UIO_WRITE ? VM_PROT_WRITE : VM_PROT_READ; + prot = (uio->uio_rw == UIO_WRITE) ? VM_PROT_WRITE : VM_PROT_READ; md_kva = false; #ifdef __HAVE_MM_MD_DIRECT_MAPPED_IO paddr_t paddr; + /* MD case: is this is a directly mapped address? */ if (mm_md_direct_mapped_io(addr, &paddr)) { + /* If so, validate physical address. */ error = mm_md_physacc(paddr, prot); - if (error) + if (error) { return error; + } md_kva = true; } #endif + if (!md_kva) { + bool checked = false; #ifdef __HAVE_MM_MD_KERNACC - if (!md_kva && (error = mm_md_kernacc(addr, prot, &md_kva)) != 0) { - return error; - } + /* MD check for the address. */ + error = mm_md_kernacc(addr, prot, &checked); + if (error) { + return error; + } #endif - if (!md_kva && !uvm_kernacc(addr, prot)) { - return EFAULT; + /* UVM check for the address (unless MD indicated to not). */ + if (!checked && !uvm_kernacc(addr, len, prot)) { + return EFAULT; + } } error = uiomove(addr, len, uio); return error; } -static int +/* + * dev_zero_readwrite: helper for DEV_ZERO (/dev/null) case of R/W. + */ +static inline int dev_zero_readwrite(struct uio *uio, struct iovec *iov) { size_t len; + /* Nothing to do for the write case. */ if (uio->uio_rw == UIO_WRITE) { uio->uio_resid = 0; return 0; } + /* + * Read in page-by-page basis, caller will continue. + * Cut appropriately for a single/last-iteration cases. + */ len = min(iov->iov_len, PAGE_SIZE); return uiomove(dev_zero_page, len, uio); } +/* + * mm_readwrite: general memory R/W function. + */ static int mm_readwrite(dev_t dev, struct uio *uio, int flags) { @@ -187,6 +252,7 @@ int error; #ifdef __HAVE_MM_MD_READWRITE + /* If defined - there are extra MD cases. */ switch (minor(dev)) { case DEV_MEM: case DEV_KMEM: @@ -204,11 +270,13 @@ while (uio->uio_resid > 0 && error == 0) { iov = uio->uio_iov; if (iov->iov_len == 0) { - ++uio->uio_iov; - --uio->uio_iovcnt; + /* Processed; next I/O vector. */ + uio->uio_iov++; + uio->uio_iovcnt--; KASSERT(uio->uio_iovcnt >= 0); continue; } + /* Helper functions will process in page-by-page basis. */ switch (minor(dev)) { case DEV_MEM: error = dev_mem_readwrite(uio, iov); @@ -236,12 +304,16 @@ return error; } +/* + * mm_mmap: general mmap() handler. + */ static paddr_t mm_mmap(dev_t dev, off_t off, int acc) { vm_prot_t prot; #ifdef __HAVE_MM_MD_MMAP + /* If defined - there are extra mmap() MD cases. */ switch (minor(dev)) { case DEV_MEM: case DEV_KMEM: @@ -271,6 +343,7 @@ if (acc & PROT_WRITE) prot |= VM_PROT_WRITE; + /* Validate the physical address. */ if (mm_md_physacc(off, prot) != 0) { return -1; } Index: src/sys/dev/mm.h diff -u src/sys/dev/mm.h:1.1.2.1 src/sys/dev/mm.h:1.1.2.2 --- src/sys/dev/mm.h:1.1.2.1 Thu Mar 18 04:36:54 2010 +++ src/sys/dev/mm.h Sun Apr 25 15:27:35 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: mm.h,v 1.1.2.1 2010/03/18 04:36:54 rmind Exp $ */ +/* $NetBSD: mm.h,v 1.1.2.2 2010/04/25 15:27:35 rmind Exp $ */ /*- * Copyright (c) 2008 Joerg Sonnenberger <jo...@netbsd.org>. @@ -86,4 +86,13 @@ */ bool mm_md_direct_mapped_io(void *, paddr_t *); +/* + * Optional hooks to select and release a special virtual address, + * in order to avoid cache aliasing issues on certain architectures. + * + * machine/types.h must define __HAVE_MM_MD_PREFER_VA to use this. + */ +vaddr_t mm_md_getva(paddr_t); +void mm_md_relva(vaddr_t); + #endif /* _SYS_DEV_MM_H_ */ Index: src/sys/uvm/uvm_glue.c diff -u src/sys/uvm/uvm_glue.c:1.144.2.1 src/sys/uvm/uvm_glue.c:1.144.2.2 --- src/sys/uvm/uvm_glue.c:1.144.2.1 Thu Mar 18 04:36:54 2010 +++ src/sys/uvm/uvm_glue.c Sun Apr 25 15:27:38 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: uvm_glue.c,v 1.144.2.1 2010/03/18 04:36:54 rmind Exp $ */ +/* $NetBSD: uvm_glue.c,v 1.144.2.2 2010/04/25 15:27:38 rmind Exp $ */ /* * Copyright (c) 1997 Charles D. Cranor and Washington University. @@ -67,7 +67,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.144.2.1 2010/03/18 04:36:54 rmind Exp $"); +__KERNEL_RCSID(0, "$NetBSD: uvm_glue.c,v 1.144.2.2 2010/04/25 15:27:38 rmind Exp $"); #include "opt_kgdb.h" #include "opt_kstack.h" @@ -90,24 +90,19 @@ #include <uvm/uvm.h> /* - * XXXCDC: do these really belong here? - */ - -/* - * uvm_kernacc: can the kernel access a region of memory + * uvm_kernacc: test if kernel can access a memory region. * - * - used only by /dev/kmem driver (dev/mm.c) + * => Currently used only by /dev/kmem driver (dev/mm.c). */ - bool -uvm_kernacc(void *addr, vm_prot_t prot) +uvm_kernacc(void *addr, size_t len, vm_prot_t prot) { - vaddr_t saddr; + vaddr_t saddr = trunc_page((vaddr_t)addr); + vaddr_t eaddr = round_page(saddr + len); bool rv; - saddr = trunc_page((vaddr_t)addr); vm_map_lock_read(kernel_map); - rv = uvm_map_checkprot(kernel_map, saddr, saddr + 1, prot); + rv = uvm_map_checkprot(kernel_map, saddr, eaddr, prot); vm_map_unlock_read(kernel_map); return rv;