public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Stian Halseth <stian@itx.no>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
	 libc-alpha@sourceware.org
Cc: sam@gentoo.org
Subject: Re: [PATCH v2] Mark swapcontext returns_twice by default [BZ #23130]
Date: Tue, 15 Sep 2026 23:00:17 +0200	[thread overview]
Message-ID: <414810f54026c4e9493339ce36f3c5c0e243475f.camel@itx.no> (raw)
In-Reply-To: <1b34b640-18f9-4492-8833-3859a9e9f957@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 4205 bytes --]

Hi, a quick ping.

Is there something else I can to do on my end, or is this now in
progress after the Reviewed-by?

I have a couple of other patches in the works, but want to wait until
my first patch lands, so I'm familiar with the whole process.

-- 
Best regards
Stian Halseth

On Fri, 2026-09-04 at 15:32 -0300, Adhemerval Zanella Netto wrote:
> 
> 
> On 04/09/26 12:29, Stian Halseth wrote:
> > swapcontext does not restore every callee-saved register on all
> > targets.
> > On sparc the %l and %i registers are not in the saved context at
> > all:
> > they live in the register window save area of the calling frame,
> > which
> > another pass through that frame can overwrite.  stdlib/tst-
> > setcontext2
> > fails on sparc64 for this reason at -O2 with PIC, where gcc keeps
> > &global in %i5 across swapcontext and reuses %i5 as the GOT base on
> > another path through the same frame.
> > 
> > Mark swapcontext returns_twice in the generic bits/indirect-
> > return.h, so
> > every target that does not override it is covered.  x86 and aarch64
> > keep
> > their own headers and are unchanged.
> > 
> > string/tst-xbzero-opt.c calls swapcontext from an always_inline
> > function, which a returns_twice callee forbids; key its guard on
> > the
> > availability of indirect_return rather than on __CET__.  It is the
> > only
> > such site in the tree.
> > 
> > Tested on sparc64: full make check is clean, with no test that
> > passed
> > before failing after.
> > 
> > Signed-off-by: Stian Halseth <stian@itx.no>
> 
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
> 
> > ---
> > Changes in v2:
> >  - drop the sparc-specific rationale from the generic header
> >  - use returns_twice unconditionally rather than preferring
> >    indirect_return
> > 
> > I left the tst-xbzero-opt.c guard keyed on indirect_return.  The
> > attribute is x86/aarch64-only in practice -- __has_attribute
> > reports 1
> > on x86_64 and 0 on sparc64 -- and both of those targets have their
> > own
> > headers, so the guard still selects exactly the targets that end up
> > with
> > returns_twice.
> > 
> > On sparc64 the generic header resolves to returns_twice either way,
> > so
> > the make check result from v1 stands unchanged.
> > 
> >  bits/indirect-return.h  | 9 +++++++--
> >  string/tst-xbzero-opt.c | 7 +++----
> >  2 files changed, 10 insertions(+), 6 deletions(-)
> > 
> > diff --git a/bits/indirect-return.h b/bits/indirect-return.h
> > index 819bd25b..ba2efb06 100644
> > --- a/bits/indirect-return.h
> > +++ b/bits/indirect-return.h
> > @@ -21,5 +21,10 @@
> >  #endif
> >  
> >  /* __INDIRECT_RETURN is used on swapcontext to indicate if it
> > requires
> > -   special compiler treatment.  */
> > -#define __INDIRECT_RETURN
> > +   special compiler treatment.  swapcontext does not restore every
> > +   callee-saved register on all targets.  */
> > +#if __glibc_has_attribute (__returns_twice__)
> > +# define __INDIRECT_RETURN __attribute__ ((__returns_twice__))
> > +#else
> > +# define __INDIRECT_RETURN
> > +#endif
> > diff --git a/string/tst-xbzero-opt.c b/string/tst-xbzero-opt.c
> > index 3aa13d03..26e2ec1c 100644
> > --- a/string/tst-xbzero-opt.c
> > +++ b/string/tst-xbzero-opt.c
> > @@ -111,10 +111,9 @@ use_test_buffer (unsigned char *buf)
> >  /* Always check the test buffer immediately after filling it; this
> >     makes externally visible side effects depend on the buffer
> > existing
> >     and having been filled in.  */
> > -#if defined __CET__ && !__glibc_has_attribute
> > (__indirect_return__)
> > -/* Note: swapcontext returns via indirect branch when SHSTK is
> > enabled.
> > -   Without indirect_return attribute, swapcontext is marked with
> > -   returns_twice attribute, which prevents always_inline to work. 
> > */
> > +#if !__glibc_has_attribute (__indirect_return__)
> > +/* Without indirect_return, swapcontext is marked returns_twice,
> > which
> > +   prevents always_inline from working.  */
> >  # define ALWAYS_INLINE
> >  #else
> >  # define ALWAYS_INLINE __attribute__ ((always_inline))
> 

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2026-09-15 21:00 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-02 12:43 [PATCH] Mark swapcontext returns_twice without indirect_return " Stian Halseth
2026-09-04 14:20 ` Adhemerval Zanella Netto
2026-09-04 15:29   ` [PATCH v2] Mark swapcontext returns_twice by default " Stian Halseth
2026-09-04 18:32     ` Adhemerval Zanella Netto
2026-09-15 21:00       ` Stian Halseth [this message]
2026-09-16 12:02         ` Adhemerval Zanella Netto
2026-09-16 12:33           ` Stian Halseth
2026-09-21 12:33     ` Andreas Schwab
2026-09-21 13:05       ` Stian Halseth
2026-09-21 13:14         ` Andreas Schwab
2026-09-21 20:36           ` Stian Halseth
2026-09-21 20:39           ` [PATCH] string: Drop always_inline from tst-xbzero-opt " Stian Halseth
2026-09-25 10:43             ` Stian Halseth
2026-09-25 13:03               ` Adhemerval Zanella Netto
2026-09-25 11:11             ` Adhemerval Zanella Netto

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=414810f54026c4e9493339ce36f3c5c0e243475f.camel@itx.no \
    --to=stian@itx.no \
    --cc=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=sam@gentoo.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).