summaryrefslogtreecommitdiffstats
path: root/arch/openrisc
diff options
context:
space:
mode:
authorChristian Svensson <blue@cmd.nu>2014-01-25 15:48:54 +0000
committerStafford Horne <shorne@gmail.com>2016-12-12 23:09:28 +0900
commite60aa2fba4678d4e7e2d28ef4f2110084d0b150a (patch)
treee58233bd667ed5b9f012696144c055ae10c253eb /arch/openrisc
parentc79902190f7e61fcae7c3f4b613c75062f385678 (diff)
downloadlinux-stable-e60aa2fba4678d4e7e2d28ef4f2110084d0b150a.tar.gz
linux-stable-e60aa2fba4678d4e7e2d28ef4f2110084d0b150a.tar.bz2
linux-stable-e60aa2fba4678d4e7e2d28ef4f2110084d0b150a.zip
openrisc: Add thread-local storage (TLS) support
Historically OpenRISC GCC has reserved r10 which we now use to hold the thread pointer for thread-local storage (TLS). Signed-off-by: Christian Svensson <blue@cmd.nu> Signed-off-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi> Tested-by: Guenter Roeck <linux@roeck-us.net> Signed-off-by: Stafford Horne <shorne@gmail.com>
Diffstat (limited to 'arch/openrisc')
-rw-r--r--arch/openrisc/kernel/process.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 7095dfe7666b..277123bb4bf8 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -173,6 +173,19 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
if (usp)
userregs->sp = usp;
+
+ /*
+ * For CLONE_SETTLS set "tp" (r10) to the TLS pointer passed to sys_clone.
+ *
+ * The kernel entry is:
+ * int clone (long flags, void *child_stack, int *parent_tid,
+ * int *child_tid, struct void *tls)
+ *
+ * This makes the source r7 in the kernel registers.
+ */
+ if (clone_flags & CLONE_SETTLS)
+ userregs->gpr[10] = userregs->gpr[7];
+
userregs->gpr[11] = 0; /* Result from fork() */
kregs->gpr[20] = 0; /* Userspace thread */