public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Florian Weimer <fweimer@redhat.com>
To: Manjunath Matti via Libc-alpha <libc-alpha@sourceware.org>
Cc: Manjunath Matti <mmatti@linux.ibm.com>,  rajis@linux.ibm.com
Subject: Re: [PATCH] powerpc: Use sysconf (_SC_SIGSTKSZ) to set SIGSTKSZ and MINSIGSTKSZ.
Date: Wed, 24 May 2023 21:08:05 +0200	[thread overview]
Message-ID: <877csxtune.fsf@oldenburg.str.redhat.com> (raw)
In-Reply-To: <20230516111140.2585699-1-mmatti@linux.ibm.com> (Manjunath Matti via Libc-alpha's message of "Tue, 16 May 2023 07:11:40 -0400")

* Manjunath Matti via Libc-alpha:

> diff --git a/sysdeps/unix/sysv/linux/powerpc/bits/sigstksz.h b/sysdeps/unix/sysv/linux/powerpc/bits/sigstksz.h
> new file mode 100644
> index 0000000000..399a49c1b0
> --- /dev/null
> +++ b/sysdeps/unix/sysv/linux/powerpc/bits/sigstksz.h
> @@ -0,0 +1,33 @@

> +#ifndef _SIGNAL_H
> +# error "Never include <bits/sigstksz.h> directly; use <signal.h> instead."
> +#endif
> +
> +#if defined __USE_DYNAMIC_STACK_SIZE && __USE_DYNAMIC_STACK_SIZE
> +# include <unistd.h>
> +
> +/* Default stack size for a signal handler: sysconf (SC_SIGSTKSZ).  */
> +# undef SIGSTKSZ
> +# define SIGSTKSZ sysconf (_SC_SIGSTKSZ)
> +
> +/* Minimum stack size for a signal handler: SIGSTKSZ/4.  */
> +# undef MINSIGSTKSZ
> +# define MINSIGSTKSZ (SIGSTKSZ >> 2)
> +#endif

I'm not sure if it is a good idea to hard-code that constant 4 here.
Similarly, it's not great to encode the constant 1 in the default case.

This is a subtle portability hazard because with these changes,
MINSIGSTKSZ is not enough on POWER to do anything on the signal stack
(because it's exactly the kernel supplied value).  On other
architectures, it's at least possible to do some minor stuff and call
e.g. siglongjmp (at least if lazy binding is not required).

The factor 4 in the implementation is somewhat x86-64-specific because
it accounts for the fact that we do a signal-like context switch
(pushing XSAVE data on the stack) in the lazy binding trampoline.

Thanks,
Florian


  reply	other threads:[~2023-05-24 19:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-16 11:11 Manjunath Matti
2023-05-24 19:08 ` Florian Weimer [this message]
2023-06-23 12:01   ` Manjunath S Matti
  -- strict thread matches above, loose matches on Subject: below --
2023-04-24 10:52 Manjunath Matti
2023-04-28 18:05 ` Tulio Magno Quites Machado Filho
2023-05-03 16:12   ` Manjunath S Matti
2023-05-03 17:48     ` Tulio Magno Quites Machado Filho
2023-05-05 10:15       ` Manjunath S Matti
2023-05-05 14:14         ` Tulio Magno Quites Machado Filho
2023-05-09 12:24           ` Manjunath S Matti
2023-05-09 17:33             ` Tulio Magno Quites Machado Filho
2023-05-11 16:50               ` Manjunath S Matti
2023-05-17 22:18                 ` Rajalakshmi Srinivasaraghavan
2023-05-17 23:09                   ` 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=877csxtune.fsf@oldenburg.str.redhat.com \
    --to=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=mmatti@linux.ibm.com \
    --cc=rajis@linux.ibm.com \
    /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).