From: David Laight <David.Laight@ACULAB.COM>
To: 'Willy Tarreau' <w@1wt.eu>
Cc: "Paul E . McKenney" <paulmck@kernel.org>,
Bedirhan KURT <windowz414@gnuweeb.org>,
Louvian Lyndal <louvianlyndal@gmail.com>,
"Ammar Faizi" <ammar.faizi@students.amikom.ac.id>,
Peter Cordes <peter@cordes.ca>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH 2/3] tools/nolibc: i386: fix initial stack alignment
Date: Mon, 25 Oct 2021 12:48:19 +0000 [thread overview]
Message-ID: <e1090244c6324f6fbaaf04ecb7a7cac5@AcuMS.aculab.com> (raw)
In-Reply-To: <20211025080620.GA23398@1wt.eu>
From: Willy Tarreau
> Sent: 25 October 2021 09:06
>
> On Mon, Oct 25, 2021 at 07:46:11AM +0000, David Laight wrote:
> > From: Willy Tarreau
> > > Sent: 24 October 2021 18:28
> > >
> > > After re-checking in the spec and comparing stack offsets with glibc,
> > > The last pushed argument must be 16-byte aligned (i.e. aligned before the
> > > call) so that in the callee esp+4 is multiple of 16, so the principle is
> > > the 32-bit equivalent to what Ammar fixed for x86_64. It's possible that
> > > 32-bit code using SSE2 or MMX could have been affected. In addition the
> > > frame pointer ought to be zero at the deepest level.
> > >
> > ...
> > > /* startup code */
> > > +/*
> > > + * i386 System V ABI mandates:
> > > + * 1) last pushed argument must be 16-byte aligned.
> > > + * 2) The deepest stack frame should be set to zero
> >
> > I'm pretty sure that the historic SYSV i386 ABI only every required
> > 4-byte alignment for the stack.
> >
> > At some point it got 'randomly' changed to 16-byte.
> > I don't think this happened until after compiler support for SSE2
> > intrinsics was added.
>
> It's very possible because I've done a number of tests and noticed
> that in some cases the called functions' stack doesn't seem to be
> more than 4-aligned. However the deepest function in the stack starts
> with an aligned stack so I prefer to follow this same rule.
Any call through asm is unlikely to maintain the 16 byte alignment.
But yes, starting off on the required (by gcc) alignment does no harm.
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
next prev parent reply other threads:[~2021-10-25 12:48 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-24 17:28 [PATCH 0/3] nolibc fixes marked for -stable Willy Tarreau
2021-10-24 17:28 ` [PATCH 1/3] tools/nolibc: x86-64: Fix startup code bug Willy Tarreau
2021-10-24 17:28 ` [PATCH 2/3] tools/nolibc: i386: fix initial stack alignment Willy Tarreau
2021-10-25 7:46 ` David Laight
2021-10-25 8:06 ` Willy Tarreau
2021-10-25 12:48 ` David Laight [this message]
2021-10-24 17:28 ` [PATCH 3/3] tools/nolibc: fix incorrect truncation of exit code Willy Tarreau
2021-10-24 22:52 ` [PATCH 0/3] nolibc fixes marked for -stable Paul E. McKenney
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=e1090244c6324f6fbaaf04ecb7a7cac5@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=ammar.faizi@students.amikom.ac.id \
--cc=linux-kernel@vger.kernel.org \
--cc=louvianlyndal@gmail.com \
--cc=paulmck@kernel.org \
--cc=peter@cordes.ca \
--cc=stable@vger.kernel.org \
--cc=w@1wt.eu \
--cc=windowz414@gnuweeb.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
all inboxes | Powered by JetHome®