From: pirofti Date: Fri, 5 Jan 2018 11:10:25 +0000 (+0000) Subject: Show uvm_fault and trace when typing show panic on a page fault'd kernel X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=c1088d887145f4cbb30e3a16e1cf9081a6cd9e1b;p=openbsd Show uvm_fault and trace when typing show panic on a page fault'd kernel Currently there is only support for amd64, if this change settles I will add support for the rest of the architectures. OK kettenis@. --- diff --git a/sys/arch/amd64/amd64/trap.c b/sys/arch/amd64/amd64/trap.c index 96565bd738d..47b3bee5128 100644 --- a/sys/arch/amd64/amd64/trap.c +++ b/sys/arch/amd64/amd64/trap.c @@ -1,4 +1,4 @@ -/* $OpenBSD: trap.c,v 1.62 2017/10/14 04:44:43 jsg Exp $ */ +/* $OpenBSD: trap.c,v 1.63 2018/01/05 11:10:25 pirofti Exp $ */ /* $NetBSD: trap.c,v 1.2 2003/05/04 23:51:56 fvdl Exp $ */ /*- @@ -380,12 +380,16 @@ faultcommon: } if (type == T_PAGEFLT) { + static char faultbuf[512]; if (pcb->pcb_onfault != 0) { KERNEL_UNLOCK(); goto copyfault; } - printf("uvm_fault(%p, 0x%lx, 0, %d) -> %x\n", + snprintf(faultbuf, sizeof faultbuf, + "uvm_fault(%p, 0x%lx, 0, %d) -> %x", map, fa, ftype, error); + printf("%s\n", faultbuf); + faultstr = faultbuf; goto we_re_toast; } diff --git a/sys/ddb/db_command.c b/sys/ddb/db_command.c index cd4cd40b714..a275023dc58 100644 --- a/sys/ddb/db_command.c +++ b/sys/ddb/db_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: db_command.c,v 1.82 2017/12/13 08:34:04 mpi Exp $ */ +/* $OpenBSD: db_command.c,v 1.83 2018/01/05 11:10:25 pirofti Exp $ */ /* $NetBSD: db_command.c,v 1.20 1996/03/30 22:30:05 christos Exp $ */ /* @@ -51,6 +51,7 @@ #include #include #include +#include #include #include #include @@ -491,6 +492,11 @@ db_show_panic_cmd(db_expr_t addr, int have_addr, db_expr_t count, char *modif) { if (panicstr) db_printf("%s\n", panicstr); + else if (faultstr) { + db_printf("kernel page fault\n"); + db_printf("%s\n", faultstr); + db_stack_trace_print(addr, have_addr, 1, modif, db_printf); + } else db_printf("the kernel did not panic\n"); /* yet */ } diff --git a/sys/kern/subr_prf.c b/sys/kern/subr_prf.c index bb527c5ba15..3572e809d09 100644 --- a/sys/kern/subr_prf.c +++ b/sys/kern/subr_prf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: subr_prf.c,v 1.92 2017/12/30 20:47:00 guenther Exp $ */ +/* $OpenBSD: subr_prf.c,v 1.93 2018/01/05 11:10:25 pirofti Exp $ */ /* $NetBSD: subr_prf.c,v 1.45 1997/10/24 18:14:25 chuck Exp $ */ /*- @@ -99,6 +99,7 @@ struct mutex kprintf_mutex = extern int log_open; /* subr_log: is /dev/klog open? */ const char *panicstr; /* arg to first call to panic (used as a flag to indicate that panic has already been called). */ +const char *faultstr; /* page fault string */ #ifdef DDB /* * Enter ddb on panic. diff --git a/sys/sys/systm.h b/sys/sys/systm.h index 04326d9db38..5fa3b80b177 100644 --- a/sys/sys/systm.h +++ b/sys/sys/systm.h @@ -1,4 +1,4 @@ -/* $OpenBSD: systm.h,v 1.136 2017/12/14 00:41:58 dlg Exp $ */ +/* $OpenBSD: systm.h,v 1.137 2018/01/05 11:10:25 pirofti Exp $ */ /* $NetBSD: systm.h,v 1.50 1996/06/09 04:55:09 briggs Exp $ */ /*- @@ -72,6 +72,7 @@ */ extern int securelevel; /* system security level */ extern const char *panicstr; /* panic message */ +extern const char *faultstr; /* fault message */ extern const char version[]; /* system version */ extern const char copyright[]; /* system copyright */ extern const char ostype[];