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: Andi Kleen <ak@suse.de>, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] i386: fix stack alignment for signal handlers
Date: Tue, 11 Oct 2005 02:23:37 +0200	[thread overview]
Message-ID: <434B0609.6080109@oberhumer.com> (raw)
In-Reply-To: <200510091857.11566.ak@suse.de>

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

I've just seen that Linus has merged my second patch, so here is one more 
missing piece to fix ia64 in ia32 emulation as well.

~Markus

p.s. this patch has not been tested due to lack of hardware


Andi Kleen wrote:
> On Sunday 09 October 2005 18:54, Markus F.X.J. Oberhumer wrote:
> 
> 
>>Here is a somewhat simplified version of my previous patch with
>>updated comments.
>>
>>Attached is also a new small user-space test program which does not
>>depend on any special gcc features and should trigger the problem on all
>>machines.
> 
> 
> I already have a version of the patch in my queue, but it's not a strict 
> bugfix so it's only for after 2.6.14.
> 
> -Andi
> 
> ftp://ftp.firstfloor.org/pub/ak/x86_64/quilt-current/patches/sigframe-alignment
> 
> 

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

[-- Attachment #2: i386-align_sigframe-ia64.patch --]
[-- Type: text/x-patch, Size: 1219 bytes --]

[PATCH] i386: fix stack alignment for signal handlers (ia64)

This fixes the setup of the alignment of the signal frame, so that all
signal handlers are run with a properly aligned stack frame.

The current code "over-aligns" the stack pointer so that the stack frame
is effectively always mis-aligned by 4 bytes.  But what we really want
is that on function entry ((sp + 4) & 15) == 0, which matches what would
happen if the stack were aligned before a "call" instruction.

[ This patch fixes ia64. i386 and x86_64 are already fixed by
  git commit d347f372273c2b3d86a66e2e1c94c790c208e166 ]

Signed-off-by: Markus F.X.J. Oberhumer <markus@oberhumer.com>



Index: linux-2.6.git/arch/ia64/ia32/ia32_signal.c
===================================================================
--- linux-2.6.git.orig/arch/ia64/ia32/ia32_signal.c
+++ linux-2.6.git/arch/ia64/ia32/ia32_signal.c
@@ -810,7 +810,11 @@
 	}
 	/* Legacy stack switching not supported */
 
-	return (void __user *)((esp - frame_size) & -8ul);
+	esp -= frame_size;
+	/* Align the stack pointer according to the i386 ABI,
+	 * i.e. so that on function entry ((sp + 4) & 15) == 0. */
+	esp = ((esp + 4) & -16ul) - 4;
+	return (void __user *) esp;
 }
 
 static int

  parent reply	other threads:[~2005-10-11  0:22 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
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 [this message]
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=434B0609.6080109@oberhumer.com \
    --to=markus@oberhumer.com \
    --cc=ak@suse.de \
    --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