summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/include
diff options
context:
space:
mode:
authornwhitehorn <nwhitehorn@FreeBSD.org>2011-06-23 22:21:28 +0000
committernwhitehorn <nwhitehorn@FreeBSD.org>2011-06-23 22:21:28 +0000
commit1d215b1285ab0897c64a473f1b6b30f0311b87d0 (patch)
tree76a642e618833d9949a5962d0c3847b6ff888af7 /sys/powerpc/include
parent1f9c357d9bfe97631d50ce6a97e271360f417bbb (diff)
downloadFreeBSD-src-1d215b1285ab0897c64a473f1b6b30f0311b87d0.zip
FreeBSD-src-1d215b1285ab0897c64a473f1b6b30f0311b87d0.tar.gz
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
Diffstat (limited to 'sys/powerpc/include')
-rw-r--r--sys/powerpc/include/pcpu.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/sys/powerpc/include/pcpu.h b/sys/powerpc/include/pcpu.h
index 949bbf3..631abd2 100644
--- a/sys/powerpc/include/pcpu.h
+++ b/sys/powerpc/include/pcpu.h
@@ -135,6 +135,14 @@ struct pmap;
#ifdef _KERNEL
#define pcpup ((struct pcpu *) powerpc_get_pcpup())
+#ifdef __powerpc64__
+register struct thread *curthread_reg __asm("%r13");
+#else
+register struct thread *curthread_reg __asm("%r2");
+#endif
+#ifdef AIM /* Book-E not yet adapted */
+#define curthread curthread_reg
+#endif
#define PCPU_GET(member) (pcpup->pc_ ## member)
OpenPOWER on IntegriCloud