Commit 41c2e949 authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Benjamin Herrenschmidt

powerpc: Fix error path in kernel_thread function

The powerpc 32-bit and 64-bit kernel_thread functions don't properly
propagate errors being returned by the clone syscall.  (In the case of
error, the syscall exit code returns a positive errno in r3 and sets
the CR0[SO] bit.)

This patch fixes that by negating r3 if CR0[SO] is set after the syscall.
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@us.ibm.com>
Signed-off-by: default avatarJosh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: default avatarPaul Mackerras <paulus@samba.org>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 99c84066
...@@ -900,8 +900,10 @@ _GLOBAL(kernel_thread) ...@@ -900,8 +900,10 @@ _GLOBAL(kernel_thread)
li r4,0 /* new sp (unused) */ li r4,0 /* new sp (unused) */
li r0,__NR_clone li r0,__NR_clone
sc sc
cmpwi 0,r3,0 /* parent or child? */ bns+ 1f /* did system call indicate error? */
bne 1f /* return if parent */ neg r3,r3 /* if so, make return code negative */
1: cmpwi 0,r3,0 /* parent or child? */
bne 2f /* return if parent */
li r0,0 /* make top-level stack frame */ li r0,0 /* make top-level stack frame */
stwu r0,-16(r1) stwu r0,-16(r1)
mtlr r30 /* fn addr in lr */ mtlr r30 /* fn addr in lr */
...@@ -911,7 +913,7 @@ _GLOBAL(kernel_thread) ...@@ -911,7 +913,7 @@ _GLOBAL(kernel_thread)
li r0,__NR_exit /* exit if function returns */ li r0,__NR_exit /* exit if function returns */
li r3,0 li r3,0
sc sc
1: lwz r30,8(r1) 2: lwz r30,8(r1)
lwz r31,12(r1) lwz r31,12(r1)
addi r1,r1,16 addi r1,r1,16
blr blr
......
...@@ -426,8 +426,10 @@ _GLOBAL(kernel_thread) ...@@ -426,8 +426,10 @@ _GLOBAL(kernel_thread)
li r4,0 /* new sp (unused) */ li r4,0 /* new sp (unused) */
li r0,__NR_clone li r0,__NR_clone
sc sc
cmpdi 0,r3,0 /* parent or child? */ bns+ 1f /* did system call indicate error? */
bne 1f /* return if parent */ neg r3,r3 /* if so, make return code negative */
1: cmpdi 0,r3,0 /* parent or child? */
bne 2f /* return if parent */
li r0,0 li r0,0
stdu r0,-STACK_FRAME_OVERHEAD(r1) stdu r0,-STACK_FRAME_OVERHEAD(r1)
ld r2,8(r29) ld r2,8(r29)
...@@ -438,7 +440,7 @@ _GLOBAL(kernel_thread) ...@@ -438,7 +440,7 @@ _GLOBAL(kernel_thread)
li r0,__NR_exit /* exit after child exits */ li r0,__NR_exit /* exit after child exits */
li r3,0 li r3,0
sc sc
1: addi r1,r1,STACK_FRAME_OVERHEAD 2: addi r1,r1,STACK_FRAME_OVERHEAD
ld r29,-24(r1) ld r29,-24(r1)
ld r30,-16(r1) ld r30,-16(r1)
blr blr
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment