[PATCH v14 0/9] Add rseq extensible ABI support

Florian Weimer fweimer@redhat.com
Mon Dec 30 10:06:58 GMT 2024


* Florian Weimer:

> * Mathieu Desnoyers:
>
>>> So it looks like that TLS_DTV_AT_TP part doesn't work, unfortunately.
>>> I see many new failures (after the mentioned revert) on powerpc64le,
>>> which is one of those targets.  I haven't tried to reproduce them yet
>>> on AArch64.  The GCC compile farm has a powerpc64le test machine
>>> (gcc120.fsffrance.org).
>>
>> I recall that Michael did test on at least one architecture
>> with TLS_DTV_AT_TP (aarch64), and one with TLS_TCB_AT_TP (x86-64).
>>
>> The issue may be specific to powerpc.
>
> Maybe it's caused by a non-zero TLS_TP_OFFSET.  We use a shifted thread
> pointer on POWER, presumably to increase the reach of signed
> displacements in TLS-accessing instructions.
>
> This is alluded to in this comment:
>
> #ifdef RSEQ_SIG
>     /* This should be a compile-time constant, but the current
>        infrastructure makes it difficult to determine its value.  Not
>        all targets support __thread_pointer, so set __rseq_offset only
>        if the rseq registration may have happened because RSEQ_SIG is
>        defined.  */
>     _rseq_offset = (char *) &pd->rseq_area - (char *) __thread_pointer ();
> #endif
>
> If this is indeed the cause, we should define TLS_TP_OFFSET on all
> architectures and use it to initialize __rseq_offset.  Similar to what I
> started here:
>
>   [PATCH 1/4] elf: Introduce generic <dl-tls.h>
>   <https://inbox.sourceware.org/libc-alpha/1b470b147d0bfe51af6256b10cd38c14285a61b2.1735313702.git.fweimer@redhat.com/>

With

diff --git a/elf/dl-tls.c b/elf/dl-tls.c
index 57e72be4..1055032a 100644
--- a/elf/dl-tls.c
+++ b/elf/dl-tls.c
@@ -419,7 +419,7 @@ _dl_determine_tlsoffset (void)
     The alignment requirements of the pointer resulting from this offset and
     the thread pointer are enforced by 'max_align' which is used to align the
     tcb_offset.  */
-  _dl_extra_tls_set_offset(offset);
+  _dl_extra_tls_set_offset(offset - TLS_TP_OFFSET);
 
   /* Add the extra TLS block to the global offset.  */
   offset += extra_tls_size;

the results look better, but I'm not sure if this is the correct fix.

I see crashes on the scv 0 instruction in statically linked binaries.
Looks like the TCB placement is wrong and the flag that indicates
support for the new system call instruction (scv 0) is not loaded
correctly.

Thanks,
Florian



More information about the Libc-alpha mailing list