5 Sep 2010 23:35
SMP/preempt bug in matt-nb5-mips64
Manuel Bouyer <bouyer <at> antioche.eu.org>
2010-09-05 21:35:41 GMT
2010-09-05 21:35:41 GMT
Hello, I found a problem in matt-nb5-mips64's mips/mips/spl.S, regarding curcpu() and preemption. In both _splraise and _splsw_splhigh, curcpu() is loaded from L_CPU(MIPS_CURLWP) in a register early, especially before disabling interrupt. If the current IPL is 0, the current thread can be preempted and rescheduled on another CPU, and the new SPL is written back to the wrong cpu_info. From there, bad things happens (what I've seen is an infinite loop from the interrupt handler on the victim CPU, because _splsw_splhigh thinks we're already at splhigh and do nothing, when interrupts are really enabled). The attached patch seems to fix it for me: it's enough to reload curcpu() before writing back the new IPL, as for the above senario to happen the old IPL of both CPUs has to be 0. I suspect there's a similar issue with the use of L_CPU(MIPS_CURLWP) in stub_lock.S, but I've not looked in details, as right now I'm running with LOCKDEBUG and this code isn't used. -- -- Manuel Bouyer <bouyer <at> antioche.eu.org> NetBSD: 26 ans d'experience feront toujours la difference --
Index: spl.S =================================================================== --- spl.S (revision 100) +++ spl.S (revision 101) <at> <at> -76,6 +76,10 <at> <at>(Continue reading)
RSS Feed