* [PATCH] powerpc64: Implement TLS using PC-relative addressing
@ 2020-09-30 19:55 Tulio Magno Quites Machado Filho via Libc-alpha
2020-10-01 8:49 ` Florian Weimer via Libc-alpha
2020-10-01 9:01 ` Andreas Schwab
0 siblings, 2 replies; 9+ messages in thread
From: Tulio Magno Quites Machado Filho via Libc-alpha @ 2020-09-30 19:55 UTC (permalink / raw)
To: libc-alpha; +Cc: amodra
As the TOC pointer becomes optional on POWER, TLS access has to be
modified in order to use PC-relative addressing instead of depending on
the TOC pointer availability.
This patch also changes old TLS code to use the new syntax. It's a
purely aesthetical change: the old code still works and the new syntax
helps to move the argument setup instruction away from the call, which
is not used in an inline assembly.
Suggested-by: Alan Modra <amodra@gmail.com>
---
sysdeps/powerpc/mod-tlsopt-powerpc.c | 7 ++++
sysdeps/powerpc/powerpc64/tls-macros.h | 54 ++++++++++++++++++++++----
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
index ee0db12a73..5856dab60b 100644
--- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
@@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
tls_index *tls_arg;
#ifdef __powerpc64__
register unsigned long thread_pointer __asm__ ("r13");
+ /* PC-relative addressing is available when compiling with -mpcrel.
+ The first releases of GCC 10 do support -mpcrel, but do not export
+ __PCREL__. */
+# if defined(__PCREL__) || __GNUC__ <= 10 && defined(_ARCH_PWR10)
+ asm ("pla %0,foo@got@tlsgd@pcrel" : "=r" (tls_arg));
+# else
asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
+# endif
#else
register unsigned long thread_pointer __asm__ ("r2");
asm ("bcl 20,31,1f\n1:\t"
diff --git a/sysdeps/powerpc/powerpc64/tls-macros.h b/sysdeps/powerpc/powerpc64/tls-macros.h
index 79a0b2579c..955f8e88da 100644
--- a/sysdeps/powerpc/powerpc64/tls-macros.h
+++ b/sysdeps/powerpc/powerpc64/tls-macros.h
@@ -9,20 +9,56 @@
: "=b" (__result) ); \
__result; \
})
-/* PowerPC64 Initial Exec TLS access. */
-#define TLS_IE(x) \
+
+/* PC-relative addressing is available when compiling with -mpcrel.
+ The first releases of GCC 10 do support -mpcrel, but do not export
+ __PCREL__. */
+#if defined(__PCREL__) || __GNUC__ <= 10 && defined(_ARCH_PWR10)
+/* PowerPC64 Initial Exec TLS access, PC-relative addressing. */
+# define TLS_IE(x) \
({ int * __result; \
- asm ("ld %0," #x "@got@tprel(2)\n\t" \
- "add %0,%0," #x "@tls" \
+ asm ("pld %0," #x "@got@tprel@pcrel\n\t" \
+ "add %0,%0," #x "@tls@pcrel" \
: "=r" (__result) ); \
__result; \
})
+/* PowerPC64 Local Dynamic TLS access, PC-relative addressing. */
+# define TLS_LD(x) \
+ ({ int * __result; \
+ asm ("pla 3, " #x "@got@tlsld@pcrel\n\t" \
+ "bl __tls_get_addr@notoc(" #x "@tlsld)\n\t" \
+ "addis %0,3," #x "@dtprel@ha\n\t" \
+ "addi %0,%0," #x "@dtprel@l" \
+ : "=b" (__result) : \
+ : "3", __TLS_CALL_CLOBBERS); \
+ __result; \
+ })
+
+/* PowerPC64 General Dynamic TLS access, PC-relative addressing. */
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ asm ("pla 3," #x "@got@tlsgd@pcrel\n\t" \
+ "bl __tls_get_addr@notoc(" #x "@tlsgd)" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; \
+ })
+#else
+/* PowerPC64 Initial Exec TLS access. */
+# define TLS_IE(x) \
+ ({ int * __result; \
+ asm ("ld %0," #x "@got@tprel(2)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=r" (__result) ); \
+ __result; \
+ })
+
/* PowerPC64 Local Dynamic TLS access. */
-#define TLS_LD(x) \
+# define TLS_LD(x) \
({ int * __result; \
asm ("addi 3,2," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr\n\t" \
+ "bl __tls_get_addr(" #x "@tlsld)\n\t" \
"nop \n\t" \
"addis %0,3," #x "@dtprel@ha\n\t" \
"addi %0,%0," #x "@dtprel@l" \
@@ -30,13 +66,15 @@
: "3", __TLS_CALL_CLOBBERS); \
__result; \
})
+
/* PowerPC64 General Dynamic TLS access. */
-#define TLS_GD(x) \
+# define TLS_GD(x) \
({ register int *__result __asm__ ("r3"); \
asm ("addi 3,2," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr\n\t" \
+ "bl __tls_get_addr(" #x "@tlsgd)\n\t" \
"nop " \
: "=r" (__result) : \
: __TLS_CALL_CLOBBERS); \
__result; \
})
+#endif
--
2.25.4
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc64: Implement TLS using PC-relative addressing
2020-09-30 19:55 [PATCH] powerpc64: Implement TLS using PC-relative addressing Tulio Magno Quites Machado Filho via Libc-alpha
@ 2020-10-01 8:49 ` Florian Weimer via Libc-alpha
2020-10-01 11:15 ` Alan Modra via Libc-alpha
2020-10-01 9:01 ` Andreas Schwab
1 sibling, 1 reply; 9+ messages in thread
From: Florian Weimer via Libc-alpha @ 2020-10-01 8:49 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho via Libc-alpha
Cc: Tulio Magno Quites Machado Filho, amodra
* Tulio Magno Quites Machado Filho via Libc-alpha:
> diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> index ee0db12a73..5856dab60b 100644
> --- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
> +++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> @@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
> tls_index *tls_arg;
> #ifdef __powerpc64__
> register unsigned long thread_pointer __asm__ ("r13");
> + /* PC-relative addressing is available when compiling with -mpcrel.
> + The first releases of GCC 10 do support -mpcrel, but do not export
> + __PCREL__. */
> +# if defined(__PCREL__) || __GNUC__ <= 10 && defined(_ARCH_PWR10)
> + asm ("pla %0,foo@got@tlsgd@pcrel" : "=r" (tls_arg));
> +# else
> asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
> +# endif
Should this check for binutils support for @pcrel? Or won't GCC enable
_ARCH_PWR10 in this case?
Thanks,
Florian
--
Red Hat GmbH, https://de.redhat.com/ , Registered seat: Grasbrunn,
Commercial register: Amtsgericht Muenchen, HRB 153243,
Managing Directors: Charles Cachera, Brian Klemm, Laurie Krebs, Michael O'Neill
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc64: Implement TLS using PC-relative addressing
2020-09-30 19:55 [PATCH] powerpc64: Implement TLS using PC-relative addressing Tulio Magno Quites Machado Filho via Libc-alpha
2020-10-01 8:49 ` Florian Weimer via Libc-alpha
@ 2020-10-01 9:01 ` Andreas Schwab
2021-01-22 1:29 ` [PATCHv2] " Tulio Magno Quites Machado Filho via Libc-alpha
1 sibling, 1 reply; 9+ messages in thread
From: Andreas Schwab @ 2020-10-01 9:01 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho via Libc-alpha
Cc: Tulio Magno Quites Machado Filho, amodra
On Sep 30 2020, Tulio Magno Quites Machado Filho via Libc-alpha wrote:
> diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> index ee0db12a73..5856dab60b 100644
> --- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
> +++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> @@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
> tls_index *tls_arg;
> #ifdef __powerpc64__
> register unsigned long thread_pointer __asm__ ("r13");
> + /* PC-relative addressing is available when compiling with -mpcrel.
> + The first releases of GCC 10 do support -mpcrel, but do not export
> + __PCREL__. */
> +# if defined(__PCREL__) || __GNUC__ <= 10 && defined(_ARCH_PWR10)
Space after defined, and remove the parens.
Andreas.
--
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1
"And now for something completely different."
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] powerpc64: Implement TLS using PC-relative addressing
2020-10-01 8:49 ` Florian Weimer via Libc-alpha
@ 2020-10-01 11:15 ` Alan Modra via Libc-alpha
0 siblings, 0 replies; 9+ messages in thread
From: Alan Modra via Libc-alpha @ 2020-10-01 11:15 UTC (permalink / raw)
To: Florian Weimer
Cc: Tulio Magno Quites Machado Filho,
Tulio Magno Quites Machado Filho via Libc-alpha
On Thu, Oct 01, 2020 at 10:49:43AM +0200, Florian Weimer wrote:
> * Tulio Magno Quites Machado Filho via Libc-alpha:
>
> > diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> > index ee0db12a73..5856dab60b 100644
> > --- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
> > +++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> > @@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
> > tls_index *tls_arg;
> > #ifdef __powerpc64__
> > register unsigned long thread_pointer __asm__ ("r13");
> > + /* PC-relative addressing is available when compiling with -mpcrel.
> > + The first releases of GCC 10 do support -mpcrel, but do not export
> > + __PCREL__. */
> > +# if defined(__PCREL__) || __GNUC__ <= 10 && defined(_ARCH_PWR10)
> > + asm ("pla %0,foo@got@tlsgd@pcrel" : "=r" (tls_arg));
> > +# else
> > asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
> > +# endif
>
> Should this check for binutils support for @pcrel? Or won't GCC enable
> _ARCH_PWR10 in this case?
Right, gcc doesn't support power10 without the requisite binutils
support. In any case, this file is only used when running the
testsuite so it hardly seems worth the bother of configure checks.
The patch looks good to me.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCHv2] powerpc64: Implement TLS using PC-relative addressing
2020-10-01 9:01 ` Andreas Schwab
@ 2021-01-22 1:29 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 15:20 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 17:13 ` Adhemerval Zanella via Libc-alpha
0 siblings, 2 replies; 9+ messages in thread
From: Tulio Magno Quites Machado Filho via Libc-alpha @ 2021-01-22 1:29 UTC (permalink / raw)
To: libc-alpha; +Cc: Andreas Schwab, amodra
Changes since v1:
- Dropped the workaround for early GCC 10 versions. We can't get this
code to work without having the macro __PCREL__. The previous code
was failing if -mcpu=power10 -mno-pcrel was used.
- Fixed coding style issues (added space after #defined and removed
unnecessary parenthesis).
---8<---
As the TOC pointer becomes optional on POWER, TLS access has to be
modified in order to use PC-relative addressing instead of depending on
the TOC pointer availability.
This patch also changes old TLS code to use the new syntax. It's a
purely aesthetical change: the old code still works and the new syntax
helps to move the argument setup instruction away from the call, which
is not used in an inline assembly.
Suggested-by: Alan Modra <amodra@gmail.com>
---
sysdeps/powerpc/mod-tlsopt-powerpc.c | 7 ++++
sysdeps/powerpc/powerpc64/tls-macros.h | 54 ++++++++++++++++++++++----
2 files changed, 53 insertions(+), 8 deletions(-)
diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
index ee0db12a73..ecfa11cb95 100644
--- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
+++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
@@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
tls_index *tls_arg;
#ifdef __powerpc64__
register unsigned long thread_pointer __asm__ ("r13");
+ /* PC-relative addressing is available when compiling with -mpcrel.
+ The first releases of GCC 10 do support -mpcrel, but do not export
+ __PCREL__. */
+# if defined __PCREL__
+ asm ("pla %0,foo@got@tlsgd@pcrel" : "=r" (tls_arg));
+# else
asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
+# endif
#else
register unsigned long thread_pointer __asm__ ("r2");
asm ("bcl 20,31,1f\n1:\t"
diff --git a/sysdeps/powerpc/powerpc64/tls-macros.h b/sysdeps/powerpc/powerpc64/tls-macros.h
index 79a0b2579c..a0e5c4a832 100644
--- a/sysdeps/powerpc/powerpc64/tls-macros.h
+++ b/sysdeps/powerpc/powerpc64/tls-macros.h
@@ -9,20 +9,56 @@
: "=b" (__result) ); \
__result; \
})
-/* PowerPC64 Initial Exec TLS access. */
-#define TLS_IE(x) \
+
+/* PC-relative addressing is available when compiling with -mpcrel.
+ The first releases of GCC 10 do support -mpcrel, but do not export
+ __PCREL__. */
+#if defined __PCREL__
+/* PowerPC64 Initial Exec TLS access, PC-relative addressing. */
+# define TLS_IE(x) \
({ int * __result; \
- asm ("ld %0," #x "@got@tprel(2)\n\t" \
- "add %0,%0," #x "@tls" \
+ asm ("pld %0," #x "@got@tprel@pcrel\n\t" \
+ "add %0,%0," #x "@tls@pcrel" \
: "=r" (__result) ); \
__result; \
})
+/* PowerPC64 Local Dynamic TLS access, PC-relative addressing. */
+# define TLS_LD(x) \
+ ({ int * __result; \
+ asm ("pla 3, " #x "@got@tlsld@pcrel\n\t" \
+ "bl __tls_get_addr@notoc(" #x "@tlsld)\n\t" \
+ "addis %0,3," #x "@dtprel@ha\n\t" \
+ "addi %0,%0," #x "@dtprel@l" \
+ : "=b" (__result) : \
+ : "3", __TLS_CALL_CLOBBERS); \
+ __result; \
+ })
+
+/* PowerPC64 General Dynamic TLS access, PC-relative addressing. */
+# define TLS_GD(x) \
+ ({ register int *__result __asm__ ("r3"); \
+ asm ("pla 3," #x "@got@tlsgd@pcrel\n\t" \
+ "bl __tls_get_addr@notoc(" #x "@tlsgd)" \
+ : "=r" (__result) : \
+ : __TLS_CALL_CLOBBERS); \
+ __result; \
+ })
+#else
+/* PowerPC64 Initial Exec TLS access. */
+# define TLS_IE(x) \
+ ({ int * __result; \
+ asm ("ld %0," #x "@got@tprel(2)\n\t" \
+ "add %0,%0," #x "@tls" \
+ : "=r" (__result) ); \
+ __result; \
+ })
+
/* PowerPC64 Local Dynamic TLS access. */
-#define TLS_LD(x) \
+# define TLS_LD(x) \
({ int * __result; \
asm ("addi 3,2," #x "@got@tlsld\n\t" \
- "bl __tls_get_addr\n\t" \
+ "bl __tls_get_addr(" #x "@tlsld)\n\t" \
"nop \n\t" \
"addis %0,3," #x "@dtprel@ha\n\t" \
"addi %0,%0," #x "@dtprel@l" \
@@ -30,13 +66,15 @@
: "3", __TLS_CALL_CLOBBERS); \
__result; \
})
+
/* PowerPC64 General Dynamic TLS access. */
-#define TLS_GD(x) \
+# define TLS_GD(x) \
({ register int *__result __asm__ ("r3"); \
asm ("addi 3,2," #x "@got@tlsgd\n\t" \
- "bl __tls_get_addr\n\t" \
+ "bl __tls_get_addr(" #x "@tlsgd)\n\t" \
"nop " \
: "=r" (__result) : \
: __TLS_CALL_CLOBBERS); \
__result; \
})
+#endif
--
2.29.2
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCHv2] powerpc64: Implement TLS using PC-relative addressing
2021-01-22 1:29 ` [PATCHv2] " Tulio Magno Quites Machado Filho via Libc-alpha
@ 2021-01-25 15:20 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 17:13 ` Adhemerval Zanella via Libc-alpha
1 sibling, 0 replies; 9+ messages in thread
From: Tulio Magno Quites Machado Filho via Libc-alpha @ 2021-01-25 15:20 UTC (permalink / raw)
To: libc-alpha, Adhemerval Zanella; +Cc: Andreas Schwab, amodra
Tulio Magno Quites Machado Filho via Libc-alpha <libc-alpha@sourceware.org> writes:
> Changes since v1:
> - Dropped the workaround for early GCC 10 versions. We can't get this
> code to work without having the macro __PCREL__. The previous code
> was failing if -mcpu=power10 -mno-pcrel was used.
> - Fixed coding style issues (added space after #defined and removed
> unnecessary parenthesis).
>
> ---8<---
>
> As the TOC pointer becomes optional on POWER, TLS access has to be
> modified in order to use PC-relative addressing instead of depending on
> the TOC pointer availability.
>
> This patch also changes old TLS code to use the new syntax. It's a
> purely aesthetical change: the old code still works and the new syntax
> helps to move the argument setup instruction away from the call, which
> is not used in an inline assembly.
>
> Suggested-by: Alan Modra <amodra@gmail.com>
Adhemerval,
I've just realized I forgot to Cc you in this patch.
It's fixing test failures when building glibc using --with-cpu=power10.
May we merge it for 2.33?
--
Tulio Magno
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv2] powerpc64: Implement TLS using PC-relative addressing
2021-01-22 1:29 ` [PATCHv2] " Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 15:20 ` Tulio Magno Quites Machado Filho via Libc-alpha
@ 2021-01-25 17:13 ` Adhemerval Zanella via Libc-alpha
2021-01-25 20:22 ` Tulio Magno Quites Machado Filho via Libc-alpha
1 sibling, 1 reply; 9+ messages in thread
From: Adhemerval Zanella via Libc-alpha @ 2021-01-25 17:13 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho, libc-alpha; +Cc: Andreas Schwab, amodra
On 21/01/2021 22:29, Tulio Magno Quites Machado Filho via Libc-alpha wrote:
> Changes since v1:
> - Dropped the workaround for early GCC 10 versions. We can't get this
> code to work without having the macro __PCREL__. The previous code
> was failing if -mcpu=power10 -mno-pcrel was used.
> - Fixed coding style issues (added space after #defined and removed
> unnecessary parenthesis).
>
> ---8<---
>
> As the TOC pointer becomes optional on POWER, TLS access has to be
> modified in order to use PC-relative addressing instead of depending on
> the TOC pointer availability.
>
> This patch also changes old TLS code to use the new syntax. It's a
> purely aesthetical change: the old code still works and the new syntax
> helps to move the argument setup instruction away from the call, which
> is not used in an inline assembly.
>
> Suggested-by: Alan Modra <amodra@gmail.com>
> ---
> sysdeps/powerpc/mod-tlsopt-powerpc.c | 7 ++++
> sysdeps/powerpc/powerpc64/tls-macros.h | 54 ++++++++++++++++++++++----
> 2 files changed, 53 insertions(+), 8 deletions(-)
>
> diff --git a/sysdeps/powerpc/mod-tlsopt-powerpc.c b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> index ee0db12a73..ecfa11cb95 100644
> --- a/sysdeps/powerpc/mod-tlsopt-powerpc.c
> +++ b/sysdeps/powerpc/mod-tlsopt-powerpc.c
> @@ -24,7 +24,14 @@ tls_get_addr_opt_test (void)
> tls_index *tls_arg;
> #ifdef __powerpc64__
> register unsigned long thread_pointer __asm__ ("r13");
> + /* PC-relative addressing is available when compiling with -mpcrel.
> + The first releases of GCC 10 do support -mpcrel, but do not export
> + __PCREL__. */
> +# if defined __PCREL__
> + asm ("pla %0,foo@got@tlsgd@pcrel" : "=r" (tls_arg));
> +# else
> asm ("addi %0,2,foo@got@tlsgd" : "=r" (tls_arg));
> +# endif
> #else
> register unsigned long thread_pointer __asm__ ("r2");
> asm ("bcl 20,31,1f\n1:\t"
The 'pla/pld' instruction support was added in binutils 2.33 version
(PowerPC D-form prefixed loads and stores, commit 8acf14351c8),
however the current idea is to set the minimal version for powerpc
to 2.29 [1].
The tls-macros.h is used solely for testing and if I understood
correctly -mpcrel should not require extra glibc support (so there
is no compiling reason to increase the current proposal of minimal
binutils to 2.33).
So, what I recommend you to do is:
1. Change the documentation patch [1] and update the powerpc
sysdeps/powerpc/powerpc64/le/configure.ac to check 'as' version
instead of 'objcopy'.
2. Add a configure check for the new TLS using PC-relative and
set a new config.h flag (SUPPORT_PPC_TLS_PCREL).
3. Use it instead of __PCREL__ on internal testing.
[1] https://sourceware.org/pipermail/libc-alpha/2021-January/121919.html
> diff --git a/sysdeps/powerpc/powerpc64/tls-macros.h b/sysdeps/powerpc/powerpc64/tls-macros.h
> index 79a0b2579c..a0e5c4a832 100644
> --- a/sysdeps/powerpc/powerpc64/tls-macros.h
> +++ b/sysdeps/powerpc/powerpc64/tls-macros.h
> @@ -9,20 +9,56 @@
> : "=b" (__result) ); \
> __result; \
> })
> -/* PowerPC64 Initial Exec TLS access. */
> -#define TLS_IE(x) \
> +
> +/* PC-relative addressing is available when compiling with -mpcrel.
> + The first releases of GCC 10 do support -mpcrel, but do not export
> + __PCREL__. */
> +#if defined __PCREL__
> +/* PowerPC64 Initial Exec TLS access, PC-relative addressing. */
> +# define TLS_IE(x) \
> ({ int * __result; \
> - asm ("ld %0," #x "@got@tprel(2)\n\t" \
> - "add %0,%0," #x "@tls" \
> + asm ("pld %0," #x "@got@tprel@pcrel\n\t" \
> + "add %0,%0," #x "@tls@pcrel" \
> : "=r" (__result) ); \
> __result; \
> })
>
> +/* PowerPC64 Local Dynamic TLS access, PC-relative addressing. */
> +# define TLS_LD(x) \
> + ({ int * __result; \
> + asm ("pla 3, " #x "@got@tlsld@pcrel\n\t" \
> + "bl __tls_get_addr@notoc(" #x "@tlsld)\n\t" \
> + "addis %0,3," #x "@dtprel@ha\n\t" \
> + "addi %0,%0," #x "@dtprel@l" \
> + : "=b" (__result) : \
> + : "3", __TLS_CALL_CLOBBERS); \
> + __result; \
> + })
> +
> +/* PowerPC64 General Dynamic TLS access, PC-relative addressing. */
> +# define TLS_GD(x) \
> + ({ register int *__result __asm__ ("r3"); \
> + asm ("pla 3," #x "@got@tlsgd@pcrel\n\t" \
> + "bl __tls_get_addr@notoc(" #x "@tlsgd)" \
> + : "=r" (__result) : \
> + : __TLS_CALL_CLOBBERS); \
> + __result; \
> + })
> +#else
> +/* PowerPC64 Initial Exec TLS access. */
> +# define TLS_IE(x) \
> + ({ int * __result; \
> + asm ("ld %0," #x "@got@tprel(2)\n\t" \
> + "add %0,%0," #x "@tls" \
> + : "=r" (__result) ); \
> + __result; \
> + })
> +
> /* PowerPC64 Local Dynamic TLS access. */
> -#define TLS_LD(x) \
> +# define TLS_LD(x) \
> ({ int * __result; \
> asm ("addi 3,2," #x "@got@tlsld\n\t" \
> - "bl __tls_get_addr\n\t" \
> + "bl __tls_get_addr(" #x "@tlsld)\n\t" \
> "nop \n\t" \
> "addis %0,3," #x "@dtprel@ha\n\t" \
> "addi %0,%0," #x "@dtprel@l" \
> @@ -30,13 +66,15 @@
> : "3", __TLS_CALL_CLOBBERS); \
> __result; \
> })
> +
> /* PowerPC64 General Dynamic TLS access. */
> -#define TLS_GD(x) \
> +# define TLS_GD(x) \
> ({ register int *__result __asm__ ("r3"); \
> asm ("addi 3,2," #x "@got@tlsgd\n\t" \
> - "bl __tls_get_addr\n\t" \
> + "bl __tls_get_addr(" #x "@tlsgd)\n\t" \
> "nop " \
> : "=r" (__result) : \
> : __TLS_CALL_CLOBBERS); \
> __result; \
> })
> +#endif
>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv2] powerpc64: Implement TLS using PC-relative addressing
2021-01-25 17:13 ` Adhemerval Zanella via Libc-alpha
@ 2021-01-25 20:22 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-27 11:16 ` Alan Modra via Libc-alpha
0 siblings, 1 reply; 9+ messages in thread
From: Tulio Magno Quites Machado Filho via Libc-alpha @ 2021-01-25 20:22 UTC (permalink / raw)
To: Adhemerval Zanella, libc-alpha; +Cc: Andreas Schwab, amodra
Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:
> On 21/01/2021 22:29, Tulio Magno Quites Machado Filho via Libc-alpha wrote:
> So, what I recommend you to do is:
>
> 1. Change the documentation patch [1] and update the powerpc
> sysdeps/powerpc/powerpc64/le/configure.ac to check 'as' version
> instead of 'objcopy'.
This has already been changed in the following patch:
https://sourceware.org/pipermail/libc-alpha/2021-January/121919.html
It's still missing the configure check, though. I'm working on that.
> 2. Add a configure check for the new TLS using PC-relative and
> set a new config.h flag (SUPPORT_PPC_TLS_PCREL).
Ack. I'm working on it.
Thanks!
--
Tulio Magno
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCHv2] powerpc64: Implement TLS using PC-relative addressing
2021-01-25 20:22 ` Tulio Magno Quites Machado Filho via Libc-alpha
@ 2021-01-27 11:16 ` Alan Modra via Libc-alpha
0 siblings, 0 replies; 9+ messages in thread
From: Alan Modra via Libc-alpha @ 2021-01-27 11:16 UTC (permalink / raw)
To: Tulio Magno Quites Machado Filho; +Cc: Andreas Schwab, libc-alpha
On Mon, Jan 25, 2021 at 05:22:02PM -0300, Tulio Magno Quites Machado Filho wrote:
> Adhemerval Zanella via Libc-alpha <libc-alpha@sourceware.org> writes:
>
> > On 21/01/2021 22:29, Tulio Magno Quites Machado Filho via Libc-alpha wrote:
>
> > So, what I recommend you to do is:
> >
> > 1. Change the documentation patch [1] and update the powerpc
> > sysdeps/powerpc/powerpc64/le/configure.ac to check 'as' version
> > instead of 'objcopy'.
>
> This has already been changed in the following patch:
> https://sourceware.org/pipermail/libc-alpha/2021-January/121919.html
>
> It's still missing the configure check, though. I'm working on that.
>
> > 2. Add a configure check for the new TLS using PC-relative and
> > set a new config.h flag (SUPPORT_PPC_TLS_PCREL).
>
> Ack. I'm working on it.
mod-tlsopt-powerpc.c and tls-macros.h are used only by the
testsuite, so don't fuss too much. Hopefully one day those files will
disappear.
--
Alan Modra
Australia Development Lab, IBM
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-01-27 11:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-30 19:55 [PATCH] powerpc64: Implement TLS using PC-relative addressing Tulio Magno Quites Machado Filho via Libc-alpha
2020-10-01 8:49 ` Florian Weimer via Libc-alpha
2020-10-01 11:15 ` Alan Modra via Libc-alpha
2020-10-01 9:01 ` Andreas Schwab
2021-01-22 1:29 ` [PATCHv2] " Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 15:20 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-25 17:13 ` Adhemerval Zanella via Libc-alpha
2021-01-25 20:22 ` Tulio Magno Quites Machado Filho via Libc-alpha
2021-01-27 11:16 ` Alan Modra via Libc-alpha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).