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 Fix "intrctl list" causes panic while attac...



details:   https://anonhg.NetBSD.org/src/rev/a6c941c67704
branches:  trunk
changeset: 321595:a6c941c67704
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Mon Mar 26 02:30:08 2018 +0000

description:
Fix "intrctl list" causes panic while attaching MSI/MSI-X devices.

When there are devices which is already pci_intr_alloc'ed, however is not
established yet, "intrctl list" causes panic. E.g.
    # while true; do intrctl list > /dev/null ; done&
    # drvctl -d ixg0 && drvctl -r pci0

And add some KASSERTMSG to similar but not the same code.

Pointed out by msaitoh@n.o.

XXX pullup-8

diffstat:

 sys/arch/x86/x86/intr.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (52 lines):

diff -r 8f8dea975628 -r a6c941c67704 sys/arch/x86/x86/intr.c
--- a/sys/arch/x86/x86/intr.c   Sun Mar 25 18:56:01 2018 +0000
+++ b/sys/arch/x86/x86/intr.c   Mon Mar 26 02:30:08 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: intr.c,v 1.123 2018/02/17 18:51:53 maxv Exp $  */
+/*     $NetBSD: intr.c,v 1.124 2018/03/26 02:30:08 knakahara Exp $     */
 
 /*
  * Copyright (c) 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -133,7 +133,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.123 2018/02/17 18:51:53 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: intr.c,v 1.124 2018/03/26 02:30:08 knakahara Exp $");
 
 #include "opt_intrdebug.h"
 #include "opt_multiprocessor.h"
@@ -2012,6 +2012,9 @@
                return;
        }
 
+       KASSERTMSG(isp->is_handlers != NULL,
+           "Don't get affinity for the device which is not established.");
+
        ci = isp->is_handlers->ih_cpu;
        if (ci == NULL) {
                kcpuset_zero(cpuset);
@@ -2064,6 +2067,9 @@
        }
 
        ih = isp->is_handlers;
+       KASSERTMSG(ih != NULL,
+           "Don't set affinity for the device which is not established.");
+
        oldci = ih->ih_cpu;
        if (newci == oldci) /* nothing to do */
                return 0;
@@ -2130,6 +2136,13 @@
 
        KASSERT(mutex_owned(&cpu_lock));
 
+       /*
+        * The device is already pci_intr_alloc'ed, however it is not
+        * established yet.
+        */
+       if (isp->is_handlers == NULL)
+               return false;
+
        ci = isp->is_handlers->ih_cpu;
        KASSERT(ci != NULL);
 



Home | Main Index | Thread Index | Old Index