[PATCH] x86-64: Move nptl/rseq-access.h to nptl/64 [BZ #32543]
Mathieu Desnoyers
mathieu.desnoyers@efficios.com
Sat Jan 11 15:19:40 GMT 2025
On 11-Jan-2025 10:41:10 AM, Florian Weimer wrote:
> * H. J. Lu:
>
> > commit 494d65129ed5ae1154b75cc189bbdde5e9ecf1df
> > Author: Michael Jeanson <mjeanson@efficios.com>
> > Date: Thu Aug 1 10:35:34 2024 -0400
> >
> > nptl: Introduce <rseq-access.h> for RSEQ_* accessors
> >
> > added things like
> >
> > asm volatile ("movl %%fs:%P1(%q2),%0" \
> > : "=r" (__value) \
> > : "i" (offsetof (struct rseq_area, member)), \
> > "r" (__rseq_offset));
> >
> > But this doesn't work for x32 when __rseq_offset is negative since the
> > address is computed as
> >
> > FS + 32-bit to 64-bit zero extension of __rseq_offset
> > + offsetof (struct rseq_area, member)
> >
> > Move x86_64/nptl/rseq-access.h to x86_64/nptl/64/rseq-access.h so that
> > sysdeps/nptl/rseq-access.h is used for x32. This fixes BZ #32543.
>
> Would this work on x86-64 and x86-64 x32?
>
> asm volatile ("movl %%fs:%P1(%q2),%0" \
> : "=r" (__value) \
> : "i" (offsetof (struct rseq_area, member)), \
> "r" ((long long int) __rseq_offset));
__rseq_offset is a ptrdiff_t, which is indeed an issue specifically on
x32 because ptrdiff_t has size 4 and gets zero-extended to 64-bit.
The fix proposed by Florian is better than using the generic
sysdeps/nptl/rseq-access.h because it benefits from using the
%%fs segment selector prefix on x32 rather than compute the offset
based on __builtin_thread_pointer() with more instructions.
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
More information about the Libc-alpha
mailing list