Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 24 Oct 2023 14:37:43 GMT
From:      Zhenlei Huang <zlei@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 8cb6243c3085 - releng/14.0 - kmsan: Add corresponding sysctl knob for loader tunable
Message-ID:  <202310241437.39OEbhvV089543@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch releng/14.0 has been updated by zlei:

URL: https://cgit.FreeBSD.org/src/commit/?id=8cb6243c3085b43e82096c775d8059ca61461318

commit 8cb6243c3085b43e82096c775d8059ca61461318
Author:     Zhenlei Huang <zlei@FreeBSD.org>
AuthorDate: 2023-10-12 10:14:49 +0000
Commit:     Zhenlei Huang <zlei@FreeBSD.org>
CommitDate: 2023-10-24 14:35:51 +0000

    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
    Approved by:    re (gjb)
    MFC after:      1 week
    Differential Revision:  https://reviews.freebsd.org/D42138
    
    (cherry picked from commit 1d2b743784f7527a6840fe35ddb7e34cd41bc17a)
    (cherry picked from commit 1b289728e93d1000e6ca03354c8bc4209ea8da51)
---
 sys/kern/subr_msan.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/sys/kern/subr_msan.c b/sys/kern/subr_msan.c
index 57caeb454b42..54948370a14a 100644
--- a/sys/kern/subr_msan.c
+++ b/sys/kern/subr_msan.c
@@ -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;
 }
 
 /* -------------------------------------------------------------------------- */



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202310241437.39OEbhvV089543>