public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: "H.J. Lu" <hjl.tools@gmail.com>
To: Florian Weimer <fweimer@redhat.com>
Cc: libc-alpha@sourceware.org
Subject: Re: [PATCH v4] x86-64: Allocate state buffer space for RDI, RSI and RBX
Date: Mon, 18 Mar 2024 05:32:23 -0700	[thread overview]
Message-ID: <CAMe9rOqsniEGO0GVZ1XMptu-s9t+SWYK3ddXQLmdCPuFo1_ewg@mail.gmail.com> (raw)
In-Reply-To: <875xxjvnyg.fsf@oldenburg3.str.redhat.com>

On Mon, Mar 18, 2024 at 3:22 AM Florian Weimer <fweimer@redhat.com> wrote:
>
> * H. J. Lu:
>
> > _dl_tlsdesc_dynamic preserves RDI, RSI and RBX before realigning stack.
> > After realigning stack, it saves RCX, RDX, R8, R9, R10 and R11.  Define
> > TLSDESC_CALL_REGISTER_SAVE_AREA to allocate space for RDI, RSI and RBX
> > to avoid clobbering saved RDI, RSI and RBX values on stack by xsave to
> > STATE_SAVE_OFFSET(%rsp).
> >
> >    +==================+<- stack frame start aligned at 8 or 16 bytes
>
> It's 8-byte aligned only?  If the caller uses the psABI convention, we
> have %rsp ≡ 8 (mod 16).

It is due to:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=58066

Do we need to support older compilers?

>
> >    |                  |<- RDI
> >    |                  |<- RSI
> >    |                  |<- RBX
>
> I would add something like “originally in the red zone” here.

Fixed.

> >    |                  |<- paddings from stack realignment of 64 bytes
> >    |------------------|<- xsave buffer end aligned at 64 bytes
>
>
> >    |                  |<-
> >    |                  |<-
> >    |                  |<-
> >    |------------------|<- xsave buffer start at STATE_SAVE_OFFSET(%rsp)
> >    |                  |<- 8-byte padding
>
> Maybe add “to achieve 64-bit alignment”.

Fixed.

> >    |                  |<- 8-byte padding
> >    |                  |<- R11
> >    |                  |<- R10
> >    |                  |<- R9
> >    |                  |<- R8
> >    |                  |<- RDX
> >    |                  |<- RCX
> >    +==================+<- State buffer start aligned at 64 bytes
>
> Isn't this “%rsp  aligned at 64 bytes”?

Fixed.

> Likewise for the comment in the sources below.

Fixed.

> > diff --git a/sysdeps/x86/sysdep.h b/sysdeps/x86/sysdep.h
> > index db8e576e91..46fcd27345 100644
> > --- a/sysdeps/x86/sysdep.h
> > +++ b/sysdeps/x86/sysdep.h
> > @@ -46,6 +46,34 @@
> >     red-zone into account.  */
> >  # define STATE_SAVE_OFFSET (8 * 7 + 8)
>
> The comment on STATE_SAVE_OFFSET needs updating, too.

Fixed.

> I would like to see comments from Noah or Sunil.  You'll have to
> maintain this, too. 8-)

CCed Noah and Sunil.

> I find the macro consts rather confusing, but maybe that's just me.

Can you suggest a different name?

The v5 patch is at

https://patchwork.sourceware.org/project/glibc/list/?series=31992

Thanks.

-- 
H.J.

      reply	other threads:[~2024-03-18 12:33 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-03-17 12:55 H.J. Lu
2024-03-17 13:02 ` H.J. Lu
2024-03-17 13:04   ` H.J. Lu
2024-03-18 10:22 ` Florian Weimer
2024-03-18 12:32   ` H.J. Lu [this message]

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=CAMe9rOqsniEGO0GVZ1XMptu-s9t+SWYK3ddXQLmdCPuFo1_ewg@mail.gmail.com \
    --to=hjl.tools@gmail.com \
    --cc=fweimer@redhat.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).