kmsan: Add corresponding sysctl knob for loader tunable

The loader tunable 'debug.kmsan.disabled' does not have corresponding
sysctl MIB entry. Add it so that it can be retrieved, and `sysctl -T`
will also report it correctly.

Reviewed by:	markj
MFC after:	1 week
Differential Revision:	https://reviews.freebsd.org/D42138

(cherry picked from commit 1d2b743784f7527a6840fe35ddb7e34cd41bc17a)
This commit is contained in:
Zhenlei Huang 2023-10-12 18:14:49 +08:00
parent 6f8ef4d6e4
commit 1b289728e9

View file

@ -108,15 +108,13 @@ static uint8_t msan_dummy_shad[PAGE_SIZE] __aligned(PAGE_SIZE);
static uint8_t msan_dummy_write_shad[PAGE_SIZE] __aligned(PAGE_SIZE);
static uint8_t msan_dummy_orig[PAGE_SIZE] __aligned(PAGE_SIZE);
static msan_td_t msan_thread0;
static bool kmsan_enabled __read_mostly;
static bool kmsan_reporting = false;
/*
* Avoid clobbering any thread-local state before we panic.
*/
#define kmsan_panic(f, ...) do { \
kmsan_enabled = false; \
kmsan_disabled = true; \
panic(f, __VA_ARGS__); \
} while (0)
@ -142,6 +140,11 @@ SYSCTL_BOOL(_debug_kmsan, OID_AUTO, panic_on_violation, CTLFLAG_RWTUN,
&panic_on_violation, 0,
"Panic if an invalid access is detected");
static bool kmsan_disabled __read_mostly = true;
#define kmsan_enabled (!kmsan_disabled)
SYSCTL_BOOL(_debug_kmsan, OID_AUTO, disabled, CTLFLAG_RDTUN | CTLFLAG_NOFETCH,
&kmsan_disabled, 0, "KMSAN is disabled");
static MALLOC_DEFINE(M_KMSAN, "kmsan", "Kernel memory sanitizer");
/* -------------------------------------------------------------------------- */
@ -599,7 +602,7 @@ kmsan_init(void)
thread0.td_kmsan = &msan_thread0;
/* Now officially enabled. */
kmsan_enabled = true;
kmsan_disabled = false;
}
/* -------------------------------------------------------------------------- */