public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ira W. Snyder <iws@ovro.caltech.edu>
To: u-boot@lists.denx.de
Subject: [U-Boot] 83xx fails to boot with moderately sized kernels
Date: Thu, 9 Sep 2010 15:52:42 -0700	[thread overview]
Message-ID: <20100909225241.GI3496@ovro.caltech.edu> (raw)

Hello all,

I am using vanilla U-Boot on an MPC8349EMDS board with 256MB of RAM. I have
been tracking down a kernel hang very early during boot, and have traced it
back to a U-Boot bug. The bug has to do with the way CONFIG_SYS_BOOTMAPSZ
is set.

Please read through this thread for more lots more information:
http://lists.ozlabs.org/pipermail/linuxppc-dev/2010-September/085524.html

On most (all?) 83xx boards, CONFIG_SYS_BOOTMAPSZ is set to 8MB. The comment
says:

/*
 * For booting Linux, the board info and command line data
 * have to be in the first 8 MB of memory, since this is
 * the maximum mapped by the Linux kernel during initialization.
 */
#define CONFIG_SYS_BOOTMAPSZ	(8 << 20)	/* Initial Memory map for Linux*/

I am booting with a FIT image containing a kernel, FDT, and ramdisk.
U-Boot's bootm command makes sure that the FDT is relocated such that it is
located at an address lower than CONFIG_SYS_BOOTMAPSZ. The ramdisk is
placed at the end of memory. The relevant U-Boot messages:

   Booting using the fdt blob at 0x226a278
   Uncompressing Kernel Image ... OK
   Loading Ramdisk to 0fe9f000, end 0ff75699 ... OK
   Loading Device Tree to 007f8000, end 007ff78f ... OK

You'll notice the ramdisk was loaded@the end of RAM (near 256MB), while
the FDT was loaded near the end of CONFIG_SYS_BOOTMAPSZ (near 8MB).

Newer Linux kernels are getting pretty large. In fact, even a fairly
minimal kernel is large enough such that the uncompressed kernel code + BSS
is >8MB. When this happens, Linux overwrites the FDT and the boot hangs
silently.

U-Boot cannot detect this, since it does not load ELF images. It does not
know the BSS size.

Below is the size of my two kernels, toggling only the CONFIG_PROVE_LOCKING
feature on or off. As stated above, the rest of the kernel is relatively
minimal.

With CONFIG_PROVE_LOCKING:
c0369000 A __bss_start
c08a0c48 A __bss_stop

0xc08a0c48 - 0xc0369000 == 5471304 bytes BSS

Kernel size (uncompressed):
3573068 vmlinux.bin

Total (code + bss): 3573068 + 5471304 == 9044372 (8.625MB)

Without CONFIG_PROVE_LOCKING:
c0363000 A __bss_start
c0786c08 A __bss_stop

0xc0786c08 - 0xc0363000 == 4340744 bytes BSS

Kernel size (uncompressed):
3548492 vmlinux.bin

Total (code + bss): 3548492 + 4340744 == 7889236 (7.523MB)

So, just adding CONFIG_PROVE_LOCKING=y made a 1MB difference, most of it in
the bss section.

Now, as the U-Boot output shows (with CONFIG_SYS_BOOTMAPSZ == 8MB):

   Booting using the fdt blob at 0x226a278
   Uncompressing Kernel Image ... OK
   Loading Ramdisk to 0fe9f000, end 0ff75699 ... OK
   Loading Device Tree to 007f8000, end 007ff78f ... OK

Now, since the Linux kernel is loaded to address 0x0, this means that after
it is running and has initialized it's BSS, the end of the kernel will be
at address: 0x786154. The working kernel is just barely squeaking by with
about 450KB of space between the kernel and FDT.

Note that on PowerPC, Linux initializes it's BSS very, very early. The BSS
is initialized before the FDT is parsed.

Nothing that Timur or I can find indicate that CONFIG_SYS_BOOTMAPSZ is
actually limited to 8MB, as the comment states. Timur and Kumar chatted,
and realized that they had seen this bug before, on 85xx. They raised the
value of CONFIG_SYS_BOOTMAPSZ to 16MB without issue.

Reading through the Linux code, I cannot find any reason why this should be
limited to 8MB, or even 16MB. Should it be limited to CONFIG_MAX_MEM_MAPPED?

I'm worried that others either have hit this bug, or will hit it soon. By
building lots of drivers into the kernel, I'm sure that even the 16MB
boundary could be overrun.

Does anyone know the true maximum value for CONFIG_SYS_BOOTMAPSZ on Linux
(if one even exists)?

Thanks,
Ira

             reply	other threads:[~2010-09-09 22:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-09-09 22:52 Ira W. Snyder [this message]
2010-09-10 11:18 ` [U-Boot] 83xx fails to boot with moderately sized kernels Wolfgang Denk
2010-09-10 11:29   ` Stefan Roese
2010-09-10 18:10     ` Ira W. Snyder
2010-09-10 18:26       ` Kim Phillips
2010-09-10 18:53         ` Wolfgang Denk
2010-09-10 19:11           ` Kim Phillips
2010-09-10 18:51       ` Wolfgang Denk
2010-09-11  7:19         ` Joakim Tjernlund
2010-09-13 19:21           ` Scott Wood
2010-09-13 21:52             ` Joakim Tjernlund
2010-09-13 22:00               ` Scott Wood

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=20100909225241.GI3496@ovro.caltech.edu \
    --to=iws@ovro.caltech.edu \
    --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