Source-Changes-HG archive

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

[src/trunk]: src Do not allow disabling interrupts on the primary CPU. Fixes ...



details:   https://anonhg.NetBSD.org/src/rev/c0a808511745
branches:  trunk
changeset: 1011847:c0a808511745
user:      jruoho <jruoho%NetBSD.org@localhost>
date:      Mon Jul 13 13:16:07 2020 +0000

description:
Do not allow disabling interrupts on the primary CPU. Fixes PR kern/45117.

diffstat:

 sys/kern/kern_cpu.c               |  10 +++++++---
 tests/usr.sbin/cpuctl/t_cpuctl.sh |  14 ++++++++++----
 2 files changed, 17 insertions(+), 7 deletions(-)

diffs (73 lines):

diff -r 2e061d259f25 -r c0a808511745 sys/kern/kern_cpu.c
--- a/sys/kern/kern_cpu.c       Mon Jul 13 12:56:58 2020 +0000
+++ b/sys/kern/kern_cpu.c       Mon Jul 13 13:16:07 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: kern_cpu.c,v 1.91 2020/05/28 20:29:18 ad Exp $ */
+/*     $NetBSD: kern_cpu.c,v 1.92 2020/07/13 13:16:07 jruoho Exp $     */
 
 /*-
  * Copyright (c) 2007, 2008, 2009, 2010, 2012, 2019 The NetBSD Foundation, Inc.
@@ -60,7 +60,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.91 2020/05/28 20:29:18 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_cpu.c,v 1.92 2020/07/13 13:16:07 jruoho Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_cpu_ucode.h"
@@ -212,7 +212,9 @@
                        error = ESRCH;
                        break;
                }
-               cpu_setintr(ci, cs->cs_intr);
+               error = cpu_setintr(ci, cs->cs_intr);
+               if (error)
+                       break;
                error = cpu_setstate(ci, cs->cs_online);
                break;
 
@@ -490,6 +492,8 @@
                        return 0;
                func = (xcfunc_t)cpu_xc_intr;
        } else {
+               if (CPU_IS_PRIMARY(ci))
+                       return EINVAL;
                if ((spc->spc_flags & SPCF_NOINTR) != 0)
                        return 0;
                /*
diff -r 2e061d259f25 -r c0a808511745 tests/usr.sbin/cpuctl/t_cpuctl.sh
--- a/tests/usr.sbin/cpuctl/t_cpuctl.sh Mon Jul 13 12:56:58 2020 +0000
+++ b/tests/usr.sbin/cpuctl/t_cpuctl.sh Mon Jul 13 13:16:07 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: t_cpuctl.sh,v 1.3 2020/06/25 15:43:26 jruoho Exp $
+# $NetBSD: t_cpuctl.sh,v 1.4 2020/07/13 13:16:07 jruoho Exp $
 #
 # Copyright (c) 2020 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -37,9 +37,6 @@
                atf_pass
        fi
 
-       # Skip the boot processor. Disabling interrupts
-       # on it will hang the system (PR kern/45117).
-       #
        while [ $ncpu -gt 1 ]; do
 
                cpuid=$(expr $ncpu - 1)
@@ -51,6 +48,15 @@
 
                ncpu=$(expr $ncpu - 1)
        done
+
+       # Additional check that interrupts cannot be
+       # disabled for the primary CPU (PR kern/45117).
+       #
+       cpuctl nointr 0 >/dev/null 2>&1
+
+       if [ $? -eq 0 ]; then
+               $2 $3
+       fi
 }
 
 clean() {



Home | Main Index | Thread Index | Old Index