Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/rmind-uvmplock]: src/sys - Invent mm_md_getva() and mm_md_relva() routin...
details: https://anonhg.NetBSD.org/src/rev/28f559804a87
branches: rmind-uvmplock
changeset: 753048:28f559804a87
user: rmind <rmind%NetBSD.org@localhost>
date: Sun Apr 25 15:27:35 2010 +0000
description:
- 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.
diffstat:
sys/arch/acorn26/acorn26/machdep.c | 14 +--
sys/arch/alpha/alpha/machdep.c | 10 +-
sys/arch/amd64/amd64/machdep.c | 7 +-
sys/arch/hp300/hp300/machdep.c | 13 +-
sys/arch/hp700/hp700/machdep.c | 22 ++++-
sys/arch/hp700/include/types.h | 5 +-
sys/arch/luna68k/luna68k/machdep.c | 13 +-
sys/arch/mips/mips/mips_machdep.c | 25 +----
sys/arch/mvme68k/mvme68k/machdep.c | 8 +-
sys/arch/news68k/news68k/machdep.c | 15 +--
sys/arch/next68k/next68k/machdep.c | 8 +-
sys/arch/powerpc/powerpc/powerpc_machdep.c | 10 +-
sys/arch/sh3/sh3/vm_machdep.c | 26 ++---
sys/arch/sparc/sparc/machdep.c | 19 +---
sys/arch/sparc64/sparc64/machdep.c | 26 +----
sys/arch/vax/include/types.h | 3 +-
sys/arch/vax/vax/machdep.c | 18 ++-
sys/arch/x68k/x68k/machdep.c | 8 +-
sys/dev/mm.c | 117 +++++++++++++++++++++++-----
sys/dev/mm.h | 11 ++-
sys/uvm/uvm_glue.c | 21 +---
21 files changed, 221 insertions(+), 178 deletions(-)
diffs (truncated from 1016 to 300 lines):
diff -r 68653eda0592 -r 28f559804a87 sys/arch/acorn26/acorn26/machdep.c
--- a/sys/arch/acorn26/acorn26/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/acorn26/acorn26/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/alpha/alpha/machdep.c
--- a/sys/arch/alpha/alpha/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/alpha/alpha/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/amd64/amd64/machdep.c
--- a/sys/arch/amd64/amd64/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/amd64/amd64/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/hp300/hp300/machdep.c
--- a/sys/arch/hp300/hp300/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/hp300/hp300/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/hp700/hp700/machdep.c
--- a/sys/arch/hp700/hp700/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/hp700/hp700/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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);
+}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/hp700/include/types.h
--- a/sys/arch/hp700/include/types.h Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/hp700/include/types.h Sun Apr 25 15:27:35 2010 +0000
@@ -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_ */
diff -r 68653eda0592 -r 28f559804a87 sys/arch/luna68k/luna68k/machdep.c
--- a/sys/arch/luna68k/luna68k/machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/luna68k/luna68k/machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
}
diff -r 68653eda0592 -r 28f559804a87 sys/arch/mips/mips/mips_machdep.c
--- a/sys/arch/mips/mips/mips_machdep.c Sat Apr 24 21:24:03 2010 +0000
+++ b/sys/arch/mips/mips/mips_machdep.c Sun Apr 25 15:27:35 2010 +0000
@@ -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;
Home |
Main Index |
Thread Index |
Old Index