[v3] Fix clone (CLONE_VM) pid/tid reset (BZ#19957)
Commit Message
Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
> index 33474cc..84eb2b9 100644
> --- a/sysdeps/unix/sysv/linux/m68k/clone.S
> +++ b/sysdeps/unix/sysv/linux/m68k/clone.S
> @@ -25,7 +25,6 @@
> #include <tls.h>
>
> #define CLONE_VM 0x00000100
> -#define CLONE_THREAD 0x00010000
>
> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
> void *parent_tidptr, void *tls, void *child_tidptr) */
> @@ -101,12 +100,9 @@ thread_start:
> subl %fp, %fp /* terminate the stack frame */
> /* Check and see if we need to reset the PID. */
> movel %d1, %a1
> - andl #CLONE_THREAD, %d1
> + andl #CLONE_VM, %d1
> jne donepid
> movel %a1, %d1
> - movel #-1, %d0
> - andl #CLONE_VM, %d1
> - jne gotpid
> movel #SYS_ify (getpid), %d0
> trap #0
> gotpid:
This can be simplified further:
Andreas.
Comments
On 22-04-2016 16:40, Andreas Schwab wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
>
>> diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
>> index 33474cc..84eb2b9 100644
>> --- a/sysdeps/unix/sysv/linux/m68k/clone.S
>> +++ b/sysdeps/unix/sysv/linux/m68k/clone.S
>> @@ -25,7 +25,6 @@
>> #include <tls.h>
>>
>> #define CLONE_VM 0x00000100
>> -#define CLONE_THREAD 0x00010000
>>
>> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
>> void *parent_tidptr, void *tls, void *child_tidptr) */
>> @@ -101,12 +100,9 @@ thread_start:
>> subl %fp, %fp /* terminate the stack frame */
>> /* Check and see if we need to reset the PID. */
>> movel %d1, %a1
>> - andl #CLONE_THREAD, %d1
>> + andl #CLONE_VM, %d1
>> jne donepid
>> movel %a1, %d1
>> - movel #-1, %d0
>> - andl #CLONE_VM, %d1
>> - jne gotpid
>> movel #SYS_ify (getpid), %d0
>> trap #0
>> gotpid:
>
> This can be simplified further:
>
> diff --git a/sysdeps/unix/sysv/linux/m68k/clone.S b/sysdeps/unix/sysv/linux/m68k/clone.S
> index 33474cc..aec12cb 100644
> --- a/sysdeps/unix/sysv/linux/m68k/clone.S
> +++ b/sysdeps/unix/sysv/linux/m68k/clone.S
> @@ -25,7 +25,6 @@
> #include <tls.h>
>
> #define CLONE_VM 0x00000100
> -#define CLONE_THREAD 0x00010000
>
> /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
> void *parent_tidptr, void *tls, void *child_tidptr) */
> @@ -100,16 +99,10 @@ thread_start:
> cfi_undefined (pc) /* Mark end of stack */
> subl %fp, %fp /* terminate the stack frame */
> /* Check and see if we need to reset the PID. */
> - movel %d1, %a1
> - andl #CLONE_THREAD, %d1
> - jne donepid
> - movel %a1, %d1
> - movel #-1, %d0
> andl #CLONE_VM, %d1
> - jne gotpid
> + jne donepid
> movel #SYS_ify (getpid), %d0
> trap #0
> -gotpid:
> movel %a0, -(%sp)
> movel %d0, -(%sp)
> bsrl __m68k_read_tp@PLTPC
>
>
> Andreas.
>
Thanks, I use this simplification.
@@ -25,7 +25,6 @@
#include <tls.h>
#define CLONE_VM 0x00000100
-#define CLONE_THREAD 0x00010000
/* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg,
void *parent_tidptr, void *tls, void *child_tidptr) */
@@ -100,16 +99,10 @@ thread_start:
cfi_undefined (pc) /* Mark end of stack */
subl %fp, %fp /* terminate the stack frame */
/* Check and see if we need to reset the PID. */
- movel %d1, %a1
- andl #CLONE_THREAD, %d1
- jne donepid
- movel %a1, %d1
- movel #-1, %d0
andl #CLONE_VM, %d1
- jne gotpid
+ jne donepid
movel #SYS_ify (getpid), %d0
trap #0
-gotpid:
movel %a0, -(%sp)
movel %d0, -(%sp)
bsrl __m68k_read_tp@PLTPC