Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/x86 x86: Check for biglock leakage in interrupt han...



details:   https://anonhg.NetBSD.org/src/rev/95676a297f80
branches:  trunk
changeset: 363432:95676a297f80
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sat Mar 12 15:50:44 2022 +0000

description:
x86: Check for biglock leakage in interrupt handlers.

diffstat:

 sys/arch/x86/include/intr.h |   3 ++-
 sys/arch/x86/x86/intr.c     |  10 ++++++++--
 2 files changed, 10 insertions(+), 3 deletions(-)

diffs (60 lines):

diff -r 27a824b37977 -r 95676a297f80 sys/arch/x86/include/intr.h
--- a/sys/arch/x86/include/intr.h       Sat Mar 12 15:36:53 2022 +0000
+++ b/sys/arch/x86/include/intr.h       Sat Mar 12 15:50:44 2022 +0000
@@ -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 *ih_evt_next;
 #endif
        struct cpu_info *ih_cpu;
+       char    ih_xname[INTRDEVNAMEBUF];
 };
 
 #define IMASK(ci,level) (ci)->ci_imask[(level)]
diff -r 27a824b37977 -r 95676a297f80 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sat Mar 12 15:36:53 2022 +0000
+++ b/sys/arch/x86/x86/intr.c   Sat Mar 12 15:50:44 2022 +0000
@@ -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 @@
 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 @@
        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;



Home | Main Index | Thread Index | Old Index