From patchwork Tue Mar 10 09:15:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Delaunay X-Patchwork-Id: 243467 List-Id: U-Boot discussion From: patrick.delaunay at st.com (Patrick Delaunay) Date: Tue, 10 Mar 2020 10:15:02 +0100 Subject: [PATCH v4 1/4] board_f.c: Ensure gd->new_bootstage alignment In-Reply-To: <20200310091505.24862-1-patrick.delaunay@st.com> References: <20200310091505.24862-1-patrick.delaunay@st.com> Message-ID: <20200310091505.24862-2-patrick.delaunay@st.com> From: Patrice Chotard 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 Reviewed-by: Vikas MANOCHA Reviewed-by: Patrick Delaunay Tested-by: Patrick Delaunay Signed-off-by: Patrick Delaunay --- Changes in v4: - replace insure by ensure in comment Changes in v3: None Changes in v2: - import: [U-Boot,v3] board_f.c: Insure gd->new_bootstage alignment common/board_f.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/board_f.c b/common/board_f.c index 82a164752a..0427b7b096 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -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);