From 826ff5f0606b303e9bac0b26adcc8acdffb4cdfd Mon Sep 17 00:00:00 2001 From: bjh21 Date: Wed, 27 Sep 2006 21:21:09 +0000 Subject: [PATCH] Make db_validate_address() work, even when called from within an interrupt handler. This should make debugging prefetch aborts slightly simpler. --- sys/arch/acorn26/acorn26/db_interface.c | 14 ++++++++++---- sys/arch/acorn26/acorn26/except.c | 25 +++++++++++++------------ sys/arch/acorn26/include/db_machdep.h | 4 +++- 3 files changed, 26 insertions(+), 17 deletions(-) diff --git a/sys/arch/acorn26/acorn26/db_interface.c b/sys/arch/acorn26/acorn26/db_interface.c index 215f75ab04a9..6c0aae1bbbd6 100644 --- a/sys/arch/acorn26/acorn26/db_interface.c +++ b/sys/arch/acorn26/acorn26/db_interface.c @@ -1,4 +1,4 @@ -/* $NetBSD: db_interface.c,v 1.9 2006/04/06 17:29:49 he Exp $ */ +/* $NetBSD: db_interface.c,v 1.10 2006/09/27 21:21:09 bjh21 Exp $ */ /* * Copyright (c) 1996 Scott K. Stevens @@ -35,7 +35,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.9 2006/04/06 17:29:49 he Exp $"); +__KERNEL_RCSID(0, "$NetBSD: db_interface.c,v 1.10 2006/09/27 21:21:09 bjh21 Exp $"); #include "opt_ddb.h" @@ -169,14 +169,20 @@ kdb_trap(type, regs) return (1); } +volatile boolean_t db_validating, db_faulted; int db_validate_address(addr) vm_offset_t addr; { + volatile uint8_t tmp; - /* FIXME */ - return 0; + db_faulted = FALSE; + db_validating = TRUE; + asm("" : : : "r14"); /* Make sure R14 is saved over the page fault */ + tmp = *(uint8_t *)addr; + db_validating = FALSE; + return db_faulted; } /* diff --git a/sys/arch/acorn26/acorn26/except.c b/sys/arch/acorn26/acorn26/except.c index 26f47292f6b1..73c291d0cc05 100644 --- a/sys/arch/acorn26/acorn26/except.c +++ b/sys/arch/acorn26/acorn26/except.c @@ -1,4 +1,4 @@ -/* $NetBSD: except.c,v 1.15 2006/09/24 23:38:59 bjh21 Exp $ */ +/* $NetBSD: except.c,v 1.16 2006/09/27 21:21:09 bjh21 Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 Ben Harris * All rights reserved. @@ -31,7 +31,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.15 2006/09/24 23:38:59 bjh21 Exp $"); +__KERNEL_RCSID(0, "$NetBSD: except.c,v 1.16 2006/09/27 21:21:09 bjh21 Exp $"); #include "opt_ddb.h" @@ -204,16 +204,11 @@ do_fault(struct trapframe *tf, struct lwp *l, if (pmap_fault(map->pmap, va, atype)) return; -#ifdef DDB if (current_intr_depth != 0) { - db_printf("Data abort in interrupt handler\n"); - kdb_trap(T_FAULT, tf); - } -#else - KASSERT(current_intr_depth == 0); -#endif - - error = uvm_fault(map, va, atype); + KASSERT((tf->tf_r15 & R15_MODE) != R15_MODE_USR); + error = EFAULT; + } else + error = uvm_fault(map, va, atype); if (error != 0) { ksiginfo_t ksi; @@ -225,7 +220,13 @@ do_fault(struct trapframe *tf, struct lwp *l, (register_t)cur_pcb->pcb_onfault; return; } - +#ifdef DDB + if (db_validating) { + db_faulted = TRUE; + tf->tf_r15 += INSN_SIZE; + return; + } +#endif if ((tf->tf_r15 & R15_MODE) != R15_MODE_USR) { #ifdef DDB db_printf("Unhandled data abort in kernel mode\n"); diff --git a/sys/arch/acorn26/include/db_machdep.h b/sys/arch/acorn26/include/db_machdep.h index 4a6c0f9639d0..f47a90116ae7 100644 --- a/sys/arch/acorn26/include/db_machdep.h +++ b/sys/arch/acorn26/include/db_machdep.h @@ -1,4 +1,4 @@ -/* $NetBSD: db_machdep.h,v 1.3 2005/12/11 12:16:04 christos Exp $ */ +/* $NetBSD: db_machdep.h,v 1.4 2006/09/27 21:21:09 bjh21 Exp $ */ #include @@ -11,3 +11,5 @@ void db_show_panic_cmd __P((db_expr_t, int, db_expr_t, const char *)); void db_show_frame_cmd __P((db_expr_t, int, db_expr_t, const char *)); void db_bus_write_cmd __P((db_expr_t, int, db_expr_t, const char *)); void db_irqstat_cmd __P((db_expr_t, int, db_expr_t, const char *)); + +extern volatile boolean_t db_validating, db_faulted;