Module Name:    src
Committed By:   riastradh
Date:           Tue Aug 16 10:24:17 UTC 2022

Modified Files:
        src/sys/kern: kern_crashme.c

Log Message:
crashme(9): New kernel_lock_spinout crasher.

This assumes that something will eventually try to take the kernel
lock and, after spinning for a while, spin out and crash -- so for
now it's only enabled under LOCKDEBUG, without which the kernel lock
spins forever.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/kern/kern_crashme.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_crashme.c
diff -u src/sys/kern/kern_crashme.c:1.5 src/sys/kern/kern_crashme.c:1.6
--- src/sys/kern/kern_crashme.c:1.5	Sat Nov 27 14:11:14 2021
+++ src/sys/kern/kern_crashme.c	Tue Aug 16 10:24:17 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_crashme.c,v 1.5 2021/11/27 14:11:14 riastradh Exp $	*/
+/*	$NetBSD: kern_crashme.c,v 1.6 2022/08/16 10:24:17 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2018, 2019 Matthew R. Green
@@ -63,6 +63,9 @@ static int crashme_null_jump(int);
 #ifdef DDB
 static int crashme_ddb(int);
 #endif
+#ifdef LOCKDEBUG
+static int crashme_kernel_lock_spinout(int);
+#endif
 
 #define CMNODE(name, lname, func)	\
     {					\
@@ -78,6 +81,10 @@ static crashme_node nodes[] = {
 #ifdef DDB
     CMNODE("ddb", "enter ddb directly", crashme_ddb),
 #endif
+#ifdef LOCKDEBUG
+    CMNODE("kernel_lock_spinout", "infinite kernel lock",
+	crashme_kernel_lock_spinout),
+#endif
 };
 static crashme_node *first_node;
 static kmutex_t crashme_lock;
@@ -270,3 +277,16 @@ crashme_ddb(int flags)
 	return 0;
 }
 #endif
+
+#ifdef LOCKDEBUG
+static int
+crashme_kernel_lock_spinout(int flags)
+{
+
+	KERNEL_LOCK(1, NULL);
+	for (;;)
+		__insn_barrier();
+	KERNEL_UNLOCK_ONE(NULL);
+	return 0;
+}
+#endif

Reply via email to