From: York Sun Date: Thu, 7 Dec 2017 21:16:07 +0000 (-0800) Subject: armv8: fix gd after relocation X-Git-Tag: v2018.01-rc2~40 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=e421b646fce125ed92936628dc4b287de5f038a5;p=u-boot armv8: fix gd after relocation Commit 21f4486faa5d ("armv8: update gd after relocate") sets x18 without checking the return value of spl_relocate_stack_gd(). Reviewed-by: Stephen Warren Signed-off-by: York Sun CC: Kever Yang CC: Philipp Tomsich --- diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index ccefce0b20..9cb70552fe 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -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