public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
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: Allocate state buffer space for RDI, RSI and RBX
Date: Sun, 17 Mar 2024 09:26:20 +0100	[thread overview]
Message-ID: <878r2he02b.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20240317031315.565195-1-hjl.tools@gmail.com> (H. J. Lu's message of "Sat, 16 Mar 2024 20:13:15 -0700")

* 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.

The macro is also misnamed because it is not an offset.  The real offset
depends on what the stack realignment did.

Thanks,
Florian


  reply	other threads:[~2024-03-17  8:26 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17  3:13 H.J. Lu
2024-03-17  8:26 ` Florian Weimer [this message]
2024-03-17 11:39   ` H.J. Lu
2024-03-17 12:57     ` H.J. Lu

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=878r2he02b.fsf@oldenburg.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).