From 891c64630d15ad1272ad72eb3542fd8de4345080 Mon Sep 17 00:00:00 2001 From: Paul Saab Date: Sun, 19 Mar 2000 14:55:42 +0000 Subject: [PATCH] Make SPLASSERT sysctl and boot time tunable with kern.splassertmode. The following values are understood: 0 (ignore), 1 (log), and 2 (panic). The default value is 1. Reviewed by: peter --- sys/alpha/alpha/ipl_funcs.c | 36 +++++++++++++++++++++++++++++++++++- sys/i386/isa/ipl_funcs.c | 36 +++++++++++++++++++++++++++++++++++- 2 files changed, 70 insertions(+), 2 deletions(-) diff --git a/sys/alpha/alpha/ipl_funcs.c b/sys/alpha/alpha/ipl_funcs.c index ea4154ac4680..fd6f86e822e2 100644 --- a/sys/alpha/alpha/ipl_funcs.c +++ b/sys/alpha/alpha/ipl_funcs.c @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -166,6 +168,38 @@ GENSET(schedsoftvm, &idelayed, 1 << SWI_VM) GENSET(schedsoftclock, &idelayed, 1 << SWI_CLOCK) #ifdef INVARIANT_SUPPORT + +#define SPLASSERT_IGNORE 0 +#define SPLASSERT_LOG 1 +#define SPLASSERT_PANIC 2 + +static int splassertmode = SPLASSERT_LOG; +SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW, + &splassertmode, 0, "Set the mode of SPLASSERT"); + +static void +init_splassertmode(void *ignored) +{ + TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode); +} +SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL); + +static void +splassertfail(char *str, const char *msg, char *name, int level) +{ + switch (splassertmode) { + case SPLASSERT_IGNORE: + break; + case SPLASSERT_LOG: + printf(str, msg, name, level); + printf("\n"); + break; + case SPLASSERT_PANIC: + panic(str, msg, name, level); + break; + } +} + #define GENSPLASSERT(name, pri) \ void \ name##assert(const char *msg) \ @@ -174,7 +208,7 @@ name##assert(const char *msg) \ \ cpl = getcpl(); \ if (cpl < ALPHA_PSL_IPL_##pri); \ - panic("%s: not %s, cpl == %#x", \ + splassertfail("%s: not %s, cpl == %#x", \ msg, __XSTRING(name) + 3, cpl); \ } #else diff --git a/sys/i386/isa/ipl_funcs.c b/sys/i386/isa/ipl_funcs.c index 13a0743ac114..d7ba1c4b9653 100644 --- a/sys/i386/isa/ipl_funcs.c +++ b/sys/i386/isa/ipl_funcs.c @@ -28,6 +28,8 @@ #include #include +#include +#include #include #include #include @@ -66,12 +68,44 @@ softclockpending(void) } #ifdef INVARIANT_SUPPORT + +#define SPLASSERT_IGNORE 0 +#define SPLASSERT_LOG 1 +#define SPLASSERT_PANIC 2 + +static int splassertmode = SPLASSERT_LOG; +SYSCTL_INT(_kern, OID_AUTO, splassertmode, CTLFLAG_RW, + &splassertmode, 0, "Set the mode of SPLASSERT"); + +static void +init_splassertmode(void *ignored) +{ + TUNABLE_INT_FETCH("kern.splassertmode", 0, splassertmode); +} +SYSINIT(param, SI_SUB_TUNABLES, SI_ORDER_ANY, init_splassertmode, NULL); + +static void +splassertfail(char *str, const char *msg, char *name, int level) +{ + switch (splassertmode) { + case SPLASSERT_IGNORE: + break; + case SPLASSERT_LOG: + printf(str, msg, name, level); + printf("\n"); + break; + case SPLASSERT_PANIC: + panic(str, msg, name, level); + break; + } +} + #define GENSPLASSERT(NAME, MODIFIER) \ void \ NAME##assert(const char *msg) \ { \ if ((cpl & (MODIFIER)) != (MODIFIER)) \ - panic("%s: not %s, cpl == %#x", \ + splassertfail("%s: not %s, cpl == %#x", \ msg, __XSTRING(NAME) + 3, cpl); \ } #else