From: Patrick Delaunay <patrick.delaunay@st.com>
To: u-boot@lists.denx.de
Subject: [PATCH v4 1/4] board_f.c: Ensure gd->new_bootstage alignment
Date: Tue, 10 Mar 2020 10:15:02 +0100 [thread overview]
Message-ID: <20200310091505.24862-2-patrick.delaunay@st.com> (raw)
In-Reply-To: <20200310091505.24862-1-patrick.delaunay@st.com>
From: Patrice Chotard <patrice.chotard@st.com>
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>
---
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);
--
2.17.1
next prev parent reply other threads:[~2020-03-10 9:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-10 9:15 [PATCH v4 0/4] Ensure 16 alignment of reserved memory in board_f.c Patrick Delaunay
2020-03-10 9:15 ` Patrick Delaunay [this message]
2020-04-17 21:08 ` [PATCH v4 1/4] board_f.c: Ensure gd->new_bootstage alignment Tom Rini
2020-03-10 9:15 ` [PATCH v4 2/4] Revert "stm32mp1: remove the imply BOOTSTAGE" Patrick Delaunay
2020-04-17 21:08 ` Tom Rini
2020-03-10 9:15 ` [PATCH v4 3/4] arm: set the relocated gd with gd->new_gd Patrick Delaunay
2020-04-17 21:08 ` Tom Rini
2020-03-10 9:15 ` [PATCH v4 4/4] board_f.c: Ensure 16 alignment of start_addr_sp and reserved memory Patrick Delaunay
2020-04-17 21:08 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200310091505.24862-2-patrick.delaunay@st.com \
--to=patrick.delaunay@st.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox