From: Wolfgang Denk Date: Mon, 18 Oct 2010 22:50:09 +0200 Subject: [U-Boot] [PATCH v3 1/7] common/image.c fix length calculation in boot_relocate_fdt In-Reply-To: <1286999857-13790-2-git-send-email-john.rigby@linaro.org> References: <1285775292-15060-1-git-send-email-john.rigby@linaro.org> <1286999857-13790-2-git-send-email-john.rigby@linaro.org> Message-ID: <20101018205009.652581359B3@gemini.denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Dear John Rigby, In message <1286999857-13790-2-git-send-email-john.rigby@linaro.org> you wrote: > boot_relocate_fdt is called on platforms with CONFIG_SYS_BOOTMAPSZ > defined to relocate the device tree blob to be inside the > boot map area between bootmap_base and bootmap_base+CONFIG_SYS_BOOTMAPSZ. > > For the case where the blob needs to be relocated, space is > allocated inside the bootmap by calling lmb_alloc_base with > size passed in plus some padding: > > of_len = *of_size + CONFIG_SYS_FDT_PAD; > > For the case where the blob is already inside the bounds of the boot map > area, lmb_reserve is called to reserve the the space where the blob is > already residing. The calculation for this case is currently: > > of_len = (CONFIG_SYS_BOOTMAPSZ + bootmap_base) - (ulong)fdt_blob; > > This is wrong because it reserves all the space in the boot map area > from the blob to the end ignoring completely the actual size. The > worst case is where the blob is at the beginning and the entire boot map > area get reserved. Fix this by changing the length calculation to this: > > of_len = *of_size + CONFIG_SYS_FDT_PAD; > > This bug has likely never manifested itself because bootm has never > been called with the fdt blob already in the bootmap area. In my > testing on an OMAP3 beagle board I initially worked around the bug > by simply moving the initial location of the fdt blob. I have tested > with the new calculation with the fdt blob both inside and outside > the boot map area. > > Signed-off-by: John Rigby > --- > common/image.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) Applied to u-boot-arm, thanks. Best regards, 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 An expert is a person who avoids the small errors while sweeping on to the grand fallacy.