mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-11 14:10:34 +00:00
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)
This commit is contained in:
parent
8411d000a1
commit
42ccd54fec
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=159726
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user