[PATCH v15 6/8] nptl: Move the rseq area to the 'extra TLS' block
Michael Jeanson
mjeanson@efficios.com
Wed Jan 8 18:19:47 GMT 2025
On 2025-01-08 12:06, Florian Weimer wrote:
> * Michael Jeanson:
>
>> On 2025-01-08 04:40, Florian Weimer wrote:
>>> * Michael Jeanson:
>>>
>>>> +#if TLS_TCB_AT_TP
>>>> + /* The rseq area block should come before the thread pointer and be at least
>>>> + 32 bytes. */
>>>> + TEST_VERIFY (__rseq_offset <= -RSEQ_AREA_SIZE_INITIAL);
>>>> +#elif TLS_DTV_AT_TP
>>>> + /* The rseq area block should come after the thread pointer. */
>>>> + TEST_VERIFY (__rseq_offset + TLS_TP_OFFSET >= 0);
>>>
>>> I think the TLS_TP_OFFSET is redudant here. It's supposed have already
>>> been folded into __rseq_offset. It certainly was before because a
>>> pointer difference was used to compute it.
>>
>> I should have updated the comment here, I'm testing that the rseq area
>> comes after the TCB on TLS_DTV_AT_TP architectures, my first iteration
>> looked like this:
>>
>> TEST_VERIFY (__rseq_offset >= -TLS_TP_OFFSET);
>>
>> but I felt it was not very readable.
>>
>> Would this be better?
>>
>> + /* The rseq area block should come after the TCB, add the TLS block
>> + offset to the rseq offset to get a value relative to the TCB and
>> + test that it's positive. */
>> + TEST_VERIFY (__rseq_offset + TLS_TP_OFFSET >= 0);
>
> The comment helps, but it should say non-negative to match the actual
> comparison?
Ack.
>
> In addition you could define a variable
>
> static __thread char thread_var __attribute__ ((tls_model ("initial-exec")));
>
> and check that the effective rseq address is greater than &thread_var.
I like this, I'll add this test.
Thanks,
Michael
More information about the Libc-alpha
mailing list