nptl: nios2: pass the child tid pointer in the right clone slot
ARCH_FORK was copied from an architecture that selects CLONE_BACKWARDS,
where the kernel's clone() takes the child tid pointer last, after the
TLS argument. nios2 uses the generic order (flags, newsp, parent_tid,
child_tid, tls), so &THREAD_SELF->tid arrived as the TLS argument and the
child tid pointer was NULL. CLONE_CHILD_SETTID then wrote nowhere and
the child kept the parent's tid, which breaks everything deriving a
kernel identity from the descriptor after a fork:
parent: gettid=1579855 clock_gettime(thread clock) ok
child : gettid=1579860 but pd->tid still 1579855
-> clock_gettime EINVAL, pthread_kill ESRCH
test-skeleton.c forks in every test, so on nios2 this showed up as
failures in tst-basic3, tst-cancel21, tst-cancelx21, tst-clockid,
tst-fork4, tst-join1, tst-kill5 and tst-mutex9; all of them pass now.
Checked the other targets while here: arm, i386, arc, xtensa, riscv,
aarch64 and nds32 select CLONE_BACKWARDS and microblaze
CLONE_BACKWARDS3, so their tid pointer in the last slot is correct; sh,
m68k, csky, or1k, alpha and x86_64 use the generic order and already
pass it in the fourth.
Signed-off-by: Ramin Moussavi <lordrasmus@gmail.com>