[PATCH v2] x86-64: Allocate state buffer space for RDI, RSI and RBX
H.J. Lu
hjl.tools@gmail.com
Sun Mar 17 12:57:16 GMT 2024
On Sun, Mar 17, 2024 at 4:39 AM H.J. Lu <hjl.tools@gmail.com> wrote:
>
> On Sun, Mar 17, 2024 at 1:26 AM Florian Weimer <fweimer@redhat.com> wrote:
> >
> > * H. J. Lu:
> >
> > > diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h
> > > index db8e576e91..262d4083e2 100644
> > > --- a/sysdeps/x86/sysdep.h
> > > +++ b/sysdeps/x86/sysdep.h
> > > @@ -46,6 +46,13 @@
> > > red-zone into account. */
> > > # define STATE_SAVE_OFFSET (8 * 7 + 8)
> > >
> > > +/* _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning
> > > + stack. After realigning stack, it saves RCX, RDX, R8, R9, R10 and
> > > + R11. Allocate space for all integer registers and round up the state
> > > + size to 64 bytes to avoid clobbering saved RDI, RSI and RBX values on
> > > + stack by xsave on STATE_SAVE_OFFSET(%rsp). */
> > > +# define TLSDESC_CALL_STATE_SAVE_OFFSET (STATE_SAVE_OFFSET + 64)
> >
> > Why 64? The red zone is 128 bytes, and the three registers only need 24
> > bytes. I think 24 has to be rounded up to 64 to preserve the XSAVE area
> > alignment.
>
> I changed it to 24.
>
> > The macro is also misnamed because it is not an offset. The real offset
> > depends on what the stack realignment did.
> >
>
> I renamed it to TLSDESC_CALL_REGISTER_SAVE_AREA in the v3 patch:
>
> https://patchwork.sourceware.org/project/glibc/list/?series=31971
>
No need to add a new test. Only sysdeps/x86_64/tst-gnu2-tls2mod1.S
is need:
https://patchwork.sourceware.org/project/glibc/list/?series=31975
--
H.J.
More information about the Libc-alpha
mailing list