public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Markus F.X.J. Oberhumer" <markus@oberhumer.com>
To: Linus Torvalds <torvalds@osdl.org>
Cc: linux-kernel@vger.kernel.org, Andi Kleen <ak@suse.de>,
	John Reiser <jreiser@bitwagon.com>
Subject: Re: [PATCH] i386: fix stack alignment for signal handlers
Date: Wed, 14 Sep 2005 03:39:32 +0200	[thread overview]
Message-ID: <43277F54.1060508@oberhumer.com> (raw)
In-Reply-To: <Pine.LNX.4.58.0509131649060.26803@g5.osdl.org>

Linus Torvalds wrote:
> 
> On Wed, 14 Sep 2005, Markus F.X.J. Oberhumer wrote:
> 
>>>You seem to be expecting that the address be aligned "before the return 
>>>address push", which is a totally different thing. Quite frankly, I don't 
>>>know which one gcc prefers or whether there's an ABI specifying any 
>>>preferences.
>>
>>I'm pretty sure that on both amd64 and i386 the alignment has to be 
>>_before_ the address push from the call, though I cannot find any exact ABI 
>>specs at the moment. Experts please advise.
>>
>>What do you get when running this slightly modified version of your test 
>>program? My patch would fix the alignment of Aligned16 here.
> 
> 
> Your test program does seems to imply that gcc wants the alignment before
> the return address (ie it prints out an address that is 4 bytes offset),
> but on the other hand I'm not even sure how careful gcc is about this
> alignment thing at all.
> 
> In the "main()" function, gcc will actually generate a "andl $-16,%esp" to 
> force the alignment, but ot in the handler function. Just a gcc special 
> case? Random luck?

I think that main() is a known name and therefore gets a special treatment 
- if you rename main() to foo() and then compare the disassembly you will 
see that the "andl $-16,%esp" has vanished.

OTOS the "andl" in main() exactly does show how gcc wants the stack to be 
aligned, i.e. _before_ the call-address push.

Another argument would be the 16-byte aligned stack-setup of glibc - please 
try runing this tiny program under gdb and look at "info reg":

     asm(".globl main\n main:\n int $3\n");

All of this would indicate that the kernel should get fixed.

~Markus

> 
> Andi - you know the gcc people, is there some documented rules somewhere? 
> How does gcc itself try to align the stack when it generates the calls?
> 
> 		Linus
> 

-- 
Markus Oberhumer, <markus@oberhumer.com>, http://www.oberhumer.com/

  reply	other threads:[~2005-09-14  1:32 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-09-13 20:55 [PATCH] i386: fix stack alignment for signal handlers Markus F.X.J. Oberhumer
2005-09-13 22:53 ` Linus Torvalds
2005-09-13 23:30   ` Markus F.X.J. Oberhumer
2005-09-13 23:52     ` Linus Torvalds
2005-09-14  1:39       ` Markus F.X.J. Oberhumer [this message]
2005-09-14  4:54       ` Andi Kleen
2005-09-14 14:22       ` Daniel Jacobowitz
2005-09-14 14:55         ` Linus Torvalds
2005-09-14 15:44           ` Andi Kleen
2005-10-09 16:54             ` Markus F.X.J. Oberhumer
2005-10-09 16:57               ` Andi Kleen
2005-10-09 17:06                 ` Markus F.X.J. Oberhumer
2005-10-11  0:23                 ` Markus F.X.J. Oberhumer
2005-09-14 20:11     ` J.A. Magallon

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=43277F54.1060508@oberhumer.com \
    --to=markus@oberhumer.com \
    --cc=ak@suse.de \
    --cc=jreiser@bitwagon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.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