From mboxrd@z Thu Jan 1 00:00:00 1970 From: Patrick DELAUNAY Date: Mon, 16 Dec 2019 11:53:48 +0000 Subject: [PATCH v3] board_f.c: Insure gd->new_bootstage alignment In-Reply-To: <20191127091138.29223-1-patrice.chotard@st.com> References: <20191127091138.29223-1-patrice.chotard@st.com> Message-ID: <611198b18f8e404d9c63a3ab2a1410dd@SFHDAG6NODE3.st.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hi Tom, > From: Patrice CHOTARD > Sent: mercredi 27 novembre 2019 10:12 > > 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 insure 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 > Do you plan to merge this fixe for the next rc for v2020.01 ? Or do you expect some change / review. This patch is mandatory for stm32mp1 (ARM plaform with bootstage feature activated). Without this patch, the boot failed (at least for v2020.01-rc3 : crash has struct pointer new_bootstage is not aligned). Or I will deactivate the BOOTSTAGE feature... Thanks Patrick > --- > > Changes in v3: > - Add Patrick Reviewed-by and Tested-by. > > Changes in v2: > - Update comment to explain the ALIGN_DOWN() usage. > > common/board_f.c | 5 +++++ > 1 file changed, 5 insertions(+) > > diff --git a/common/board_f.c b/common/board_f.c index e3591cbaeb..d367f6b044 > 100644 > --- a/common/board_f.c > +++ b/common/board_f.c > @@ -559,6 +559,11 @@ static int reserve_bootstage(void) > int size = bootstage_get_size(); > > gd->start_addr_sp -= size; > + /* > + * Insure 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); > -- > 2.17.1