public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Wolfgang Denk <wd@denx.de>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V7] POST cleanup.
Date: Sat, 13 Nov 2010 23:55:11 +0100	[thread overview]
Message-ID: <20101113225511.92BACCEA55B@gemini.denx.de> (raw)
In-Reply-To: <20101026210959.518031365D8@gemini.denx.de>

Dear Michael,

Ping!

In message <20101026210959.518031365D8@gemini.denx.de> I wrote:
> Dear Michael Zaidman,
> 
> In message <d520c6ef298416a03789ebfa4e05e257b5331693.1284965175.git.michael.zaidman@gmail.com> you wrote:
> > - Revives POST for blackfin arch;
> > - Removes redundant code:
> >      arch/blackfin/lib/post.c
> >      arch/powerpc/cpu/ppc4xx/commproc.c
> >      arch/powerpc/cpu/mpc512x/common.c
> > - fixes up the post_word_{load|store} usage.
> 
> Unfortunately it turns out that the code now contains a few nasty
> bugs...
> 
> ...
> >  #define CONFIG_SYS_GBL_DATA_OFFSET   (CONFIG_SYS_INIT_RAM_END - CONFIG_SYS_GBL_DATA_SIZE)
> > -#define CONFIG_SYS_POST_WORD_ADDR    (CONFIG_SYS_GBL_DATA_OFFSET - 0x4)
> > -#define CONFIG_SYS_INIT_SP_OFFSET    CONFIG_SYS_POST_WORD_ADDR
> > +#define CONFIG_SYS_INIT_SP_OFFSET    (CONFIG_SYS_GBL_DATA_OFFSET - 0x4)
> 
> This is a seriously broken design, as it sneaks in storage for a
> variable in a storage location where it is not expected.
> 
> The "official" layout is that we have CONFIG_SYS_INIT_RAM_BYTES
> available; the top CONFIG_SYS_GBL_DATA_SIZE bytes (now
> GENERATED_GBL_DATA_SIZE) are used for global data, and the part below
> is used for the stack.  No other room is reserved there.
> 
> Shifting down the stack by 4 bytes as it's done here causes that the
> stack is not correctly aligned any more, which may cause really nasty
> subsequent errors.
> 
> But it's even worse.
> 
> > diff --git a/include/configs/mpc5121-common.h b/include/configs/mpc5121-common.h
> > index 96fab20..afae1ab 100644
> > --- a/include/configs/mpc5121-common.h
> > +++ b/include/configs/mpc5121-common.h
> ...
> > -#define CONFIG_SYS_POST_WORD_ADDR	(CONFIG_SYS_GBL_DATA_OFFSET - 0x4)
> > -#define CONFIG_SYS_INIT_SP_OFFSET	CONFIG_SYS_POST_WORD_ADDR
> > +#define CONFIG_SYS_INIT_SP_OFFSET	(CONFIG_SYS_GBL_DATA_OFFSET - 0x4)
> 
> There the same is done, but what happens actually?
> 
> Have a look how the stack setup gets implemented in
> "arch/powerpc/cpu/mpc512x/start.S":
> 
> ...
> 244 in_flash:
> 245         lis     r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@h
> 246         ori     r1, r1, (CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_GBL_DATA_OFFSET)@l
> 247
> 248         li      r0, 0           /* Make room for stack frame header and */
> 249         stwu    r0, -4(r1)      /* clear final stack frame so that      */
> 250         stwu    r0, -4(r1)      /* stack backtraces terminate cleanly   */
> ...
> 
> As you can see, the code does not use CONFIG_SYS_INIT_SP_OFFSET at
> all; instead it performs a calculation which should be redundant, but
> in the current code it means that the location of the POST_WORD is
> right in the initial stack.
> 
> I did not check if the code for other processors has similar issues.
> 
> 
> "Reserving" private storage like that is bad, as other involved
> parties probably have no knowledge of such a private reservation.
> 
> 
> Why do we not simply reserve a word in the global data structure instead?
> 
> 
> This bug needs pretty urgent fixing.
> 
> 
> Best regards,
> 
> Wolfgang Denk

Viele Gr??e,

Wolfgang Denk

-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
If a train station is a place where a train stops,
                                           then what's a workstation?

  reply	other threads:[~2010-11-13 22:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-02 10:38 [U-Boot] [PATCH v3] POST cleanup v3 (incremental) Michael Zaidman
2010-05-06 21:42 ` Wolfgang Denk
2010-05-09 15:27   ` [U-Boot] [PATCH v4] POST cleanup Michael Zaidman
2010-05-10 11:17     ` Detlev Zundel
2010-05-10 11:39       ` Michael Zaidman
2010-05-12 12:02         ` Detlev Zundel
2010-05-12 12:49           ` Michael Zaidman
2010-06-27 14:00             ` Michael Zaidman
2010-05-10 12:12       ` Michael Zaidman
2010-05-10 13:33       ` [U-Boot] [PATCH v5] " Michael Zaidman
2010-06-29 19:51         ` Wolfgang Denk
2010-06-30 16:16           ` [U-Boot] [PATCH v6] " Michael Zaidman
2010-08-08  6:53             ` Michael Zaidman
2010-08-08 20:30               ` Wolfgang Denk
2010-08-10 13:37                 ` Michael Zaidman
2010-09-20  6:51                 ` [U-Boot] [PATCH V7] " Michael Zaidman
2010-09-21 19:40                   ` Wolfgang Denk
2010-10-26 21:09                   ` Wolfgang Denk
2010-11-13 22:55                     ` Wolfgang Denk [this message]
2010-11-21 12:34                     ` Michael Zaidman
2010-12-06  8:00                       ` Michael Zaidman
2010-05-10 11:51     ` [U-Boot] [PATCH v4] " Anatolij Gustschin
2010-05-10 11:55       ` Michael Zaidman

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=20101113225511.92BACCEA55B@gemini.denx.de \
    --to=wd@denx.de \
    --cc=u-boot@lists.denx.de \
    /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