linux/arch/arc
Vineet Gupta 89982d3bc8 ARC: clone syscall to setp r25 as thread pointer
commit c58a584f05 upstream.

Per ARC TLS ABI, r25 is designated TP (thread pointer register).
However so far kernel didn't do any special treatment, like setting up
usermode r25, even for CLONE_SETTLS. We instead relied on libc runtime
to do this, in say clone libc wrapper [1]. This was deliberate to keep
kernel ABI agnostic (userspace could potentially change TP, specially
for different ARC ISA say ARCompact vs. ARCv2 with different spare
registers etc)

However userspace setting up r25, after clone syscall opens a race, if
child is not scheduled and gets a signal instead. It starts off in
userspace not in clone but in a signal handler and anything TP sepcific
there such as pthread_self() fails which showed up with uClibc
testsuite nptl/tst-kill6 [2]

Fix this by having kernel populate r25 to TP value. So this locks in
ABI, but it was not going to change anyways, and fwiw is same for both
ARCompact (arc700 core) and ARCvs (HS3x cores)

[1] https://cgit.uclibc-ng.org/cgi/cgit/uclibc-ng.git/tree/libc/sysdeps/linux/arc/clone.S
[2] https://github.com/wbx-github/uclibc-ng-test/blob/master/test/nptl/tst-kill6.c

Fixes: ARC STAR 9001378481
Reported-by: Nikita Sobolev <sobolev@synopsys.com>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
History 2018-12-16 22:09:36 +00:00
..
boot ARC: [nsimosci] move peripherals to match model to FPGA 2015-01-15 10:44:08 +00:00
configs ARC: [nsimosci] Unbork console 2014-04-05 18:36:51 +05:30
include ARC: mm: allow mprotect to make stack mappings executable 2018-11-20 18:05:39 +00:00
kernel ARC: clone syscall to setp r25 as thread pointer 2018-12-16 22:09:36 +00:00
lib ARC: switch to generic ENTRY/END assembler annotations 2014-03-26 14:31:28 +05:30
mm ARC: Re-enable MMU upon Machine Check exception 2017-11-26 13:50:29 +00:00
oprofile ARC: OProfile support 2013-02-15 23:16:00 +05:30
plat-arcfpga ARC: [arcfpga] Early ARC UART to be only activated by cmdline 2014-06-03 14:20:09 +05:30
plat-tb10x ARC: [TB10x] Updates for GPIO and pinctrl 2013-11-11 09:57:44 +05:30
Kbuild ARC: Build system: Makefiles, Kconfig, Linker script 2013-02-11 20:00:25 +05:30
Kconfig Kconfig: rename HAS_IOPORT to HAS_IOPORT_MAP 2014-04-07 16:36:11 -07:00
Kconfig.debug consolidate per-arch stack overflow debugging options 2013-07-04 11:25:39 -07:00
Makefile ARC: unwind: ensure that .debug_frame is generated (vs. .eh_frame) 2016-08-22 22:38:22 +01:00