On Tue, Oct 20, 2020 at 7:59 AM H.J. Lu wrote: > > On Tue, Oct 20, 2020 at 2:19 AM Dave Martin wrote: > > > > On Mon, Oct 19, 2020 at 02:32:35PM -0700, H.J. Lu via Libc-alpha wrote: > > > On Mon, Oct 19, 2020 at 8:08 AM Dave Martin wrote: > > > > > > > > On Thu, Oct 15, 2020 at 04:57:28AM -0700, H.J. Lu via Libc-alpha wrote: > > > > [...] > > > > > > > > > diff --git a/sysdeps/unix/sysv/linux/x86/dl-minsigstacksize.h b/sysdeps/unix/sysv/linux/x86/dl-minsigstacksize.h > > > > [...] > > > > > > > > > +/* Emulate AT_MINSIGSTKSZ with XSAVE. */ > > > > > > > + > > > > > > > +static inline void > > > > > > > +dl_check_minsigstacksize (void) > > > > > > > +{ > > > > > > > + /* NB: Default to a constant MINSIGSTKSZ. */ > > > > > > > + _Static_assert (__builtin_constant_p (MINSIGSTKSZ), > > > > > > > + "MINSIGSTKSZ is constant"); > > > > > > > + /* Return if AT_MINSIGSTKSZ is provide by kernel. */ > > > > > > > + if (GLRO(dl_minsigstacksize) != MINSIGSTKSZ) > > > > > > > + return; > > > > > > > > > > > > Couldn't the kernel actually yield MINSIGSTKSZ or a smaller value, say, > > > > > > if running on hardware that doesn't have AVX-512? > > > > > > > > > > > It is OK for MINSIGSTKSZ > AT_MINSIGSTKSZ. For _SC_SIGSTKSZ_SOURCE, > > > > > dynamic MINSIGSTKSZ is defined as sysconf (_SC_SIGSTKSZ) which is > > > > > > > > > > MAX (SIGSTKSZ, MAX (MINSIGSTKSZ, sysconf (_SC_MINSIGSTKSZ)) * 4) > > > > > > > > > > and dynamic MINSIGSTKSZ is always > MINSIGSTKSZ. > > > > > > > > > > > We might want a separate flag to indicate whether we obtained a value > > > > > > from the auxv, rather relying on MINSIGSTKSZ having this magic meaning. > > > > > > > > > > AT_MINSIGSTKSZ is the only way for GLRO(dl_minsigstacksize) != MINSIGSTKSZ. > > > > > > > > Yes, but reading AT_MINSIGSTKSZ doesn't guarantee that > > > > GLRO(dl_minsigstkszsize) != MINSIGSTKSZ, no? > > > > > > > > What if the value reported for AT_MINSIGSTKSZ is actually the same as > > > > MINSIGSTKSZ? This could be the case on some arches in future even if > > > > it's never true today. But the code here assumes that AT_MINSIGSTKSZ > > > > wasn't available in this case, and reverts to a fallback guess. > > > > > > Since the fallback tracks what the kernel does, if AT_MINSIGSTKSZ > > > is 2KB, the fallback will be 2KB or slightly larger. > > > > Well, I guess that should be safe. It still feels a bit like it works > > by accident, but I may be being too paranoid. > > Let me work on that. > Here is the updated patch to initialize GLRO(dl_minsigstacksize) to 0 on x86. -- H.J.