From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0104FC433F5 for ; Mon, 25 Oct 2021 08:07:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D772F60E8C for ; Mon, 25 Oct 2021 08:07:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231245AbhJYIJc (ORCPT ); Mon, 25 Oct 2021 04:09:32 -0400 Received: from wtarreau.pck.nerim.net ([62.212.114.60]:44706 "EHLO 1wt.eu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbhJYIJ0 (ORCPT ); Mon, 25 Oct 2021 04:09:26 -0400 Received: (from willy@localhost) by pcw.home.local (8.15.2/8.15.2/Submit) id 19P86KPj023417; Mon, 25 Oct 2021 10:06:20 +0200 Date: Mon, 25 Oct 2021 10:06:20 +0200 From: Willy Tarreau To: David Laight Cc: "Paul E . McKenney" , Bedirhan KURT , Louvian Lyndal , Ammar Faizi , Peter Cordes , "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" Subject: Re: [PATCH 2/3] tools/nolibc: i386: fix initial stack alignment Message-ID: <20211025080620.GA23398@1wt.eu> References: <20211024172816.17993-1-w@1wt.eu> <20211024172816.17993-3-w@1wt.eu> <7e5ed287476042388779ca3c84483a92@AcuMS.aculab.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7e5ed287476042388779ca3c84483a92@AcuMS.aculab.com> User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Willy