Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1485062 > unrolled thread

[PATCH 4/7] openrisc: Add thread-local storage (TLS) support

Started byStafford Horne <shorne@gmail.com>
First post2016-09-16 16:50 +0200
Last post2016-09-19 16:50 +0200
Articles 3 — 2 participants

Back to article view | Back to linux.kernel

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  [PATCH 4/7] openrisc: Add thread-local storage (TLS) support Stafford Horne <shorne@gmail.com> - 2016-09-16 16:50 +0200
    Re: [PATCH 4/7] openrisc: Add thread-local storage (TLS) support Stafford Horne <shorne@gmail.com> - 2016-09-19 16:50 +0200
    Re: [PATCH 4/7] openrisc: Add thread-local storage (TLS) support Jonas Bonn <jonas@southpole.se> - 2016-09-19 16:50 +0200

#1485062 — [PATCH 4/7] openrisc: Add thread-local storage (TLS) support

FromStafford Horne <shorne@gmail.com>
Date2016-09-16 16:50 +0200
Subject[PATCH 4/7] openrisc: Add thread-local storage (TLS) support
Message-ID<si2CK-608-5@gated-at.bofh.it>
From: Christian Svensson <blue@cmd.nu>

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>
Signed-off-by: Stafford Horne <shorne@gmail.com>
---
 arch/openrisc/kernel/process.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
index 7095dfe..277123b 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 */
-- 
2.7.4

[toc] | [next] | [standalone]


#1486561

FromStafford Horne <shorne@gmail.com>
Date2016-09-19 16:50 +0200
Message-ID<sj83p-6ES-45@gated-at.bofh.it>
In reply to#1485062

On Mon, 19 Sep 2016, Jonas Bonn wrote:

> On 09/16/2016 04:43 PM, Stafford Horne wrote:
>>  From: Christian Svensson <blue@cmd.nu>
>>
>>  Historically OpenRISC GCC has reserved r10 which we now use to hold
>>  the thread pointer for thread-local storage (TLS).
> I know this was proposed by way of this patch, but we deferred accepting this 
> until the OpenRISC spec could be updated accordingly.  Has this been done 
> now?  If not, still NAK.

Hi Jonas,

Thanks for your review, I do not believe the spec has been updated. I will 
look into seeing what I can do and update the patch if needed.

-Stafford

>>
>>  Signed-off-by: Christian Svensson <blue@cmd.nu>
>>  Signed-off-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
>>  Signed-off-by: Stafford Horne <shorne@gmail.com>
>>  ---
>>    arch/openrisc/kernel/process.c | 13 +++++++++++++
>>    1 file changed, 13 insertions(+)
>>
>>  diff --git a/arch/openrisc/kernel/process.c
>>  b/arch/openrisc/kernel/process.c
>>  index 7095dfe..277123b 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 */
>
>
>

[toc] | [prev] | [next] | [standalone]


#1486564

FromJonas Bonn <jonas@southpole.se>
Date2016-09-19 16:50 +0200
Message-ID<sj83p-6ES-47@gated-at.bofh.it>
In reply to#1485062
On 09/16/2016 04:43 PM, Stafford Horne wrote:
> From: Christian Svensson <blue@cmd.nu>
>
> Historically OpenRISC GCC has reserved r10 which we now use to hold
> the thread pointer for thread-local storage (TLS).
I know this was proposed by way of this patch, but we deferred accepting 
this until the OpenRISC spec could be updated accordingly.  Has this 
been done now?  If not, still NAK.

/Jonas

>
> Signed-off-by: Christian Svensson <blue@cmd.nu>
> Signed-off-by: Stefan Kristiansson <stefan.kristiansson@saunalahti.fi>
> Signed-off-by: Stafford Horne <shorne@gmail.com>
> ---
>   arch/openrisc/kernel/process.c | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
>
> diff --git a/arch/openrisc/kernel/process.c b/arch/openrisc/kernel/process.c
> index 7095dfe..277123b 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 */

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web