armv8: fix gd after relocation
authorYork Sun <[email protected]>
Thu, 7 Dec 2017 21:16:07 +0000 (13:16 -0800)
committerTom Rini <[email protected]>
Thu, 7 Dec 2017 22:00:06 +0000 (17:00 -0500)
Commit 21f4486faa5d ("armv8: update gd after relocate") sets x18
without checking the return value of spl_relocate_stack_gd().

Reviewed-by: Stephen Warren <[email protected]>
Signed-off-by: York Sun <[email protected]>
CC: Kever Yang <[email protected]>
CC: Philipp Tomsich <[email protected]>
arch/arm/lib/crt0_64.S

index ccefce0b20a4658d383c61f7981009ca6855cd0f..9cb70552fedad205d0dba215134dbb12324b9906 100644 (file)
@@ -120,8 +120,9 @@ relocation_return:
 #endif /* !CONFIG_SPL_BUILD */
 #if defined(CONFIG_SPL_BUILD)
        bl      spl_relocate_stack_gd           /* may return NULL */
-       /* set up gd here, outside any C code */
-       mov     x18, x0
+       /* set up gd here, outside any C code, if new stack is returned */
+       cmp     x0, #0
+       csel    x18, x0, x18, ne
        /*
         * Perform 'sp = (x0 != NULL) ? x0 : sp' while working
         * around the constraint that conditional moves can not