[PATCH] ARM: boot: Fix ATAGs with appended DTB

Geert Uytterhoeven
2020-02-25T14:48:01Z

At early boot, register r8 may contain an ATAGs or DTB pointer.
When an appended DTB is found, its address is stored in r8, for
extraction of the RAM base address later.

However, if r8 contained an ATAGs pointer before, that pointer will be
lost, and the provided ATAGs is no longer folded into the provided DTB.

Fix this by leaving r8 untouched.

Fixes: 137e522593918be2 ("ARM: 8960/1: boot: Obtain start of physical memory from DTB")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
---
Not tested with ATAGs, only with [uz]Image + DTB, and zImage with
appended DTB.
---
arch/arm/boot/compressed/head.S | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/head.S b/arch/arm/boot/compressed/head.S
index 339d4b4cfbbeed15..a351ed2bc195ed8d 100644
--- a/arch/arm/boot/compressed/head.S
+++ b/arch/arm/boot/compressed/head.S
@@ -267,16 +267,18 @@ not_angel:
cmp r0, r1 @ do we have a DTB there?
bne 1f

- mov r8, r6 @ use it if so
/* preserve 64-bit alignment */
add r5, r5, #7
bic r5, r5, #7
- add sp, sp, r5 @ and move stack above it
+ add sp, sp, r5 @ if so, move stack above DTB
+ mov r0, r6 @ and extract memory start from DTB
+ b 2f

1:
#endif /* CONFIG_ARM_APPENDED_DTB */

mov r0, r8
+2:
bl fdt_get_mem_start
mov r4, r0
cmp r0, #-1
--
2.17.1