]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
board_f.c: Ensure gd->new_bootstage alignment
authorPatrice Chotard <patrice.chotard@st.com>
Tue, 10 Mar 2020 09:15:02 +0000 (10:15 +0100)
committerTom Rini <trini@konsulko.com>
Fri, 17 Apr 2020 03:06:54 +0000 (23:06 -0400)
In reserve_bootstage(), in case size is odd, gd->new_bootstage
is not aligned. In bootstage_relocate(), the platform hangs when
getting access to data->record[i].name.
To avoid this issue, make gd->new_bootstage 16 byte aligned.

To ensure that new_bootstage is 16 byte aligned (at least needed for
x86_64 and ARMv8) and new_bootstage starts down to get enough space,
ALIGN_DOWN macro is used.

Fixes: ac9cd4805c8b ("bootstage: Correct relocation algorithm")
Signed-off-by: Patrice Chotard <patrice.chotard@st.com>
Reviewed-by: Vikas MANOCHA <vikas.manocha@st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@st.com>
Tested-by: Patrick Delaunay <patrick.delaunay@st.com>
Signed-off-by: Patrick Delaunay <patrick.delaunay@st.com>
common/board_f.c

index 82a164752aa38f1010fa94d39cd66b1f90c2d8c3..0427b7b096cc97d47f812e7a5c00e3b3871b664b 100644 (file)
@@ -564,6 +564,11 @@ static int reserve_bootstage(void)
        int size = bootstage_get_size();
 
        gd->start_addr_sp -= size;
+       /*
+        * Ensure that start_addr_sp is aligned down to reserve enough
+        * space for new_bootstage
+        */
+       gd->start_addr_sp = ALIGN_DOWN(gd->start_addr_sp, 16);
        gd->new_bootstage = map_sysmem(gd->start_addr_sp, size);
        debug("Reserving %#x Bytes for bootstage at: %08lx\n", size,
              gd->start_addr_sp);