From: Sebastian Siewior <bigeasy@linutronix•de>
To: Milton Miller <miltonm@bga•com>
Cc: linuxppc-dev@ozlabs•org, David Gibson <david@gibson•dropbear.id.au>
Subject: Re: [RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize
Date: Thu, 25 Sep 2008 23:43:57 +0200 [thread overview]
Message-ID: <20080925214357.GA2929@www.tglx.de> (raw)
In-Reply-To: <200809240146.m8O1kIpZ077447@sullivan.realtime.net>
* Milton Miller | 2008-09-23 20:46:18 [-0500]:
>On Wed Sep 24 at about 06:38:57 EST in 2008, Sebastian Siewior wrote:
>> My mylinux binary incl. bss is ~5 MiB without bss less than 4 MiB.
>> Therefore I though that I could replace ei.memsize with ei.loadsize. It
>> didn't work. I'm not sure why it did not work but I guess that the
>> memset() of bss in the initial kernel code overwrote the cuimage code
>> which is required for some reason. Maybe some device-tree callbacks.
>
>probably because the bss extended beyond the cuboot _end to include
>where your device tree was copied (just a malloc and we start
>simple_malloc at the boot _end on most platforms).
Right, the bss section went past _dtb_start, moving the device tree
helps.
Signed-off-by: Sebastian Siewior <bigeasy@linutronix•de>
---
arch/powerpc/boot/libfdt-wrapper.c | 16 ++++++++--------
arch/powerpc/boot/main.c | 12 +++++++++++-
2 files changed, 19 insertions(+), 9 deletions(-)
diff --git a/arch/powerpc/boot/libfdt-wrapper.c b/arch/powerpc/boot/libfdt-wrapper.c
index c541fd8..1daa73f 100644
--- a/arch/powerpc/boot/libfdt-wrapper.c
+++ b/arch/powerpc/boot/libfdt-wrapper.c
@@ -165,6 +165,7 @@ static unsigned long fdt_wrapper_finalize(void)
void fdt_init(void *blob)
{
int err;
+ int bufsize;
dt_ops.finddevice = fdt_wrapper_finddevice;
dt_ops.getprop = fdt_wrapper_getprop;
@@ -178,16 +179,15 @@ void fdt_init(void *blob)
/* Make sure the dt blob is the right version and so forth */
fdt = blob;
- err = fdt_open_into(fdt, fdt, fdt_totalsize(blob));
- if (err == -FDT_ERR_NOSPACE) {
- int bufsize = fdt_totalsize(fdt) + 4;
- buf = malloc(bufsize);
- err = fdt_open_into(fdt, buf, bufsize);
- }
+ bufsize = fdt_totalsize(fdt) + 4;
+ buf = malloc(bufsize);
+ if(!buf)
+ fatal("malloc failed. can't relocate the device tree\n\r");
+
+ err = fdt_open_into(fdt, buf, bufsize);
if (err != 0)
fatal("fdt_init(): %s\n\r", fdt_strerror(err));
- if (buf)
- fdt = buf;
+ fdt = buf;
}
diff --git a/arch/powerpc/boot/main.c b/arch/powerpc/boot/main.c
index 45a81c3..f5fcd14 100644
--- a/arch/powerpc/boot/main.c
+++ b/arch/powerpc/boot/main.c
@@ -56,9 +56,19 @@ static struct addr_range prep_kernel(void *chosen)
if (platform_ops.vmlinux_alloc) {
addr = platform_ops.vmlinux_alloc(ei.memsize);
} else {
+ /*
+ * Check if the kernel image (without bss) would overwrite the
+ * bootwrapper. The device tree has been moved in fdt_init()
+ * to an area allocated with malloc() (somewhere past _end).
+ */
if ((unsigned long)_start < ei.loadsize)
fatal("Insufficient memory for kernel at address 0!"
- " (_start=%p)\n\r", _start);
+ " (_start=%p, uncomressed size=%08x)\n\r",
+ _start, ei.loadsize);
+
+ if ((unsigned long)_end < ei.memsize)
+ fatal("The final kernel image would overwrite the "
+ "device tree\n\r");
}
/* Finally, gunzip the kernel */
--
1.5.6.5
next prev parent reply other threads:[~2008-09-25 21:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-23 20:38 [RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize Sebastian Siewior
2008-09-24 1:46 ` Milton Miller
2008-09-25 10:21 ` Sebastian Siewior
2008-09-25 21:43 ` Sebastian Siewior [this message]
2008-10-10 3:58 ` Benjamin Herrenschmidt
2008-10-13 9:15 ` [PATCH] " Sebastian Andrzej Siewior
2008-10-14 1:57 ` David Gibson
2008-10-14 2:00 ` David Gibson
2008-11-01 20:00 ` [PATCH] powerpc/boot: allocate more memory for dtb Sebastian Andrzej Siewior
2008-11-06 0:16 ` David Gibson
2008-09-25 18:15 ` [RFC] powerpc/boot: compare _start against ei.loadsize instead ei.memsize Scott Wood
-- strict thread matches above, loose matches on Subject: below --
2008-09-25 19:54 Milton Miller
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=20080925214357.GA2929@www.tglx.de \
--to=bigeasy@linutronix$(echo .)de \
--cc=david@gibson$(echo .)dropbear.id.au \
--cc=linuxppc-dev@ozlabs$(echo .)org \
--cc=miltonm@bga$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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