Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libkvm Teach libkvm how kernel virtual memory is laided ...



details:   https://anonhg.NetBSD.org/src/rev/55cbd6c5e3ee
branches:  trunk
changeset: 761297:55cbd6c5e3ee
user:      matt <matt%NetBSD.org@localhost>
date:      Sun Jan 23 06:28:52 2011 +0000

description:
Teach libkvm how kernel virtual memory is laided on 64-bit MIPS kernels.

diffstat:

 lib/libkvm/kvm_mips.c |  43 +++++++++++++++++++++++++++++++++++++++----
 1 files changed, 39 insertions(+), 4 deletions(-)

diffs (97 lines):

diff -r 2b3bfdbcf8b6 -r 55cbd6c5e3ee lib/libkvm/kvm_mips.c
--- a/lib/libkvm/kvm_mips.c     Sun Jan 23 06:27:32 2011 +0000
+++ b/lib/libkvm/kvm_mips.c     Sun Jan 23 06:28:52 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kvm_mips.c,v 1.20 2010/09/20 23:23:16 jym Exp $ */
+/* $NetBSD: kvm_mips.c,v 1.21 2011/01/23 06:28:52 matt Exp $ */
 
 /*
  * Copyright (c) 1994, 1995 Carnegie-Mellon University.
@@ -34,7 +34,7 @@
 
 #include <sys/cdefs.h>
 #if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: kvm_mips.c,v 1.20 2010/09/20 23:23:16 jym Exp $");
+__RCSID("$NetBSD: kvm_mips.c,v 1.21 2011/01/23 06:28:52 matt Exp $");
 #endif /* LIBC_SCCS and not lint */
 
 /*
@@ -100,6 +100,23 @@
        cpu_kh = kd->cpu_data;
        page_off = va & PGOFSET;
 
+#ifdef _LP64
+       if (MIPS_XKPHYS_P(va)) {
+               /*
+                * Direct-mapped cached address: just convert it.
+                */
+               *pa = MIPS_XKPHYS_TO_PHYS(va);
+               return (NBPG - page_off);
+       }
+
+       if (va < MIPS_XKPHYS_START) {
+               /*
+                * XUSEG (user virtual address space) - invalid.
+                */
+               _kvm_err(kd, 0, "invalid kernel virtual address");
+               goto lose;
+       }
+#else
        if (va < MIPS_KSEG0_START) {
                /*
                 * KUSEG (user virtual address space) - invalid.
@@ -107,8 +124,9 @@
                _kvm_err(kd, 0, "invalid kernel virtual address");
                goto lose;
        }
+#endif
 
-       if (va >= MIPS_KSEG0_START && va < MIPS_KSEG1_START) {
+       if (MIPS_KSEG0_P(va)) {
                /*
                 * Direct-mapped cached address: just convert it.
                 */
@@ -116,7 +134,7 @@
                return (NBPG - page_off);
        }
 
-       if (va >= MIPS_KSEG1_START && va < MIPS_KSEG2_START) {
+       if (MIPS_KSEG1_P(va)) {
                /*
                 * Direct-mapped uncached address: just convert it.
                 */
@@ -124,6 +142,16 @@
                return (NBPG - page_off);
        }
 
+#ifdef _LP64
+       if (va >= MIPS_KSEG2_START) {
+               /*
+                * KUSEG (user virtual address space) - invalid.
+                */
+               _kvm_err(kd, 0, "invalid kernel virtual address");
+               goto lose;
+       }
+#endif
+
        /*
         * We now know that we're a KSEG2 (kernel virtually mapped)
         * address.  Translate the address using the pmap's kernel
@@ -134,10 +162,17 @@
         * Step 1: Make sure the kernel page table has a translation
         * for the address.
         */
+#ifdef _LP64
+       if (va >= (MIPS_XKSEG_START + (cpu_kh->sysmapsize * NBPG))) {
+               _kvm_err(kd, 0, "invalid XKSEG address");
+               goto lose;
+       }
+#else
        if (va >= (MIPS_KSEG2_START + (cpu_kh->sysmapsize * NBPG))) {
                _kvm_err(kd, 0, "invalid KSEG2 address");
                goto lose;
        }
+#endif
 
        /*
         * Step 2: Locate and read the PTE.



Home | Main Index | Thread Index | Old Index