summaryrefslogtreecommitdiff
path: root/sys/arch/mips64
diff options
context:
space:
mode:
authorMiod Vallat <miod@cvs.openbsd.org>2010-01-18 16:57:47 +0000
committerMiod Vallat <miod@cvs.openbsd.org>2010-01-18 16:57:47 +0000
commit2f93ee5e4fdcf08bf7c7ba70572362b5f4cb8524 (patch)
treedbe24da428d03ad4416cfbf7c65d1a8b2523fe96 /sys/arch/mips64
parentb0d04eb64e0162350db0b6423097cdda3aabb170 (diff)
Make trapdebug code MP-safe.
Diffstat (limited to 'sys/arch/mips64')
-rw-r--r--sys/arch/mips64/include/trap.h54
-rw-r--r--sys/arch/mips64/mips64/interrupt.c4
-rw-r--r--sys/arch/mips64/mips64/trap.c57
3 files changed, 63 insertions, 52 deletions
diff --git a/sys/arch/mips64/include/trap.h b/sys/arch/mips64/include/trap.h
index 9cbfd10297a..c1533aace1f 100644
--- a/sys/arch/mips64/include/trap.h
+++ b/sys/arch/mips64/include/trap.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.h,v 1.11 2009/11/12 19:45:53 miod Exp $ */
+/* $OpenBSD: trap.h,v 1.12 2010/01/18 16:57:44 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -84,40 +84,44 @@
#if defined(DDB) || defined(DEBUG)
struct trapdebug { /* trap history buffer for debugging */
- u_int status;
- u_int cause;
- u_long vadr;
- u_long pc;
- u_long ra;
- u_long sp;
+ uint32_t status;
+ uint32_t cause;
+ register_t vadr;
+ register_t pc;
+ register_t ra;
+ register_t sp;
u_int code;
u_int ipl;
};
-#define trapdebug_enter(x, cd) { \
- u_int32_t __s = disableintr(); \
- trp->status = x->sr; \
- trp->cause = x->cause; \
- trp->vadr = x->badvaddr; \
- trp->pc = x->pc; \
- trp->sp = x->sp; \
- trp->ra = x->ra; \
- trp->ipl = x->ipl; \
- trp->code = cd; \
- if (++trp == &trapdebug[TRAPSIZE]) \
- trp = trapdebug; \
- setsr(__s); \
- }
+#define trapdebug_enter(ci, frame, cd) \
+do { \
+ uint32_t sr = disableintr(); \
+ u_long cpuid = ci->ci_cpuid; \
+ struct trapdebug *t; \
+ \
+ t = trapdebug + TRAPSIZE * cpuid + trppos[cpuid]; \
+ t->status = frame->sr; \
+ t->cause = frame->cause; \
+ t->vadr = frame->badvaddr; \
+ t->pc = frame->pc; \
+ t->sp = frame->sp; \
+ t->ra = frame->ra; \
+ t->ipl = frame->ipl; \
+ t->code = cd; \
+ if (++trppos[cpuid] == TRAPSIZE) \
+ trppos[cpuid] = 0; \
+ setsr(sr); \
+} while (0)
#define TRAPSIZE 10 /* Trap log buffer length */
-extern struct trapdebug trapdebug[TRAPSIZE], *trp;
+extern struct trapdebug trapdebug[MAXCPUS * TRAPSIZE];
+extern uint trppos[MAXCPUS];
void trapDump(char *msg);
#else
-
-#define trapdebug_enter(x, y)
-
+#define trapdebug_enter(ci, frame, code)
#endif
#endif /* _LOCORE */
diff --git a/sys/arch/mips64/mips64/interrupt.c b/sys/arch/mips64/mips64/interrupt.c
index 89030cf5d60..588fad00961 100644
--- a/sys/arch/mips64/mips64/interrupt.c
+++ b/sys/arch/mips64/mips64/interrupt.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: interrupt.c,v 1.56 2010/01/09 23:43:43 miod Exp $ */
+/* $OpenBSD: interrupt.c,v 1.57 2010/01/18 16:57:46 miod Exp $ */
/*
* Copyright (c) 2001-2004 Opsycon AB (www.opsycon.se / www.opsycon.com)
@@ -114,7 +114,7 @@ interrupt(struct trap_frame *trapframe)
ci->ci_intrdepth++;
#ifdef DEBUG_INTERRUPT
- trapdebug_enter(trapframe, 0);
+ trapdebug_enter(ci, trapframe, T_INT);
#endif
atomic_add_int(&uvmexp.intrs, 1);
diff --git a/sys/arch/mips64/mips64/trap.c b/sys/arch/mips64/mips64/trap.c
index 3c1f4244afd..e49cc225546 100644
--- a/sys/arch/mips64/mips64/trap.c
+++ b/sys/arch/mips64/mips64/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.60 2010/01/16 23:28:10 miod Exp $ */
+/* $OpenBSD: trap.c,v 1.61 2010/01/18 16:57:46 miod Exp $ */
/*
* Copyright (c) 1988 University of Utah.
@@ -124,7 +124,8 @@ const char *trap_type[] = {
};
#if defined(DDB) || defined(DEBUG)
-struct trapdebug trapdebug[TRAPSIZE], *trp = trapdebug;
+struct trapdebug trapdebug[MAXCPUS * TRAPSIZE];
+uint trppos[MAXCPUS];
void stacktrace(struct trap_frame *);
uint32_t kdbpeek(vaddr_t);
@@ -186,19 +187,19 @@ ast()
* pcb_onfault is set, otherwise, return old pc.
*/
void
-trap(trapframe)
- struct trap_frame *trapframe;
+trap(struct trap_frame *trapframe)
{
+ struct cpu_info *ci = curcpu();
int type, i;
unsigned ucode = 0;
- struct proc *p = curproc;
+ struct proc *p = ci->ci_curproc;
vm_prot_t ftype;
extern vaddr_t onfault_table[];
int onfault;
int typ = 0;
union sigval sv;
- trapdebug_enter(trapframe, -1);
+ trapdebug_enter(ci, trapframe, -1);
type = (trapframe->cause & CR_EXC_CODE) >> CR_EXC_CODE_SHIFT;
if (USERMODE(trapframe->sr)) {
@@ -541,10 +542,8 @@ printf("SIG-BUSB @%p pc %p, ra %p\n", trapframe->badvaddr, trapframe->pc, trapfr
rval[0] = 0;
rval[1] = locr0->v1;
#if defined(DDB) || defined(DEBUG)
- if (trp == trapdebug)
- trapdebug[TRAPSIZE - 1].code = code;
- else
- trp[-1].code = code;
+ trapdebug[TRAPSIZE * ci->ci_cpuid + (trppos[ci->ci_cpuid] == 0 ?
+ TRAPSIZE : trppos[ci->ci_cpuid]) - 1].code = code;
#endif
#if NSYSTRACE > 0
@@ -860,29 +859,37 @@ void
trapDump(msg)
char *msg;
{
+#ifdef MULTIPROCESSOR
+ CPU_INFO_ITERATOR cii;
+#endif
+ struct cpu_info *ci;
struct trapdebug *ptrp;
int i;
int s;
s = splhigh();
- ptrp = trp;
printf("trapDump(%s)\n", msg);
- for (i = 0; i < TRAPSIZE; i++) {
- if (ptrp == trapdebug) {
- ptrp = &trapdebug[TRAPSIZE - 1];
- }
- else {
- ptrp--;
- }
-
- if (ptrp->cause == 0)
- break;
+#ifndef MULTIPROCESSOR
+ ci = curcpu();
+#else
+ CPU_INFO_FOREACH(cii, ci)
+#endif
+ {
+ /* walk in reverse order */
+ for (i = TRAPSIZE - 1; i >= 0; i--) {
+ ptrp = trapdebug + ci->ci_cpuid * TRAPSIZE;
+ ptrp += (trppos[ci->ci_cpuid] + i) % TRAPSIZE;
- printf("%s: PC %p CR 0x%x SR 0x%x\n",
- trap_type[(ptrp->cause & CR_EXC_CODE) >> CR_EXC_CODE_SHIFT],
- ptrp->pc, ptrp->cause, ptrp->status);
+ if (ptrp->cause == 0)
+ break;
- printf(" RA %p SP %p ADR %p\n", ptrp->ra, ptrp->sp, ptrp->vadr);
+ printf("%s: PC %p CR 0x%08x SR 0x%08x\n",
+ trap_type[(ptrp->cause & CR_EXC_CODE) >>
+ CR_EXC_CODE_SHIFT],
+ ptrp->pc, ptrp->cause, ptrp->status);
+ printf(" RA %p SP %p ADR %p\n",
+ ptrp->ra, ptrp->sp, ptrp->vadr);
+ }
}
splx(s);