]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
Use the ABI-mandated thread pointer register (r2 for ppc32, r13 for ppc64)
authorNathan Whitehorn <nwhitehorn@FreeBSD.org>
Thu, 23 Jun 2011 22:21:28 +0000 (22:21 +0000)
committerNathan Whitehorn <nwhitehorn@FreeBSD.org>
Thu, 23 Jun 2011 22:21:28 +0000 (22:21 +0000)
commite69dff491d4faeddb7bde8ba3d88881574a29c93
tree76a642e618833d9949a5962d0c3847b6ff888af7
parent6a4ba2279dcc15976a06bbb485e52b66d6f874a3
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
16 files changed:
sys/powerpc/aim/copyinout.c
sys/powerpc/aim/locore32.S
sys/powerpc/aim/locore64.S
sys/powerpc/aim/machdep.c
sys/powerpc/aim/mp_cpudep.c
sys/powerpc/aim/swtch32.S
sys/powerpc/aim/swtch64.S
sys/powerpc/aim/trap.c
sys/powerpc/aim/trap_subr32.S
sys/powerpc/aim/trap_subr64.S
sys/powerpc/booke/copyinout.c
sys/powerpc/booke/interrupt.c
sys/powerpc/booke/trap.c
sys/powerpc/include/pcpu.h
sys/powerpc/ofw/ofwcall32.S
sys/powerpc/powerpc/mp_machdep.c