summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2008-09-16 16:28:51 +0000
committermarcel <marcel@FreeBSD.org>2008-09-16 16:28:51 +0000
commit30ff2246e9e45b7de38c4d85845a14e1bf21adcb (patch)
tree2c4bc2f8a68b9d602e59958d131750823996953c /sys/powerpc
parent020ede1151961fbedcb0cfc78fde6a11aaff2cbc (diff)
downloadFreeBSD-src-30ff2246e9e45b7de38c4d85845a14e1bf21adcb.zip
FreeBSD-src-30ff2246e9e45b7de38c4d85845a14e1bf21adcb.tar.gz
In powerpc_get_pcpup(), make the inline assembly statement
volatile so that the compiler won't perform CSE. For SMP, this may result in us accessing the wrong PCPU and as such results in a bogus curthread value. Note that getting curthread is not quite MP-safe in the sense that it requires two instructions that aren't performed atomically. The first instruction gets the address of the PCPU structure and the second instruction dereferences that pointer to get curthread. If a thread is switched-out in between these instructions and switched-in on a different CPU, we still get the wrong curthread.
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/include/cpufunc.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/sys/powerpc/include/cpufunc.h b/sys/powerpc/include/cpufunc.h
index caeceb3..7e35562 100644
--- a/sys/powerpc/include/cpufunc.h
+++ b/sys/powerpc/include/cpufunc.h
@@ -158,7 +158,7 @@ powerpc_get_pcpup(void)
{
struct pcpu *ret;
- __asm ("mfsprg %0, 0" : "=r"(ret));
+ __asm __volatile("mfsprg %0, 0" : "=r"(ret));
return(ret);
}
OpenPOWER on IntegriCloud