From 1d215b1285ab0897c64a473f1b6b30f0311b87d0 Mon Sep 17 00:00:00 2001 From: nwhitehorn Date: Thu, 23 Jun 2011 22:21:28 +0000 Subject: Use the ABI-mandated thread pointer register (r2 for ppc32, r13 for ppc64) instead of a PCPU field for curthread. This averts a race on SMP systems with a high interrupt rate where the thread looking up the value of curthread could be preempted and migrated between obtaining the PCPU pointer and reading the value of pc_curthread, resulting in curthread being observed to be the current thread on the thread's original CPU. This played merry havoc with the system, in particular with mutexes. Many thanks to jhb for helping me work this one out. Note that Book-E is in principle susceptible to the same problem, but has not been modified yet due to lack of Book-E hardware. MFC after: 2 weeks --- sys/powerpc/booke/interrupt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys/powerpc/booke/interrupt.c') diff --git a/sys/powerpc/booke/interrupt.c b/sys/powerpc/booke/interrupt.c index c0bdee1..e268537 100644 --- a/sys/powerpc/booke/interrupt.c +++ b/sys/powerpc/booke/interrupt.c @@ -118,7 +118,7 @@ powerpc_decr_interrupt(struct trapframe *framep) struct thread *td; struct trapframe *oldframe; - td = PCPU_GET(curthread); + td = curthread; critical_enter(); atomic_add_int(&td->td_intr_nesting_level, 1); oldframe = td->td_intr_frame; -- cgit v1.1