Christian Svensson
2014-01-25 15:48:54 UTC
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 at cmd.nu>
---
arch/openrisc/kernel/process.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 386af25..6386097 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -173,6 +173,20 @@ 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.
+ */
+ if (clone_flags & CLONE_SETTLS)
+ userregs->gpr[10] = userregs->gpr[7];
+
userregs->gpr[11] = 0; /* Result from fork() */
kregs->gpr[20] = 0; /* Userspace thread */
--
1.9.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openrisc.net/pipermail/linux/attachments/20140712/448673d5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: or1k-tls.patch
Type: application/octet-stream
Size: 1236 bytes
Desc: not available
URL: <http://lists.openrisc.net/pipermail/linux/attachments/20140712/448673d5/attachment.obj>
the thread pointer for thread-local storage (TLS).
Signed-off-by: Christian Svensson <blue at cmd.nu>
---
arch/openrisc/kernel/process.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 386af25..6386097 100644
--- a/arch/openrisc/kernel/process.c
+++ b/arch/openrisc/kernel/process.c
@@ -173,6 +173,20 @@ 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.
+ */
+ if (clone_flags & CLONE_SETTLS)
+ userregs->gpr[10] = userregs->gpr[7];
+
userregs->gpr[11] = 0; /* Result from fork() */
kregs->gpr[20] = 0; /* Userspace thread */
--
1.9.3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openrisc.net/pipermail/linux/attachments/20140712/448673d5/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: or1k-tls.patch
Type: application/octet-stream
Size: 1236 bytes
Desc: not available
URL: <http://lists.openrisc.net/pipermail/linux/attachments/20140712/448673d5/attachment.obj>