summaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorReuben Dowle <reuben.dowle@4rf.com>2020-09-01 21:32:01 +0000
committerTom Rini <trini@konsulko.com>2020-09-11 17:13:56 -0400
commiteb39d8ba5f0d1468b01b89a2a464d18612d3ea76 (patch)
tree93782078ccf62a0559a5b152171bb7ece6f5a717 /common
parent1e2c5bb9e7f9fdad05a5b1f36c44da5cc430b8a9 (diff)
Fix data abort caused by mis-aligning FIT data
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>
Diffstat (limited to 'common')
-rw-r--r--common/spl/spl_fit.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/common/spl/spl_fit.c b/common/spl/spl_fit.c
index 365104fe02..a8bfd388b1 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++);