When loading U-Boot in a low memory address, the adpr instruction to preserve saved_args[] end up within the memory space of QEMUs mapped pflashes. As a result the following store pair instructions lead to a crash since instructions that modify more than one registers can't trap into KVM.
This problem can be solved with loading U-Boot with -kernel and defining a different text base address. But when running with -bios we always start from 0x0. So let's postpone the calculation of saved_args[] post relocation, where we will have an address that doesn't collide with the QEMU flashes. Acked-by: Raymond Mao <[email protected]> Signed-off-by: Ilias Apalodimas <[email protected]> --- Changes since v1: - Move comments to the appropriate place - Add missing ifdefs when calculating the bloblist placement arch/arm/cpu/armv8/start.S | 9 ++++----- arch/arm/lib/crt0_64.S | 7 +++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/arch/arm/cpu/armv8/start.S b/arch/arm/cpu/armv8/start.S index 40c342e97e9b..c9ca93bcc904 100644 --- a/arch/arm/cpu/armv8/start.S +++ b/arch/arm/cpu/armv8/start.S @@ -386,11 +386,10 @@ ENDPROC(c_runtime_cpu_setup) WEAK(save_boot_params) #if (IS_ENABLED(CONFIG_BLOBLIST)) - /* Calculate the PC-relative address of saved_args */ - adrp x9, saved_args - add x9, x9, :lo12:saved_args - stp x0, x1, [x9] - stp x2, x3, [x9, #16] + mov x0, x19 + mov x1, x20 + mov x2, x21 + mov x3, x22 #endif b save_boot_params_ret /* back to my caller */ ENDPROC(save_boot_params) diff --git a/arch/arm/lib/crt0_64.S b/arch/arm/lib/crt0_64.S index 3e7627aa389b..588d89687206 100644 --- a/arch/arm/lib/crt0_64.S +++ b/arch/arm/lib/crt0_64.S @@ -132,6 +132,13 @@ ENTRY(_main) b relocate_code relocation_return: +#if (IS_ENABLED(CONFIG_BLOBLIST)) + /* Calculate the PC-relative address of saved_args */ + adrp x9, saved_args + add x9, x9, :lo12:saved_args + stp x19, x20, [x9] + stp x21, x22, [x9, #16] +#endif /* * Set up final (full) environment -- 2.51.0

