summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2009-11-22 00:07:05 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2009-11-22 00:07:05 +0000
commita2feff6f6e67265d6246eedb1e93779a5540bfc0 (patch)
treebf99709c25a5b2d09c035aa8ead704e037ecf9a8
parentcd1108ad13a0da9d29d3357b59a3a562df545780 (diff)
Allow mips ports to override VM_{MIN,MAX}_KERNEL_ADDRESS, and provide the
address as a kernel variable for use by libkvm. On sgi IP27 and IP30 kernels, use XKSEG instead of CKSSEG; this will allow kernel KVM size to grow in the future if necessary.
-rw-r--r--lib/libkvm/kvm_mips64.c18
-rw-r--r--sys/arch/mips64/include/vmparam.h6
-rw-r--r--sys/arch/mips64/mips64/pmap.c3
-rw-r--r--sys/arch/mips64/mips64/trap.c14
-rw-r--r--sys/arch/sgi/include/vmparam.h20
5 files changed, 49 insertions, 12 deletions
diff --git a/lib/libkvm/kvm_mips64.c b/lib/libkvm/kvm_mips64.c
index a2d4df5038d..0537c65796a 100644
--- a/lib/libkvm/kvm_mips64.c
+++ b/lib/libkvm/kvm_mips64.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kvm_mips64.c,v 1.9 2009/10/27 23:59:28 deraadt Exp $ */
+/* $OpenBSD: kvm_mips64.c,v 1.10 2009/11/22 00:07:02 miod Exp $ */
/* $NetBSD: kvm_mips.c,v 1.3 1996/03/18 22:33:44 thorpej Exp $ */
/*-
@@ -60,6 +60,7 @@
struct vmstate {
pt_entry_t *Sysmap;
u_int Sysmapsize;
+ vaddr_t Sysmapbase;
};
void
@@ -96,6 +97,17 @@ _kvm_initvtop(kvm_t *kd)
_kvm_err(kd, kd->program, "cannot read Sysmapsize");
return (-1);
}
+
+ /*
+ * Older kernels might not have this symbol; in which case
+ * we use the value of VM_MIN_KERNEL_ADDRESS they must have.
+ */
+ nlist[0].n_name = "Sysmapbase";
+ nlist[1].n_name = 0;
+ if (kvm_nlist(kd, nlist) != 0 ||
+ KREAD(kd, (u_long)nlist[0].n_value, &vm->Sysmapbase))
+ vm->Sysmapbase = (vaddr_t)KSSEG_BASE;
+
return (0);
}
@@ -134,9 +146,9 @@ _kvm_kvatop(kvm_t *kd, u_long va, paddr_t *pa)
*pa = KSEG0_TO_PHYS(va);
return (int)(PAGE_SIZE - offset);
}
- if (va < VM_MIN_KERNEL_ADDRESS)
+ if (va < vm->Sysmapbase)
goto invalid;
- idx = (va - VM_MIN_KERNEL_ADDRESS) >> PGSHIFT;
+ idx = (va - vm->Sysmapbase) >> PGSHIFT;
if (idx >= vm->Sysmapsize)
goto invalid;
addr = (u_long)(vm->Sysmap + idx);
diff --git a/sys/arch/mips64/include/vmparam.h b/sys/arch/mips64/include/vmparam.h
index 5572ee262ed..38a1d72c423 100644
--- a/sys/arch/mips64/include/vmparam.h
+++ b/sys/arch/mips64/include/vmparam.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmparam.h,v 1.17 2009/10/22 18:20:21 miod Exp $ */
+/* $OpenBSD: vmparam.h,v 1.18 2009/11/22 00:07:04 miod Exp $ */
/* $NetBSD: vmparam.h,v 1.5 1994/10/26 21:10:10 cgd Exp $ */
/*
@@ -98,8 +98,10 @@
#define VM_MIN_ADDRESS ((vaddr_t)0x0000000000001000L)
#define VM_MAXUSER_ADDRESS ((vaddr_t)0x0000000080000000L)
#define VM_MAX_ADDRESS ((vaddr_t)0x0000000080000000L)
-#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffffc0000000L)
+#ifndef VM_MIN_KERNEL_ADDRESS
+#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffffc0000000L)
#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xfffffffffffff000L)
+#endif
/* map PIE below 256MB (non-pie link address) to avoid mmap pressure */
#define VM_PIE_MIN_ADDR PAGE_SIZE
diff --git a/sys/arch/mips64/mips64/pmap.c b/sys/arch/mips64/mips64/pmap.c
index c678c37c08b..07aa52ca417 100644
--- a/sys/arch/mips64/mips64/pmap.c
+++ b/sys/arch/mips64/mips64/pmap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pmap.c,v 1.39 2009/11/19 20:16:27 miod Exp $ */
+/* $OpenBSD: pmap.c,v 1.40 2009/11/22 00:07:04 miod Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -131,6 +131,7 @@ u_int tlbpid_cnt = 2; /* next available TLB PID */
pt_entry_t *Sysmap; /* kernel pte table */
u_int Sysmapsize; /* number of pte's in Sysmap */
+const vaddr_t Sysmapbase = VM_MIN_KERNEL_ADDRESS; /* for libkvm */
/*
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index d460179aa70..91c3085d574 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.50 2009/11/21 23:28:15 syuu Exp $ */
+/* $OpenBSD: trap.c,v 1.51 2009/11/22 00:07:04 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -1122,6 +1122,10 @@ stacktrace(regs)
stacktrace_subr(regs, printf);
}
+#define VALID_ADDRESS(va) \
+ (((va) >= VM_MIN_KERNEL_ADDRESS && (va) < VM_MAX_KERNEL_ADDRESS) || \
+ IS_XKPHYS(va) || ((va) >= CKSEG0_BASE && (va) < CKSSEG_BASE))
+
void
stacktrace_subr(regs, printfn)
struct trap_frame *regs;
@@ -1132,7 +1136,6 @@ stacktrace_subr(regs, printfn)
unsigned instr, mask;
InstFmt i;
int more, stksize;
- extern char edata[];
unsigned int frames = 0;
/* get initial values from the exception frame */
@@ -1157,7 +1160,7 @@ loop:
}
/* check for bad SP: could foul up next frame */
- if (sp & 3 || (!IS_XKPHYS(sp) && sp < CKSEG0_BASE)) {
+ if (sp & 3 || !VALID_ADDRESS(sp)) {
(*printfn)("SP %p: not in kernel\n", sp);
ra = 0;
subr = 0;
@@ -1189,8 +1192,7 @@ loop:
Between((vaddr_t)a, pc, (vaddr_t)b)
/* check for bad PC */
- if (pc & 3 || (!IS_XKPHYS(pc) && pc < CKSEG0_BASE) ||
- pc >= (vaddr_t)edata) {
+ if (pc & 3 || !VALID_ADDRESS(pc)) {
(*printfn)("PC %p: not in kernel\n", pc);
ra = 0;
goto done;
@@ -1336,6 +1338,8 @@ done:
}
}
+#undef VALID_ADDRESS
+
#if !defined(DDB)
/*
* Functions ``special'' enough to print by name
diff --git a/sys/arch/sgi/include/vmparam.h b/sys/arch/sgi/include/vmparam.h
index a55866983c4..210a1aebfee 100644
--- a/sys/arch/sgi/include/vmparam.h
+++ b/sys/arch/sgi/include/vmparam.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vmparam.h,v 1.4 2009/10/14 20:18:26 miod Exp $ */
+/* $OpenBSD: vmparam.h,v 1.5 2009/11/22 00:07:04 miod Exp $ */
/* public domain */
#ifndef _SGI_VMPARAM_H_
#define _SGI_VMPARAM_H_
@@ -19,6 +19,24 @@
#define VM_NFREELIST 2
#define VM_FREELIST_DMA32 1 /* memory suitable for 32-bit DMA */
+/*
+ * On systems with may use R5000 processors, we limit the kernel virtual
+ * address space to KSSEG and KSEG3.
+ * On systems with R10000 family processors, we use the XKSEG which allows
+ * for a much larger virtual memory size.
+ *
+ * All Octane and Origin class systems are R10000 family based only,
+ * so TGT_COHERENT is safe to use so far.
+ */
+
+#ifdef TGT_COHERENT
+#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xc000000000000000L)
+#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xc000000040000000L)
+#else
+#define VM_MIN_KERNEL_ADDRESS ((vaddr_t)0xffffffffc0000000L)
+#define VM_MAX_KERNEL_ADDRESS ((vaddr_t)0xfffffffffffff000L)
+#endif
+
#include <mips64/vmparam.h>
#endif /* _SGI_VMPARAM_H_ */