diff options
author | Josh Poimboeuf <jpoimboe@us.ibm.com> | 2008-10-07 02:10:03 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2008-10-10 00:55:18 -0400 |
commit | 41c2e949cb7b80c5a6247c7df97759953b0f71b5 (patch) | |
tree | c8ba92fa5cd1dc7f6293552704e639135008c343 | |
parent | 99c840668c23fa81ac642598c792926021329747 (diff) |
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: Josh Poimboeuf <jpoimboe@us.ibm.com>
Signed-off-by: Josh Boyer <jwboyer@linux.vnet.ibm.com>
Acked-by: Paul Mackerras <paulus@samba.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/kernel/misc_32.S | 8 | ||||
-rw-r--r-- | arch/powerpc/kernel/misc_64.S | 8 |
2 files changed, 10 insertions, 6 deletions
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S index e9c8ab6eabfe..6a9b4bf0d173 100644 --- a/arch/powerpc/kernel/misc_32.S +++ b/arch/powerpc/kernel/misc_32.S | |||
@@ -900,8 +900,10 @@ _GLOBAL(kernel_thread) | |||
900 | li r4,0 /* new sp (unused) */ | 900 | li r4,0 /* new sp (unused) */ |
901 | li r0,__NR_clone | 901 | li r0,__NR_clone |
902 | sc | 902 | sc |
903 | cmpwi 0,r3,0 /* parent or child? */ | 903 | bns+ 1f /* did system call indicate error? */ |
904 | bne 1f /* return if parent */ | 904 | neg r3,r3 /* if so, make return code negative */ |
905 | 1: cmpwi 0,r3,0 /* parent or child? */ | ||
906 | bne 2f /* return if parent */ | ||
905 | li r0,0 /* make top-level stack frame */ | 907 | li r0,0 /* make top-level stack frame */ |
906 | stwu r0,-16(r1) | 908 | stwu r0,-16(r1) |
907 | mtlr r30 /* fn addr in lr */ | 909 | mtlr r30 /* fn addr in lr */ |
@@ -911,7 +913,7 @@ _GLOBAL(kernel_thread) | |||
911 | li r0,__NR_exit /* exit if function returns */ | 913 | li r0,__NR_exit /* exit if function returns */ |
912 | li r3,0 | 914 | li r3,0 |
913 | sc | 915 | sc |
914 | 1: lwz r30,8(r1) | 916 | 2: lwz r30,8(r1) |
915 | lwz r31,12(r1) | 917 | lwz r31,12(r1) |
916 | addi r1,r1,16 | 918 | addi r1,r1,16 |
917 | blr | 919 | blr |
diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S index 4dd70cf7bb4e..3053fe5c62f2 100644 --- a/arch/powerpc/kernel/misc_64.S +++ b/arch/powerpc/kernel/misc_64.S | |||
@@ -426,8 +426,10 @@ _GLOBAL(kernel_thread) | |||
426 | li r4,0 /* new sp (unused) */ | 426 | li r4,0 /* new sp (unused) */ |
427 | li r0,__NR_clone | 427 | li r0,__NR_clone |
428 | sc | 428 | sc |
429 | cmpdi 0,r3,0 /* parent or child? */ | 429 | bns+ 1f /* did system call indicate error? */ |
430 | bne 1f /* return if parent */ | 430 | neg r3,r3 /* if so, make return code negative */ |
431 | 1: cmpdi 0,r3,0 /* parent or child? */ | ||
432 | bne 2f /* return if parent */ | ||
431 | li r0,0 | 433 | li r0,0 |
432 | stdu r0,-STACK_FRAME_OVERHEAD(r1) | 434 | stdu r0,-STACK_FRAME_OVERHEAD(r1) |
433 | ld r2,8(r29) | 435 | ld r2,8(r29) |
@@ -438,7 +440,7 @@ _GLOBAL(kernel_thread) | |||
438 | li r0,__NR_exit /* exit after child exits */ | 440 | li r0,__NR_exit /* exit after child exits */ |
439 | li r3,0 | 441 | li r3,0 |
440 | sc | 442 | sc |
441 | 1: addi r1,r1,STACK_FRAME_OVERHEAD | 443 | 2: addi r1,r1,STACK_FRAME_OVERHEAD |
442 | ld r29,-24(r1) | 444 | ld r29,-24(r1) |
443 | ld r30,-16(r1) | 445 | ld r30,-16(r1) |
444 | blr | 446 | blr |