summaryrefslogtreecommitdiff
path: root/sys/arch/mips64
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2008-02-18 19:47:37 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2008-02-18 19:47:37 +0000
commit2622358a4e95c5ac61ddb274ebbe9206ad6f748d (patch)
tree59faf736316e897d8ca0533d32db1ccc1ce68b1c /sys/arch/mips64
parent2f527e5bb6d3571d44a176399bb9e302e17a088b (diff)
Use better types and fix tests for pc and sp being in kernel to really
handle XKPHYS addresses correctly.
Diffstat (limited to 'sys/arch/mips64')
-rw-r--r--sys/arch/mips64/mips64/db_machdep.c19
-rw-r--r--sys/arch/mips64/mips64/trap.c19
2 files changed, 20 insertions, 18 deletions
diff --git a/sys/arch/mips64/mips64/db_machdep.c b/sys/arch/mips64/mips64/db_machdep.c
index af27e124f57..c6d3fa4fe67 100644
--- a/sys/arch/mips64/mips64/db_machdep.c
+++ b/sys/arch/mips64/mips64/db_machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: db_machdep.c,v 1.14 2007/10/22 14:46:46 jsing Exp $ */
+/* $OpenBSD: db_machdep.c,v 1.15 2008/02/18 19:47:36 miod Exp $ */
/*
* Copyright (c) 1998-2003 Opsycon AB (www.opsycon.se)
@@ -213,7 +213,7 @@ db_stack_trace_print(addr, have_addr, count, modif, pr)
db_expr_t diff;
db_addr_t subr;
char *symname;
- register_t pc, sp, ra, va;
+ vaddr_t pc, sp, ra, va;
register_t a0, a1, a2, a3;
unsigned instr, mask;
InstFmt i;
@@ -224,9 +224,9 @@ db_stack_trace_print(addr, have_addr, count, modif, pr)
struct trap_frame *regs = &ddb_regs;
/* get initial values from the exception frame */
- sp = regs->sp;
- pc = regs->pc;
- ra = regs->ra; /* May be a 'leaf' function */
+ sp = (vaddr_t)regs->sp;
+ pc = (vaddr_t)regs->pc;
+ ra = (vaddr_t)regs->ra; /* May be a 'leaf' function */
a0 = regs->a0;
a1 = regs->a1;
a2 = regs->a2;
@@ -239,7 +239,7 @@ loop:
stksize = 0;
/* check for bad SP: could foul up next frame */
- if (sp & 3 || (!IS_XKPHYS((vaddr_t)sp) && sp < KSEG0_BASE)) {
+ if (sp & 3 || (!IS_XKPHYS(sp) && sp < KSEG0_BASE)) {
(*pr)("SP %p: not in kernel\n", sp);
ra = 0;
subr = 0;
@@ -248,9 +248,9 @@ loop:
#if 0
/* Backtraces should contine through interrupts from kernel mode */
- if (pc >= (unsigned)MipsKernIntr && pc < (unsigned)MipsUserIntr) {
+ if (pc >= (vaddr_t)MipsKernIntr && pc < (vaddr_t)MipsUserIntr) {
(*pr)("MipsKernIntr+%x: (%x, %x ,%x) -------\n",
- pc-(unsigned)MipsKernIntr, a0, a1, a2);
+ pc - (vaddr_t)MipsKernIntr, a0, a1, a2);
regs = (struct trap_frame *)(sp + STAND_ARG_SIZE);
a0 = kdbpeek(&regs->a0);
a1 = kdbpeek(&regs->a1);
@@ -266,7 +266,8 @@ loop:
/* check for bad PC */
- if (pc & 3 || pc < KSEG0_BASE || pc >= (unsigned)edata) {
+ if (pc & 3 || (!IS_XKPHYS(pc) && pc < KSEG0_BASE) ||
+ pc >= (vaddr_t)edata) {
(*pr)("PC %p: not in kernel\n", pc);
ra = 0;
goto done;
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index 7eaf6a5ee97..3d057cd8539 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.39 2007/10/25 16:24:18 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.40 2008/02/18 19:47:36 miod Exp $ */
/* tracked to 1.23 */
/*
@@ -1129,7 +1129,7 @@ stacktrace_subr(regs, printfn)
struct trap_frame *regs;
int (*printfn)(const char*, ...);
{
- long pc, sp, fp, ra, va, subr;
+ vaddr_t pc, sp, fp, ra, va, subr;
long a0, a1, a2, a3;
unsigned instr, mask;
InstFmt i;
@@ -1138,10 +1138,10 @@ stacktrace_subr(regs, printfn)
unsigned int frames = 0;
/* get initial values from the exception frame */
- sp = regs->sp;
- pc = regs->pc;
- fp = regs->s8;
- ra = regs->ra; /* May be a 'leaf' function */
+ sp = (vaddr_t)regs->sp;
+ pc = (vaddr_t)regs->pc;
+ fp = (vaddr_t)regs->s8;
+ ra = (vaddr_t)regs->ra; /* May be a 'leaf' function */
a0 = regs->a0;
a1 = regs->a1;
a2 = regs->a2;
@@ -1159,7 +1159,7 @@ loop:
}
/* check for bad SP: could foul up next frame */
- if (sp & 3 || (!IS_XKPHYS((vaddr_t)sp) && sp < KSEG0_BASE)) {
+ if (sp & 3 || (!IS_XKPHYS(sp) && sp < KSEG0_BASE)) {
(*printfn)("SP %p: not in kernel\n", sp);
ra = 0;
subr = 0;
@@ -1170,7 +1170,7 @@ loop:
/* Backtraces should contine through interrupts from kernel mode */
if (pc >= (vaddr_t)MipsKernIntr && pc < (vaddr_t)MipsUserIntr) {
(*printfn)("MipsKernIntr+%x: (%x, %x ,%x) -------\n",
- pc-(vaddr_t)MipsKernIntr, a0, a1, a2);
+ pc - (vaddr_t)MipsKernIntr, a0, a1, a2);
regs = (struct trap_frame *)(sp + STAND_ARG_SIZE);
a0 = kdbpeek(&regs->a0);
a1 = kdbpeek(&regs->a1);
@@ -1191,7 +1191,8 @@ loop:
Between((vaddr_t)a, pc, (vaddr_t)b)
/* check for bad PC */
- if (pc & 3 || pc < KSEG0_BASE || pc >= (unsigned)edata) {
+ if (pc & 3 || (!IS_XKPHYS(pc) && pc < KSEG0_BASE) ||
+ pc >= (vaddr_t)edata) {
(*printfn)("PC %p: not in kernel\n", pc);
ra = 0;
goto done;