Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/arm Fix racy softint dispatch that lead to KASSERT(...



details:   https://anonhg.NetBSD.org/src/rev/7a557d16c793
branches:  trunk
changeset: 780217:7a557d16c793
user:      skrll <skrll%NetBSD.org@localhost>
date:      Mon Jul 16 06:26:43 2012 +0000

description:
Fix racy softint dispatch that lead to KASSERT(si->si_active) in
softint_execute

Discussed with matt@. "Looks good to me"

diffstat:

 sys/arch/arm/arm32/arm32_machdep.c |  17 ++++++++++-------
 sys/arch/arm/include/cpu.h         |   2 +-
 2 files changed, 11 insertions(+), 8 deletions(-)

diffs (70 lines):

diff -r e47f110e62d8 -r 7a557d16c793 sys/arch/arm/arm32/arm32_machdep.c
--- a/sys/arch/arm/arm32/arm32_machdep.c        Mon Jul 16 01:52:37 2012 +0000
+++ b/sys/arch/arm/arm32/arm32_machdep.c        Mon Jul 16 06:26:43 2012 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: arm32_machdep.c,v 1.76 2011/06/30 20:09:19 wiz Exp $   */
+/*     $NetBSD: arm32_machdep.c,v 1.77 2012/07/16 06:26:43 skrll Exp $ */
 
 /*
  * Copyright (c) 1994-1998 Mark Brinicombe.
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.76 2011/06/30 20:09:19 wiz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: arm32_machdep.c,v 1.77 2012/07/16 06:26:43 skrll Exp $");
 
 #include "opt_modular.h"
 #include "opt_md.h"
@@ -59,11 +59,12 @@
 #include <sys/buf.h>
 #include <sys/msgbuf.h>
 #include <sys/device.h>
-#include <uvm/uvm_extern.h>
 #include <sys/sysctl.h>
 #include <sys/cpu.h>
 #include <sys/module.h>
 
+#include <uvm/uvm_extern.h>
+
 #include <dev/cons.h>
 #include <dev/mm.h>
 
@@ -449,19 +450,21 @@
        const int opl = ci->ci_cpl;
        const uint32_t softiplmask = SOFTIPLMASK(opl);
 
+       splhigh();
        for (;;) {
                u_int softints = ci->ci_softints & softiplmask;
                KASSERT((softints != 0) == ((ci->ci_softints >> opl) != 0));
-               if (softints == 0)
+               KASSERT(opl == IPL_NONE || (softints & (1 << (opl - IPL_SOFTCLOCK))) == 0);
+               if (softints == 0) {
+                       splx(opl);
                        return;
-               ci->ci_cpl = IPL_HIGH;
+               }
 #define        DOSOFTINT(n) \
-               if (softints & (1 << (IPL_SOFT ## n - IPL_SOFTCLOCK))) { \
+               if (ci->ci_softints & (1 << (IPL_SOFT ## n - IPL_SOFTCLOCK))) { \
                        ci->ci_softints &= \
                            ~(1 << (IPL_SOFT ## n - IPL_SOFTCLOCK)); \
                        softint_switch(ci->ci_softlwps[SOFTINT_ ## n], \
                            IPL_SOFT ## n); \
-                       ci->ci_cpl = opl; \
                        continue; \
                }
                DOSOFTINT(SERIAL);
diff -r e47f110e62d8 -r 7a557d16c793 sys/arch/arm/include/cpu.h
--- a/sys/arch/arm/include/cpu.h        Mon Jul 16 01:52:37 2012 +0000
+++ b/sys/arch/arm/include/cpu.h        Mon Jul 16 06:26:43 2012 +0000
@@ -247,7 +247,7 @@
        struct pcb *ci_curpcb;          /* current pcb */
 #ifdef __HAVE_FAST_SOFTINTS
        lwp_t *ci_softlwps[SOFTINT_COUNT];
-       uint32_t ci_softints;
+       volatile uint32_t ci_softints;
 #endif
 #if !defined(PROCESS_ID_IS_CURLWP)
        lwp_t *ci_curlwp;               /* current lwp */



Home | Main Index | Thread Index | Old Index