summaryrefslogtreecommitdiffstats
path: root/sys/powerpc/aim
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2009-04-04 22:23:03 +0000
committermarcel <marcel@FreeBSD.org>2009-04-04 22:23:03 +0000
commit43f12bcbe6cd236c43a2796a77aca22e701d5f22 (patch)
tree4fe5eecd4ee27e21a5bbad1b607c9656e18d81c0 /sys/powerpc/aim
parentd8907d8b8a8f186d9cfdba6d2f970626a82d0d10 (diff)
downloadFreeBSD-src-43f12bcbe6cd236c43a2796a77aca22e701d5f22.zip
FreeBSD-src-43f12bcbe6cd236c43a2796a77aca22e701d5f22.tar.gz
Perform a dummy stwcx. when we switch contexts. The context
being switched out may hold a reservation. The stwcx. will clear the reservation. This is architecturally recommended. The scenario this addresses is as follows: 1. Thread 1 performs a lwarx and as such holds a reservation. 2. Thread 1 gets switched out (before doing the matching stwcx.) and thread 2 is switched in. 3. Thread 2 performs a stwcx. to the same reservation granule. This will succeed because the processor has the reservation even though thread 2 didn't do the lwarx. Note that on some processors the address given the stwcx. is not checked. On these processors the mere condition of having a reservation would cause the stwcx. to succeed, irrespective of whether the addresses are the same. The dummy stwcx. is especially important for those processors.
Diffstat (limited to 'sys/powerpc/aim')
-rw-r--r--sys/powerpc/aim/swtch.S6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/powerpc/aim/swtch.S b/sys/powerpc/aim/swtch.S
index 672fe6b..619bf89 100644
--- a/sys/powerpc/aim/swtch.S
+++ b/sys/powerpc/aim/swtch.S
@@ -155,6 +155,12 @@ cpu_switchin:
mtsr USER_SR,%r5
isync
lwz %r1,PCB_SP(%r3) /* Load the stack pointer */
+ /*
+ * Perform a dummy stwcx. to clear any reservations we may have
+ * inherited from the previous thread. It doesn't matter if the
+ * stwcx succeeds or not. pcb_context[0] can be clobbered.
+ */
+ stwcx. %r1, 0, %r3
blr
/*
OpenPOWER on IntegriCloud