From: Florian Weimer <fweimer@redhat.com>
To: "H.J. Lu" <hjl.tools@gmail.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v2] x86-64: Update _dl_tlsdesc_dynamic to preserve vector registers
Date: Mon, 12 Feb 2024 11:44:15 +0100 [thread overview]
Message-ID: <87eddic680.fsf@oldenburg3.str.redhat.com> (raw)
In-Reply-To: <20240212031949.3041730-1-hjl.tools@gmail.com> (H. J. Lu's message of "Sun, 11 Feb 2024 19:19:49 -0800")
* H. J. Lu:
> Compiler generates the following instruction sequence for GNU2 dynamic
> TLS access:
>
> leaq tls_var@TLSDESC(%rip), %rax
> call *tls_var@TLSCALL(%rax)
>
> CALL instruction may be transparent to compiler which assumes all
> registers, except for RAX, are unchanged after CALL. At run-time,
> _dl_tlsdesc_dynamic is called, which calls __tls_get_addr on the
> slow path. __tls_get_addr is a normal function which doesn't
> preserve any caller-saved registers. _dl_tlsdesc_dynamic saves and
> restores integer caller-saved registers, but doesn't preserve any
> vector registers which are caller-saved. Add _dl_tlsdesc_dynamic
> IFUNC functions for FXSAVE, XSAVE and XSAVEC to save and restore
> all vector registers. This fixes BZ #31372.
What about the flags register? It's still clobbered.
What about stack pointer alignment?
> + /* Besides rdi and rsi, saved above, save rcx, rdx, r8, r9,
> + r10 and r11. */
I would prefer to see some explicit ABI action first before making such
decisions. Maybe %r11 could be a scratch register available for use by
the TLSDESC call? Or does current GCC already assume that all scalar
registers are preserved?
The other way to fix this is to preallocate everything, so that the need
for the slow path goes away.
Thanks,
Florian
next prev parent reply other threads:[~2024-02-12 10:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-12 3:19 H.J. Lu
2024-02-12 10:44 ` Florian Weimer [this message]
2024-02-12 12:34 ` H.J. Lu
2024-02-12 13:29 ` Florian Weimer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87eddic680.fsf@oldenburg3.str.redhat.com \
--to=fweimer@redhat.com \
--cc=hjl.tools@gmail.com \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).