Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e60aa2fb authored by Christian Svensson's avatar Christian Svensson Committed by Stafford Horne
Browse files

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: default avatarChristian Svensson <blue@cmd.nu>
Signed-off-by: default avatarStefan Kristiansson <stefan.kristiansson@saunalahti.fi>
Tested-by: default avatarGuenter Roeck <linux@roeck-us.net>
Signed-off-by: default avatarStafford Horne <shorne@gmail.com>
parent c7990219
Loading
Loading
Loading
Loading
+13 −0
Original line number Original line Diff line number Diff line
@@ -173,6 +173,19 @@ copy_thread(unsigned long clone_flags, unsigned long usp,


		if (usp)
		if (usp)
			userregs->sp = 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() */
		userregs->gpr[11] = 0;	/* Result from fork() */


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