[U-Boot] [PATCH v2 08/10] bootstage: Correct relocation algorithm
Simon Glass
sjg at chromium.org
Wed Feb 26 16:33:11 CET 2020
Hi Heinrich,
On Sat, 25 Jan 2020 at 01:59, Heinrich Schuchardt <xypron.debian at gmx.de> wrote:
>
> On 10/22/19 1:26 AM, Simon Glass wrote:
> > At present bootstage relocation assumes that it is possible to point back
> > to memory available before relocation, so it does not relocate the
> > strings. However this is not the case on some platforms, such as x86 which
> > uses the cache as RAM and loses access to this when the cache is enabled.
> >
> > Move the relocation step to before U-Boot relocates, expand the allocated
> > region to include space for the strings and relocate the strings at the
> > same time as the bootstage records.
> >
> > This ensures that bootstage data can remain accessible from TPL through
> > SPL to U-Boot before/after relocation.
> >
> > Signed-off-by: Simon Glass <sjg at chromium.org>
>
> Hello Simon,
>
> this merged patch seems to be incorrect. I compiled sandbox_defconfig
> with clang and ran it with valgrind.
>
> We allocate memory in bootstage_init() for gd->bootstage. But from
> bootstage_get_size() we return a size that is larger than what we have
> allocated and use that larger memory area in reloc_bootstage(). See
> output below.
Yes that's right. This is a bit tricky.
The original malloc() does not include space for strings, since the
caller passes them in and we just use pointers.
When we relocate we copy the structure but then also write out the
strings after it.
The only obvious solution is to store the total size of the bootstage
record in the bootstage_data record, probably adding a version number
as well.
Regards,
Simon
More information about the U-Boot
mailing list