Skip to content

Commit

Permalink
powerpc/boot: Change the load address for the wrapper to fit the kernel
Browse files Browse the repository at this point in the history
The wrapper code which uncompresses the kernel in case of a 'ppc' boot
is by default loaded at 0x00400000 and the kernel will be uncompressed
to fit the location 0-0x00400000. But with dynamic relocations, the size
of the kernel may exceed 0x00400000(4M). This would cause an overlap
of the uncompressed kernel and the boot wrapper, causing a failure in
boot.

The message looks like :

   zImage starting: loaded at 0x00400000 (sp: 0x0065ffb0)
   Allocating 0x5ce650 bytes for kernel ...
   Insufficient memory for kernel at address 0! (_start=00400000, uncompressed size=00591a20)

This patch shifts the load address of the boot wrapper code to the next
higher MB, according to the size of  the uncompressed vmlinux.

With the patch, we get the following message while building the image :

 WARN: Uncompressed kernel (size 0x5b0344) overlaps the address of the wrapper(0x400000)
 WARN: Fixing the link_address of wrapper to (0x600000)

Signed-off-by: Suzuki K. Poulose <suzuki@in.ibm.com>
Signed-off-by: Josh Boyer <jwboyer@gmail.com>
  • Loading branch information
Suzuki Poulose authored and Josh Boyer committed Dec 20, 2011
1 parent 5b2e478 commit c55aef0
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions arch/powerpc/boot/wrapper
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,8 @@ vmz="$tmpdir/`basename \"$kernel\"`.$ext"
if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then
${CROSS}objcopy $objflags "$kernel" "$vmz.$$"

strip_size=$(stat -c %s $vmz.$$)

if [ -n "$gzip" ]; then
gzip -n -f -9 "$vmz.$$"
fi
Expand All @@ -269,6 +271,24 @@ if [ -z "$cacheit" -o ! -f "$vmz$gzip" -o "$vmz$gzip" -ot "$kernel" ]; then
else
vmz="$vmz.$$"
fi
else
# Calculate the vmlinux.strip size
${CROSS}objcopy $objflags "$kernel" "$vmz.$$"
strip_size=$(stat -c %s $vmz.$$)
rm -f $vmz.$$
fi

# Round the size to next higher MB limit
round_size=$(((strip_size + 0xfffff) & 0xfff00000))

round_size=0x$(printf "%x" $round_size)
link_addr=$(printf "%d" $link_address)

if [ $link_addr -lt $strip_size ]; then
echo "WARN: Uncompressed kernel (size 0x$(printf "%x\n" $strip_size))" \
"overlaps the address of the wrapper($link_address)"
echo "WARN: Fixing the link_address of wrapper to ($round_size)"
link_address=$round_size
fi

vmz="$vmz$gzip"
Expand Down

0 comments on commit c55aef0

Please sign in to comment.