Re: [PATCH] arm: add RESET_PID in the clone impl
Hi Carmelo, Carmelo Amoroso wrote, > Hi, > I don't think clone on arm is missing RESET_PID if you use the > correct implementation from > libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S. Can you explain this a little bit more? cat ./libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S #define RESET_PID #include #include "../../../../../../../libc/sysdeps/linux/arm/clone.S" Do you think the test-suite failures on arm come from a buildsystem problem? best regards Waldemar > Cheers > Carmelo > > Inviato con AquaMail per Android > http://www.aqua-mail.com > > > Il 02 settembre 2014 14:12:24 Wangyufen ha scritto: > > >From: Wang Yufen > > > >Called getpid() When creating a new process with clone(), getpid() returns > >the father_process's value. It should be child_process's value. > >The reason is missing a RESET_PID in the arm clone impl. > > > >Signed-off-by: Wang Yufen > >--- > > libc/sysdeps/linux/arm/clone.S | 61 > > ++- > > libc/sysdeps/linux/arm/sysdep.h | 45 > > 2 files changed, 92 insertions(+), 14 deletions(-) > > > >diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S > >index 03cd10e..29045ef 100644 > >--- a/libc/sysdeps/linux/arm/clone.S > >+++ b/libc/sysdeps/linux/arm/clone.S > >@@ -19,12 +19,17 @@ > > /* clone() is even more special than fork() as it mucks with stacks > >and invokes a function in the right context after its all over. */ > > > >+#include > > #define _ERRNO_H > > #include > > #include > > #include > > #include > > #include > >+#include > >+ > >+#define CLONE_VM 0x0100 > >+#define CLONE_THREAD 0x0001 > > > > #if defined(__NR_clone) > > /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void > > *arg); */ > >@@ -87,6 +92,8 @@ __error: > > .pool > > #else > > __clone: > >+.fnstart > >+.cantunwind > > @ sanity check args > > cmp r0, #0 > > IT(te, ne) > >@@ -95,32 +102,58 @@ __clone: > > beq __error > > > > @ insert the args onto the new stack > >-sub r1, r1, #8 > >-str r3, [r1, #4] > >-@ save the function pointer as the 0th element > >-str r0, [r1] > >+str r3, [r1, #-4]! > >+str r0, [r1, #-4]! > > > > @ do the system call > > @ get flags > > mov r0, r2 > >+#ifdef RESET_PID > >+mov ip, r2 > >+#endif > > @ new sp is already in r1 > >-@ load remaining arguments off the stack > >-stmfd sp!, {r4} > >-ldr r2, [sp, #4] > >-ldr r3, [sp, #8] > >-ldr r4, [sp, #12] > >-DO_CALL (clone) > >-movsa1, a1 > >-IT(t, ne) > >-ldmnefd sp!, {r4} > >+push{r4, r7} > >+cfi_adjust_cfa_offset (8) > >+cfi_rel_offset (r4, 0) > >+cfi_rel_offset (r7, 4) > >+ldr r2, [sp, #8] > >+ldr r3, [sp, #12] > >+ldr r4, [sp, #16] > >+ldr r7, =SYS_ify(clone) > >+swi 0x0 > >+cfi_endproc > >+cmp r0, #0 > >+beq 1f > >+pop {r4, r7} > > blt __error > >-IT(t, ne) > > #if defined(__USE_BX__) > > bxnelr > > #else > > movne pc, lr > > #endif > > > >+cfi_startproc > >+.fnend > >+PSEUDO_END (__clone) > >+ > >+1: > >+.fnstart > >+.cantunwind > >+#ifdef RESET_PID > >+tst ip, #CLONE_THREAD > >+bne 3f > >+GET_TLS (lr) > >+mov r1, r0 > >+tst ip, #CLONE_VM > >+ldr r7, =SYS_ify(getpid) > >+ite ne > >+movne r0, #-1 > >+swieq 0x0 > >+NEGOFF_ADJ_BASE (r1, TID_OFFSET) > >+str r0, NEGOFF_OFF1 (r1, TID_OFFSET) > >+str r0, NEGOFF_OFF2 (r1, PID_OFFSET, TID_OFFSET) > >+3: > >+#endif > > @ pick the function arg and call address off the stack and execute > > ldr r0, [sp, #4] > > mov lr, pc > >diff --git a/libc/sysdeps/linux/arm/sysdep.h > >b/libc/sysdeps/linux/arm/sysdep.h > >index 64f4040..38a131d 100644 > >--- a/libc/sysdeps/linux/arm/sysdep.h > >+++ b/libc/sysdeps/linux/arm/sysdep.h > >@@ -213,6 +213,51 @@ __local_syscall_error: > >\ > >sees the right arguments. > > > > */ > >+#if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__) > >+# define ARCH_HAS_BX > >+#endif > >+#if __ARM_ARCH > 4 > >+# define ARCH_HAS_BLX > >+#endif > >+#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6K__) || defined > >(__ARM_ARCH_6ZK__) > >+# define ARCH_HAS_HARD_TP > >+#endif > >+#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6T2__) > >+# define ARCH_HAS_T2 > >+#endif > >+ > >+# ifdef __thumb2__ > >+# define NEGOFF_ADJ_BASE(R, OFF) add R, R, $OFF > >+# define NEGOFF_ADJ_BASE2(D, S, OFF) add D, S, $OFF > >+# define NEGOFF_OFF1(R, OFF) [R] > >+# define NEGOFF_OFF2(R, OFFA, OFFB)[R, $((OFFA) - (OFFB))] > >+# else > >+# define NEGOFF_ADJ_BASE(R, OFF) > >+# define NEGOFF_ADJ_BASE2(D, S, OFF) mov D, S > >+# define NEGOFF_OFF1(R, OFF) [R, $OFF] > >+# define NEGOFF_OFF2
Re: [PATCH] arm: add RESET_PID in the clone impl
Hi, I don't think clone on arm is missing RESET_PID if you use the correct implementation from libpthread/nptl/sysdeps/unix/sysv/linux/arm/clone.S. Cheers Carmelo Inviato con AquaMail per Android http://www.aqua-mail.com Il 02 settembre 2014 14:12:24 Wangyufen ha scritto: From: Wang Yufen Called getpid() When creating a new process with clone(), getpid() returns the father_process's value. It should be child_process's value. The reason is missing a RESET_PID in the arm clone impl. Signed-off-by: Wang Yufen --- libc/sysdeps/linux/arm/clone.S | 61 ++- libc/sysdeps/linux/arm/sysdep.h | 45 2 files changed, 92 insertions(+), 14 deletions(-) diff --git a/libc/sysdeps/linux/arm/clone.S b/libc/sysdeps/linux/arm/clone.S index 03cd10e..29045ef 100644 --- a/libc/sysdeps/linux/arm/clone.S +++ b/libc/sysdeps/linux/arm/clone.S @@ -19,12 +19,17 @@ /* clone() is even more special than fork() as it mucks with stacks and invokes a function in the right context after its all over. */ +#include #define _ERRNO_H #include #include #include #include #include +#include + +#define CLONE_VM 0x0100 +#define CLONE_THREAD 0x0001 #if defined(__NR_clone) /* int clone(int (*fn)(void *arg), void *child_stack, int flags, void *arg); */ @@ -87,6 +92,8 @@ __error: .pool #else __clone: +.fnstart +.cantunwind @ sanity check args cmp r0, #0 IT(te, ne) @@ -95,32 +102,58 @@ __clone: beq __error @ insert the args onto the new stack - sub r1, r1, #8 - str r3, [r1, #4] - @ save the function pointer as the 0th element - str r0, [r1] + str r3, [r1, #-4]! + str r0, [r1, #-4]! @ do the system call @ get flags mov r0, r2 +#ifdef RESET_PID + mov ip, r2 +#endif @ new sp is already in r1 - @ load remaining arguments off the stack - stmfd sp!, {r4} - ldr r2, [sp, #4] - ldr r3, [sp, #8] - ldr r4, [sp, #12] - DO_CALL (clone) - movsa1, a1 - IT(t, ne) - ldmnefd sp!, {r4} + push{r4, r7} + cfi_adjust_cfa_offset (8) + cfi_rel_offset (r4, 0) + cfi_rel_offset (r7, 4) + ldr r2, [sp, #8] + ldr r3, [sp, #12] + ldr r4, [sp, #16] + ldr r7, =SYS_ify(clone) + swi 0x0 + cfi_endproc + cmp r0, #0 + beq 1f + pop {r4, r7} blt __error - IT(t, ne) #if defined(__USE_BX__) bxnelr #else movne pc, lr #endif + cfi_startproc +.fnend +PSEUDO_END (__clone) + +1: + .fnstart + .cantunwind +#ifdef RESET_PID + tst ip, #CLONE_THREAD + bne 3f + GET_TLS (lr) + mov r1, r0 + tst ip, #CLONE_VM + ldr r7, =SYS_ify(getpid) + ite ne + movne r0, #-1 + swieq 0x0 + NEGOFF_ADJ_BASE (r1, TID_OFFSET) + str r0, NEGOFF_OFF1 (r1, TID_OFFSET) + str r0, NEGOFF_OFF2 (r1, PID_OFFSET, TID_OFFSET) +3: +#endif @ pick the function arg and call address off the stack and execute ldr r0, [sp, #4] mov lr, pc diff --git a/libc/sysdeps/linux/arm/sysdep.h b/libc/sysdeps/linux/arm/sysdep.h index 64f4040..38a131d 100644 --- a/libc/sysdeps/linux/arm/sysdep.h +++ b/libc/sysdeps/linux/arm/sysdep.h @@ -213,6 +213,51 @@ __local_syscall_error: \ sees the right arguments. */ +#if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__) +# define ARCH_HAS_BX +#endif +#if __ARM_ARCH > 4 +# define ARCH_HAS_BLX +#endif +#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6K__) || defined (__ARM_ARCH_6ZK__) +# define ARCH_HAS_HARD_TP +#endif +#if __ARM_ARCH > 6 || defined (__ARM_ARCH_6T2__) +# define ARCH_HAS_T2 +#endif + +# ifdef __thumb2__ +# define NEGOFF_ADJ_BASE(R, OFF) add R, R, $OFF +# define NEGOFF_ADJ_BASE2(D, S, OFF) add D, S, $OFF +# define NEGOFF_OFF1(R, OFF) [R] +# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $((OFFA) - (OFFB))] +# else +# define NEGOFF_ADJ_BASE(R, OFF) +# define NEGOFF_ADJ_BASE2(D, S, OFF) mov D, S +# define NEGOFF_OFF1(R, OFF) [R, $OFF] +# define NEGOFF_OFF2(R, OFFA, OFFB) [R, $OFFA] +# endif + +# ifdef ARCH_HAS_HARD_TP +/* If the cpu has cp15 available, use it. */ +# define GET_TLS(TMP) mrc p15, 0, r0, c13, c0, 3 +# else +/* At this generic level we have no tricks to pull. Call the ABI routine. */ +# define GET_TLS(TMP) \ + push{ r1, r2, r3, lr }; \ + cfi_remember_state; \ + cfi_adjust_cfa_offset (16); \ + cfi_rel_offset (r1, 0); \ + cfi_rel_offset (r2, 4); \ + cfi_rel_offset (r3, 8);
Re: sparc64 removal patch too big
Hi Baruch, Baruch Siach wrote, > Hi Waldemar, > > On Tue, Sep 02, 2014 at 04:05:37PM +0200, Waldemar Brodkorb wrote: > > Anyone Admin for the mailinglist? > > My sparc64 removal patch was set on hold. > > You may try the -D parameter of git format-patch. It omits the text of > deleted > files, thus making the patch much smaller and also easier to review. This worked, thanks for the hint. best regards Waldemar ___ uClibc mailing list uClibc@uclibc.org http://lists.busybox.net/mailman/listinfo/uclibc
[PATCH] sparc: remove sparc64/sparcv9 code
The sparc64/sparcv9 code is incomplete. Furthermore there is no real embedded hardware for sparc64 available, so better remove it until someone comes up with a complete port. Signed-off-by: Waldemar Brodkorb --- Test before patch: http://www.openadk.org/test/REPORT.sparc.uclibc Test after patch: http://www.openadk.org/test/REPORT.sparc.uclibc.libc No regression found. Changes to libc/string/sparc/ are incomplete. What would the best way to change libc/string/sparc/memchr.S and others? --- extra/Configs/Config.sparc | 6 - libc/string/sparc/sparc64/memchr.S | 258 -- libc/string/sparc/sparc64/memcpy.S | 922 - libc/string/sparc/sparc64/memset.S | 316 --- libc/string/sparc/sparc64/sparcv9b/memcpy.S| 611 -- libc/string/sparc/sparc64/stpcpy.S | 270 -- libc/string/sparc/sparc64/strcat.S | 338 libc/string/sparc/sparc64/strchr.S | 485 --- libc/string/sparc/sparc64/strcmp.S | 278 --- libc/string/sparc/sparc64/strcpy.S | 244 -- libc/string/sparc/sparc64/strlen.S | 172 libc/sysdeps/linux/sparc/bits/setjmp.h | 31 - libc/sysdeps/linux/sparc/bits/sigcontext.h | 35 - libc/sysdeps/linux/sparc/crt1.S| 11 - libc/sysdeps/linux/sparc/jmpbuf-unwind.h | 25 +- libc/sysdeps/linux/sparc/qp_ops.c | 8 - libc/sysdeps/linux/sparc/sparcv9/clone.S | 101 --- libc/sysdeps/linux/sparc/sparcv9/rem.S | 20 - libc/sysdeps/linux/sparc/sparcv9/sdiv.S| 18 - libc/sysdeps/linux/sparc/sparcv9/udiv.S| 15 - libc/sysdeps/linux/sparc/sparcv9/umul.S| 15 - libc/sysdeps/linux/sparc/sparcv9/urem.S| 17 - libc/sysdeps/linux/sparc/sys/procfs.h | 88 -- .../linuxthreads.old/sysdeps/sparc/pt-machine.h| 86 +- .../sysdeps/sparc/sparc32/pt-machine.h | 82 -- .../sysdeps/sparc/sparc64/pt-machine.h | 104 --- libpthread/linuxthreads/sysdeps/sparc/pspinlock.c | 95 ++- libpthread/linuxthreads/sysdeps/sparc/pt-machine.h | 86 +- .../linuxthreads/sysdeps/sparc/sparc32/pspinlock.c | 87 -- .../sysdeps/sparc/sparc32/pt-machine.h | 82 -- .../sysdeps/sparc/sparc32/sparcv9/pspinlock.c | 93 --- .../linuxthreads/sysdeps/sparc/sparc64/pspinlock.c | 92 -- .../sysdeps/sparc/sparc64/pt-machine.h | 104 --- .../unix/sysv/linux/sparc/sparc32/sysdep-cancel.h | 100 --- .../sysdeps/unix/sysv/linux/sparc/sparc32/vfork.S | 64 -- .../unix/sysv/linux/sparc/sparc64/pt-sigsuspend.c | 1 - .../unix/sysv/linux/sparc/sparc64/sysdep-cancel.h | 99 --- .../sysdeps/unix/sysv/linux/sparc/sparc64/vfork.S | 63 -- .../sysdeps/unix/sysv/linux/sparc/sysdep-cancel.h | 102 ++- .../sysdeps/unix/sysv/linux/sparc/vfork.S | 64 ++ libpthread/nptl/sysdeps/jmpbuf-unwind.h| 27 + libpthread/nptl/sysdeps/pthread_spin_lock.c| 39 + libpthread/nptl/sysdeps/pthread_spin_trylock.c | 28 + libpthread/nptl/sysdeps/pthreaddef.h | 39 + libpthread/nptl/sysdeps/sparc/jmpbuf-unwind.h | 32 +- libpthread/nptl/sysdeps/sparc/pthread_spin_lock.c | 44 +- .../nptl/sysdeps/sparc/pthread_spin_trylock.c | 33 +- libpthread/nptl/sysdeps/sparc/pthreaddef.h | 44 +- .../nptl/sysdeps/sparc/sparc32/jmpbuf-unwind.h | 27 - .../nptl/sysdeps/sparc/sparc32/pthread_spin_lock.c | 39 - .../sysdeps/sparc/sparc32/pthread_spin_trylock.c | 28 - libpthread/nptl/sysdeps/sparc/sparc32/pthreaddef.h | 39 - .../sparc/sparc32/sparcv9/pthread_spin_lock.c | 38 - .../sparc/sparc32/sparcv9/pthread_spin_trylock.c | 1 - .../sparc/sparc32/sparcv9/pthread_spin_unlock.c| 1 - .../nptl/sysdeps/sparc/sparc64/jmpbuf-unwind.h | 27 - .../nptl/sysdeps/sparc/sparc64/pthread_spin_lock.c | 38 - .../sysdeps/sparc/sparc64/pthread_spin_trylock.c | 33 - .../sysdeps/sparc/sparc64/pthread_spin_unlock.c| 29 - libpthread/nptl/sysdeps/sparc/sparc64/pthreaddef.h | 39 - .../nptl/sysdeps/unix/sysv/linux/sparc/clone.S | 7 +- .../nptl/sysdeps/unix/sysv/linux/sparc/pt-vfork.S | 49 +- .../unix/sysv/linux/sparc/pthread_barrier_wait.c | 94 ++- .../nptl/sysdeps/unix/sysv/linux/sparc/sem_post.c | 52 ++ .../sysdeps/unix/sysv/linux/sparc/sem_timedwait.c | 147 .../sysdeps/unix/sysv/linux/sparc/sem_trywait.c| 51 ++ .../nptl/sysdeps/unix/sysv/linux/sparc/sem_wait.c | 124 +++ .../sysdeps/unix/sysv/linux/sparc/sparc32/clone.S | 2 - .../unix/sysv/linux/sparc/sparc32/pt-vfork.S | 44 - .../linux/sparc/sparc32/pthread_barrier_wait.c | 93 --- .../unix/sysv/linux/sparc/sparc32/sem_post.c | 52 -- .../unix/sysv/linux/sparc/sparc32/sem_timedwait.c | 147 .../unix/sysv/linux/sparc/sparc32/sem_trywait.c|