summaryrefslogtreecommitdiffstats
path: root/sys/kern/subr_kdb.c
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2006-06-18 12:27:59 +0000
committeryar <yar@FreeBSD.org>2006-06-18 12:27:59 +0000
commit0bf54ce0e0f19078ff8df34ba903149d79f09219 (patch)
tree2d9e655fafe1e071c856b352e0f6c982afc4443e /sys/kern/subr_kdb.c
parentf41df61805651b337adac08fd998ece671442169 (diff)
downloadFreeBSD-src-0bf54ce0e0f19078ff8df34ba903149d79f09219.zip
FreeBSD-src-0bf54ce0e0f19078ff8df34ba903149d79f09219.tar.gz
Add a funny sysctl: debug.kdb.trap_code .
It is similar to debug.kdb.trap, except for it tries to cause a page fault via a call to an invalid pointer. This can highlight differences between a fault on data access vs. a fault on code call some CPUs might have. This appeared as a test for a work \ Sponsored by: RiNet (Cronyx Plus LLC)
Diffstat (limited to 'sys/kern/subr_kdb.c')
-rw-r--r--sys/kern/subr_kdb.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/sys/kern/subr_kdb.c b/sys/kern/subr_kdb.c
index 6b2be99..4b2991c 100644
--- a/sys/kern/subr_kdb.c
+++ b/sys/kern/subr_kdb.c
@@ -62,6 +62,7 @@ static int kdb_sysctl_current(SYSCTL_HANDLER_ARGS);
static int kdb_sysctl_enter(SYSCTL_HANDLER_ARGS);
static int kdb_sysctl_panic(SYSCTL_HANDLER_ARGS);
static int kdb_sysctl_trap(SYSCTL_HANDLER_ARGS);
+static int kdb_sysctl_trap_code(SYSCTL_HANDLER_ARGS);
SYSCTL_NODE(_debug, OID_AUTO, kdb, CTLFLAG_RW, NULL, "KDB nodes");
@@ -78,7 +79,10 @@ SYSCTL_PROC(_debug_kdb, OID_AUTO, panic, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
kdb_sysctl_panic, "I", "set to panic the kernel");
SYSCTL_PROC(_debug_kdb, OID_AUTO, trap, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
- kdb_sysctl_trap, "I", "set cause a page fault");
+ kdb_sysctl_trap, "I", "set to cause a page fault via data access");
+
+SYSCTL_PROC(_debug_kdb, OID_AUTO, trap_code, CTLTYPE_INT | CTLFLAG_RW, 0, 0,
+ kdb_sysctl_trap_code, "I", "set to cause a page fault via code access");
/*
* Flag indicating whether or not to IPI the other CPUs to stop them on
@@ -195,6 +199,23 @@ kdb_sysctl_trap(SYSCTL_HANDLER_ARGS)
return (*addr);
}
+static int
+kdb_sysctl_trap_code(SYSCTL_HANDLER_ARGS)
+{
+ int error, i;
+ void (*fp)(u_int, u_int, u_int) = (void *)0xdeadc0de;
+
+ error = sysctl_wire_old_buffer(req, sizeof(int));
+ if (error == 0) {
+ i = 0;
+ error = sysctl_handle_int(oidp, &i, 0, req);
+ }
+ if (error != 0 || req->newptr == NULL)
+ return (error);
+ (*fp)(0x11111111, 0x22222222, 0x33333333);
+ return (0);
+}
+
/*
* Solaris implements a new BREAK which is initiated by a character sequence
* CR ~ ^b which is similar to a familiar pattern used on Sun servers by the
OpenPOWER on IntegriCloud