Module Name:    src
Committed By:   matt
Date:           Sun Jan 23 06:28:53 UTC 2011

Modified Files:
        src/lib/libkvm: kvm_mips.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/lib/libkvm/kvm_mips.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/lib/libkvm/kvm_mips.c
diff -u src/lib/libkvm/kvm_mips.c:1.20 src/lib/libkvm/kvm_mips.c:1.21
--- src/lib/libkvm/kvm_mips.c:1.20	Mon Sep 20 23:23:16 2010
+++ src/lib/libkvm/kvm_mips.c	Sun Jan 23 06:28:52 2011
@@ -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.

Reply via email to