[U-Boot] [PATCH] arm: fix bug on relocation address

Heiko Schocher hs at denx.de
Fri Feb 1 09:17:14 CET 2013


Hello Luca,

on 31.01.2013 15:29, Luca Ellero wrote:
> If (N. SDRAM banks > 1) and they are not contiguous, don't relocate
> u-boot at (CONFIG_SYS_SDRAM_BASE + gd->ram_size), which is a bug.
> Instead use the end of 2nd bank (even if there are more than 2 banks)
> 
> Signed-off-by: Luca Ellero <lroluk at gmail.com>
> Cc: Albert Aribaud <albert.u.boot at aribaud.net>
> Cc: Heiko Schocher <hs at denx.de>
> ---
> 
> On ARM architectures there is a bug getting top of SDRAM (where u-boot 
> will be relocated). Top of SDRAM will always be:
> 
> CONFIG_SYS_SDRAM_BASE + gd->ram_size
> 
> anyway this can be wrong since SDRAM can be composed by more that one 
> bank in not-contiguous address space.
> (CONFIG_SYS_SDRAM_BASE + gd->ram_size) can land to not existent SDRAM 
> addresses and can be very dangerous since it can potentially corrupt 
> real SDRAM (in most cases SDRAM is aliased so writing to some 
> not-existent address can write to real address).
> Some arch use more than 2 banks but implementing all macros checks to 
> PHYS_SDRAM_* leads to very ugly code, so I think using 2nd bank is good 
> and does not generates bloated code

This is not a valid use case for U-Boot! Look in the README
section "Memory Management". This is not so trivial as it looks,
as for example the stack pointer starts somewhere near the end
of RAM and grows downwards. If you now have RAM with gaps, it maybe
reaches an address, which is not valid ...

bye,
Heiko
-- 
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany


More information about the U-Boot mailing list