mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Johannes Weiner <jw@emlix.com>
To: Mike Frysinger <vapier.adi@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	David Howells <dhowells@redhat.com>,
	Russell King <rmk@arm.linux.org.uk>,
	Bryan Wu <cooloney@kernel.org>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Paul Mundt <lethal@linux-sh.org>, Greg Ungerer <gerg@uclinux.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [patch -v2] flat: fix data sections alignment
Date: Wed, 4 Mar 2009 21:13:54 +0100	[thread overview]
Message-ID: <E1LexT4-00063F-Vp@mailer.emlix.com> (raw)
In-Reply-To: <8bd0f97a0903041200y4dfa9556r8709c4331a12002b@mail.gmail.com>

On Wed, Mar 04, 2009 at 03:00:25PM -0500, Mike Frysinger wrote:
> On Wed, Mar 4, 2009 at 14:33, Johannes Weiner wrote:
> > On Wed, Mar 04, 2009 at 01:04:00PM -0500, Mike Frysinger wrote:
> >> On Wed, Mar 4, 2009 at 08:51, Johannes Weiner wrote:
> >> > The flat loader uses an architecture's flat_stack_align() to align the
> >> > stack but assumes word-alignment is enough for the data sections.
> >> >
> >> > However, on the Xtensa S6000 we have registers up to 128bit width
> >> > which can be used from userspace and therefor need userspace stack and
> >> > data-section alignment of at least this size.
> >>
> >> could this perhaps be a gcc problem ?  x86 has a similar problem with
> >> sse and they addressed it with a function attribute.  after all, just
> >> because your stack started out 128bit aligned doesnt mean gcc will
> >> keep it that way when calling other functions.  so having the stack
> >> start out aligned would only "fix" the stack for the application's
> >> entry point right (which would in practice bubble up to main()) ?  so
> >> you'd be right back where you started ...
> >
> > gcc generates sp changes only ever in multiples of 16 deltas, I just
> > checked it again with various amounts of stack variables.
> >
> > The stack frames allocate themselves with an ENTRY instruction and the
> > generated code I read here allocates stack frames of n * 16 bytes.
> >
> > So we are good to go as long as the initial stack frame is properly
> > aligned.
> 
> throwing a few random cases at gcc isnt really a good way to validate.
>  this would have worked for x86 too with older versions.  only when
> common code in later gcc versions got more aggressive with stack
> packing did people notice the issue.
> 
> so, lets look at the authoritative place: the gcc source code for xtensa
> 
> $ grep define.*STACK_BOUNDARY -B 2 gcc/config/xtensa/*.h
> xtensa.h-/* Align stack frames on 128 bits for Xtensa.  This is necessary for
> xtensa.h-   128-bit datatypes defined in TIE (e.g., for Vectra).  */
> xtensa.h:#define STACK_BOUNDARY 128
> 
> ok, now i believe that forcing a stack alignment of 128bits in the
> kernel is correct ;)

Now I do too.  Heh.

Seriously, thanks for fishing this out.  Is this an Ack? ;)

> -mike

	Hannes

  reply	other threads:[~2009-03-04 20:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-04 13:51 Johannes Weiner
2009-03-04 18:04 ` Mike Frysinger
2009-03-04 19:33   ` Johannes Weiner
2009-03-04 20:00     ` Mike Frysinger
2009-03-04 20:13       ` Johannes Weiner [this message]
2009-03-04 21:48 ` Mike Frysinger
2009-03-05 10:53   ` Johannes Weiner
2009-03-05 16:40   ` Oskar Schirmer
2009-03-05  8:43 ` Paul Mundt
2009-05-29  0:01 ` John Williams
2009-05-29  3:58   ` Paul Mundt
2009-05-29  5:11     ` John Williams

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=E1LexT4-00063F-Vp@mailer.emlix.com \
    --to=jw@emlix.com \
    --cc=akpm@linux-foundation.org \
    --cc=cooloney@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=geert@linux-m68k.org \
    --cc=gerg@uclinux.org \
    --cc=lethal@linux-sh.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rmk@arm.linux.org.uk \
    --cc=vapier.adi@gmail.com \
    /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®