summaryrefslogtreecommitdiff
path: root/src/thread/powerpc/clone.s
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2012-11-18 22:57:32 -0500
committerRich Felker <dalias@aerifal.cx>2012-11-18 22:57:32 -0500
commit9565a349f217fb6f532fac06b7ef458a32c2ad2e (patch)
tree8c04bf07adcdc61315d71796331c971f281d5103 /src/thread/powerpc/clone.s
parent0004ea613ac310daaee30c167112d796db33fa70 (diff)
downloadmusl-9565a349f217fb6f532fac06b7ef458a32c2ad2e.tar.gz
fix powerpc asm not to store data in volatile space below stack pointer
it's essential to decrement the stack pointer before writing to new stack space, rather than afterwards. otherwise there is a race condition during which asynchronous code (signals) could clobber the data being stored. it may be possible to optimize the code further using stwu, but I wanted to avoid making any changes to the actual stack layout in this commit. further improvements can be made separately if desired.
Diffstat (limited to 'src/thread/powerpc/clone.s')
-rw-r--r--src/thread/powerpc/clone.s8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/thread/powerpc/clone.s b/src/thread/powerpc/clone.s
index cea69e99..54a2314e 100644
--- a/src/thread/powerpc/clone.s
+++ b/src/thread/powerpc/clone.s
@@ -16,9 +16,9 @@ __clone:
# in order that the child can find the start func and its arg, we need to store it into
# non-volative regs. to do so, we have to store those 2 regs into our stackframe, so
# we can restore them later.
-stw 30, -4(1)
-stw 31, -8(1)
subi 1, 1, 16
+stw 30, 12(1)
+stw 31, 8(1)
# save r3 (func) into r30, and r6(arg) into r31
mr 30, 3
@@ -72,9 +72,9 @@ sc
2:
# restore stack
+lwz 30, 12(1)
+lwz 31, 8(1)
addi 1, 1, 16
-lwz 30, -4(1)
-lwz 31, -8(1)
blr