* [PATCH v2] Fix data abort caused by mis-aligning FIT data
@ 2020-09-01 21:32 Reuben Dowle
2020-09-14 19:41 ` Tom Rini
0 siblings, 1 reply; 2+ messages in thread
From: Reuben Dowle @ 2020-09-01 21:32 UTC (permalink / raw)
To: u-boot
Attempting to place device tree immediately after an image in memory can lead
to mis-aligned data accesses if that image size is not divisible by the
alignment requirements of the architecture.
Data aborts caused by this were observed on a custom Marvel A388 based system,
where the image was a uboot FIT file. The total size varies depending on the
uboot device tree size, which does not always lead to correct alignment.
The minimum alignment specified for ARM [1] and ARM64 [2] linux booting has been
used
[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm/booting.rst#n126
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst#n45
Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
---
common/spl/spl_fit.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 365104f..a8bfd38 100644
--- a/common/spl/spl_fit.c
+++ b/common/spl/spl_fit.c
@@ -349,9 +349,12 @@ static int spl_fit_append_fdt(struct spl_image_info *spl_image,
/*
* Use the address following the image as target address for the
- * device tree.
+ * device tree. Load address is aligned to 8 bytes to match the required
+ * alignment specified for linux arm [1] and arm 64 [2] booting
+ * [1]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm/booting.rst#n126
+ * [2]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst#n45
*/
- image_info.load_addr = spl_image->load_addr + spl_image->size;
+ image_info.load_addr = ALIGN(spl_image->load_addr + spl_image->size, 8);
/* Figure out which device tree the board wants to use */
node = spl_fit_get_image_node(fit, images, FIT_FDT_PROP, index++);
--
2.7.4
^ permalink raw reply related [flat|nested] 2+ messages in thread
* [PATCH v2] Fix data abort caused by mis-aligning FIT data
2020-09-01 21:32 [PATCH v2] Fix data abort caused by mis-aligning FIT data Reuben Dowle
@ 2020-09-14 19:41 ` Tom Rini
0 siblings, 0 replies; 2+ messages in thread
From: Tom Rini @ 2020-09-14 19:41 UTC (permalink / raw)
To: u-boot
On Tue, Sep 01, 2020 at 09:32:01PM +0000, Reuben Dowle wrote:
> Attempting to place device tree immediately after an image in memory can lead
> to mis-aligned data accesses if that image size is not divisible by the
> alignment requirements of the architecture.
>
> Data aborts caused by this were observed on a custom Marvel A388 based system,
> where the image was a uboot FIT file. The total size varies depending on the
> uboot device tree size, which does not always lead to correct alignment.
>
> The minimum alignment specified for ARM [1] and ARM64 [2] linux booting has been
> used
>
> [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm/booting.rst#n126
> [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/arm64/booting.rst#n45
>
> Signed-off-by: Reuben Dowle <reuben.dowle@4rf.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20200914/38f77d95/attachment.sig>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-09-14 19:41 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-09-01 21:32 [PATCH v2] Fix data abort caused by mis-aligning FIT data Reuben Dowle
2020-09-14 19:41 ` Tom Rini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox