Skip to content

Commit e60aa2f

Browse files
bluecmdstffrdhrn
authored andcommitted
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>
1 parent c799021 commit e60aa2f

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

‎arch/openrisc/kernel/process.c‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,19 @@ copy_thread(unsigned long clone_flags, unsigned long usp,
173173

174174
if (usp)
175175
userregs->sp = usp;
176+
177+
/*
178+
* For CLONE_SETTLS set "tp" (r10) to the TLS pointer passed to sys_clone.
179+
*
180+
* The kernel entry is:
181+
* int clone (long flags, void *child_stack, int *parent_tid,
182+
* int *child_tid, struct void *tls)
183+
*
184+
* This makes the source r7 in the kernel registers.
185+
*/
186+
if (clone_flags & CLONE_SETTLS)
187+
userregs->gpr[10] = userregs->gpr[7];
188+
176189
userregs->gpr[11] = 0; /* Result from fork() */
177190

178191
kregs->gpr[20] = 0; /* Userspace thread */

0 commit comments

Comments
 (0)