Module Name:    src
Committed By:   riastradh
Date:           Sat Mar 12 15:50:45 UTC 2022

Modified Files:
        src/sys/arch/x86/include: intr.h
        src/sys/arch/x86/x86: intr.c

Log Message:
x86: Check for biglock leakage in interrupt handlers.


To generate a diff of this commit:
cvs rdiff -u -r1.62 -r1.63 src/sys/arch/x86/include/intr.h
cvs rdiff -u -r1.159 -r1.160 src/sys/arch/x86/x86/intr.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/arch/x86/include/intr.h
diff -u src/sys/arch/x86/include/intr.h:1.62 src/sys/arch/x86/include/intr.h:1.63
--- src/sys/arch/x86/include/intr.h:1.62	Sat Apr 25 15:26:18 2020
+++ src/sys/arch/x86/include/intr.h	Sat Mar 12 15:50:44 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.h,v 1.62 2020/04/25 15:26:18 bouyer Exp $	*/
+/*	$NetBSD: intr.h,v 1.63 2022/03/12 15:50:44 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 1998, 2001, 2006, 2007, 2008, 2019 The NetBSD Foundation, Inc.
@@ -145,6 +145,7 @@ struct intrhand {
 	struct	intrhand *ih_evt_next;
 #endif
 	struct cpu_info *ih_cpu;
+	char	ih_xname[INTRDEVNAMEBUF];
 };
 
 #define IMASK(ci,level) (ci)->ci_imask[(level)]

Index: src/sys/arch/x86/x86/intr.c
diff -u src/sys/arch/x86/x86/intr.c:1.159 src/sys/arch/x86/x86/intr.c:1.160
--- src/sys/arch/x86/x86/intr.c:1.159	Thu Dec 23 02:45:43 2021
+++ src/sys/arch/x86/x86/intr.c	Sat Mar 12 15:50:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: intr.c,v 1.159 2021/12/23 02:45:43 yamaguchi Exp $	*/
+/*	$NetBSD: intr.c,v 1.160 2022/03/12 15:50:45 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2007, 2008, 2009, 2019 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.159 2021/12/23 02:45:43 yamaguchi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.160 2022/03/12 15:50:45 riastradh Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -653,11 +653,16 @@ static int
 intr_biglock_wrapper(void *vp)
 {
 	struct intrhand *ih = vp;
+	int locks;
 	int ret;
 
 	KERNEL_LOCK(1, NULL);
 
+	locks = curcpu()->ci_biglock_count;
 	ret = (*ih->ih_realfun)(ih->ih_realarg);
+	KASSERTMSG(locks == curcpu()->ci_biglock_count,
+	    "%s @ %p slipped locks %d -> %d",
+	    ih->ih_xname, ih->ih_realfun, locks, curcpu()->ci_biglock_count);
 
 	KERNEL_UNLOCK_ONE(NULL);
 
@@ -904,6 +909,7 @@ intr_establish_xname(int legacy_irq, str
 	ih->ih_pin = pin;
 	ih->ih_cpu = ci;
 	ih->ih_slot = slot;
+	strlcpy(ih->ih_xname, xname, sizeof(ih->ih_xname));
 #ifdef MULTIPROCESSOR
 	if (!mpsafe) {
 		ih->ih_fun = intr_biglock_wrapper;

Reply via email to