summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Meng <bmeng.cn@gmail.com>2021-07-10 17:28:20 +0300
committerAnup Patel <anup@brainfault.org>2021-07-17 14:43:43 +0300
commit8a1475b5a1325547af7f428d4aed063d7a4007c7 (patch)
treee5283cd4ebb7ae4ac7de8fb03e696caf2efb8271
parentf3a8f603a702b10f13f0fad7c0c815b21fb2384a (diff)
downloadopensbi-8a1475b5a1325547af7f428d4aed063d7a4007c7.tar.xz
firmware: Remove the unhelpful alignment codes before fdt relocation
If the device tree is at an address that is not __SIZEOF_POINTER__ aligned, the fdt relocation code tries to align both source and destination address to __SIZEOF_POINTER__ before the memory copy. But such alignment can lead to unexpected results if either source or destination address is not aligned. In fact libfdt requires that the device tree must be at an 8-byte aligned address. Hence remove the unhelpful alignment codes. Signed-off-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
-rw-r--r--firmware/fw_base.S5
1 files changed, 1 insertions, 4 deletions
diff --git a/firmware/fw_base.S b/firmware/fw_base.S
index 928ca91..6baf6ab 100644
--- a/firmware/fw_base.S
+++ b/firmware/fw_base.S
@@ -349,8 +349,7 @@ _scratch_init:
* previous booting stage.
*/
beqz a1, _fdt_reloc_done
- /* Mask values in a3 and a4 */
- li a3, ~(__SIZEOF_POINTER__ - 1)
+ /* Mask values in a4 */
li a4, 0xff
/* t1 = destination FDT start address */
MOV_3R s0, a0, s1, a1, s2, a2
@@ -359,10 +358,8 @@ _scratch_init:
MOV_3R a0, s0, a1, s1, a2, s2
beqz t1, _fdt_reloc_done
beq t1, a1, _fdt_reloc_done
- and t1, t1, a3
/* t0 = source FDT start address */
add t0, a1, zero
- and t0, t0, a3
/* t2 = source FDT size in big-endian */
#if __riscv_xlen == 64
lwu t2, 4(t0)