Module Name: src Committed By: reinoud Date: Wed Feb 8 17:55:21 UTC 2012
Modified Files: src/sys/arch/usermode/include: cpu.h types.h vmparam.h src/sys/arch/usermode/usermode: machdep.c Log Message: Fix /dev/kmem access and make vmstat(1) `work'. Not sure all the results are indeed valid or correct but at least it shows them without coredumping or coredumping the kernel. To generate a diff of this commit: cvs rdiff -u -r1.9 -r1.10 src/sys/arch/usermode/include/cpu.h cvs rdiff -u -r1.7 -r1.8 src/sys/arch/usermode/include/types.h cvs rdiff -u -r1.15 -r1.16 src/sys/arch/usermode/include/vmparam.h cvs rdiff -u -r1.52 -r1.53 src/sys/arch/usermode/usermode/machdep.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/include/cpu.h diff -u src/sys/arch/usermode/include/cpu.h:1.9 src/sys/arch/usermode/include/cpu.h:1.10 --- src/sys/arch/usermode/include/cpu.h:1.9 Thu Jan 19 12:14:49 2012 +++ src/sys/arch/usermode/include/cpu.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: cpu.h,v 1.9 2012/01/19 12:14:49 reinoud Exp $ */ +/* $NetBSD: cpu.h,v 1.10 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -50,10 +50,10 @@ extern void cpu_need_resched(struct cpu_ struct cpu_info { - device_t ci_dev; + struct cpu_data ci_data; /* MI per-cpu data */ + device_t ci_dev; /* pointer to our device */ struct cpu_info *ci_self; struct cpu_info *ci_next; - struct cpu_data ci_data; u_int ci_cpuid; int ci_want_resched; int ci_idepth; Index: src/sys/arch/usermode/include/types.h diff -u src/sys/arch/usermode/include/types.h:1.7 src/sys/arch/usermode/include/types.h:1.8 --- src/sys/arch/usermode/include/types.h:1.7 Sun Jan 8 18:06:00 2012 +++ src/sys/arch/usermode/include/types.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: types.h,v 1.7 2012/01/08 18:06:00 jmcneill Exp $ */ +/* $NetBSD: types.h,v 1.8 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -62,4 +62,7 @@ typedef volatile unsigned char __cpu_sim #define __HAVE_OLD_DISKLABEL #endif +#define __HAVE_CPU_DATA_FIRST +#define __HAVE_MM_MD_KERNACC + #endif /* !_ARCH_USERMODE_INCLUDE_TYPES_H */ Index: src/sys/arch/usermode/include/vmparam.h diff -u src/sys/arch/usermode/include/vmparam.h:1.15 src/sys/arch/usermode/include/vmparam.h:1.16 --- src/sys/arch/usermode/include/vmparam.h:1.15 Tue Jan 10 10:19:38 2012 +++ src/sys/arch/usermode/include/vmparam.h Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: vmparam.h,v 1.15 2012/01/10 10:19:38 reinoud Exp $ */ +/* $NetBSD: vmparam.h,v 1.16 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2007 Jared D. McNeill <jmcne...@invisible.ca> @@ -36,6 +36,7 @@ extern paddr_t kmem_k_start, kmem_k_end; extern paddr_t kmem_kvm_start, kmem_kvm_end; +extern paddr_t kmem_kvm_cur_end; extern paddr_t kmem_user_start, kmem_user_end; #define VM_MIN_ADDRESS kmem_user_start Index: src/sys/arch/usermode/usermode/machdep.c diff -u src/sys/arch/usermode/usermode/machdep.c:1.52 src/sys/arch/usermode/usermode/machdep.c:1.53 --- src/sys/arch/usermode/usermode/machdep.c:1.52 Sun Jan 15 10:30:21 2012 +++ src/sys/arch/usermode/usermode/machdep.c Wed Feb 8 17:55:21 2012 @@ -1,4 +1,4 @@ -/* $NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $ */ +/* $NetBSD: machdep.c,v 1.53 2012/02/08 17:55:21 reinoud Exp $ */ /*- * Copyright (c) 2011 Reinoud Zandijk <rein...@netbsd.org> @@ -37,7 +37,7 @@ #include "opt_memsize.h" #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $"); +__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.53 2012/02/08 17:55:21 reinoud Exp $"); #include <sys/types.h> #include <sys/systm.h> @@ -55,6 +55,7 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v #include <uvm/uvm_page.h> #include <dev/mm.h> +#include <machine/vmparam.h> #include <machine/machdep.h> #include <machine/thunk.h> @@ -249,8 +250,30 @@ consinit(void) } int -mm_md_physacc(paddr_t pa, vm_prot_t prog) +mm_md_physacc(paddr_t pa, vm_prot_t prot) { + // printf("%s: pa = %p, acc %d\n", __func__, (void *) pa, prot); + if (pa >= physmem * PAGE_SIZE) + return EFAULT; + return 0; +} + + +int +mm_md_kernacc(void *ptr, vm_prot_t prot, bool *handled) +{ + const vaddr_t va = (vaddr_t)ptr; + extern void *end; + + // printf("%s: ptr %p, acc %d\n", __func__, ptr, prot); + if (va < kmem_kvm_start) + return EFAULT; + if ((va >= kmem_kvm_cur_end) && (va < kmem_k_start)) + return EFAULT; + if (va > (vaddr_t) end) + return EFAULT; + + *handled = true; return 0; }