From 5b4feac12669eff009e877808b29f6a7a22f4be8 Mon Sep 17 00:00:00 2001 From: ad Date: Sun, 28 Jun 2009 09:25:05 +0000 Subject: [PATCH] idle_loop: explicitly go to spl0() to sidestep potential MD bugs. --- sys/kern/kern_idle.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_idle.c b/sys/kern/kern_idle.c index c6b0c8b2966c..9ef90813d435 100644 --- a/sys/kern/kern_idle.c +++ b/sys/kern/kern_idle.c @@ -1,4 +1,4 @@ -/* $NetBSD: kern_idle.c,v 1.21 2008/06/11 13:42:02 ad Exp $ */ +/* $NetBSD: kern_idle.c,v 1.22 2009/06/28 09:25:05 ad Exp $ */ /*- * Copyright (c)2002, 2006, 2007 YAMAMOTO Takashi, @@ -28,7 +28,7 @@ #include -__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.21 2008/06/11 13:42:02 ad Exp $"); +__KERNEL_RCSID(0, "$NetBSD: kern_idle.c,v 1.22 2009/06/28 09:25:05 ad Exp $"); #include #include @@ -48,7 +48,6 @@ idle_loop(void *dummy) struct cpu_info *ci = curcpu(); struct schedstate_percpu *spc; struct lwp *l = curlwp; - int s; ci->ci_data.cpu_onproc = l; @@ -57,10 +56,15 @@ idle_loop(void *dummy) binuptime(&l->l_stime); lwp_unlock(l); + /* + * Use spl0() here to ensure that we have the correct interrupt + * priority. This may be the first thread running on the CPU, + * in which case we took a dirtbag route to get here. + */ spc = &ci->ci_schedstate; - s = splsched(); + (void)splsched(); spc->spc_flags |= SPCF_RUNNING; - splx(s); + spl0(); KERNEL_UNLOCK_ALL(l, NULL); l->l_stat = LSONPROC;