From 30f310052672d2500479989846380d050033cd44 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Tue, 28 Jan 2020 11:45:38 +0100 Subject: el3_entrypoint_common: avoid overwriting arg3 At each BL entry point, the registers r9 to r12 are used to save info from the previous BL parameters put in r0 to r3. But zeromem uses r12, leading to a corruption of arg3. Therefore this change copies r12 to r7 before zeromem() call and restores r12 afterwards. It may be better to save it in r7 in el3_arch_init_common and not at the entrypoint as r7 could be used in other functions, especially platform ones. This is a fix for Task T661. Change-Id: Icc11990c69b5d4c542d08aca1a77b1f754b61a53 Signed-off-by: Yann Gautier --- include/arch/aarch32/el3_common_macros.S | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'include') diff --git a/include/arch/aarch32/el3_common_macros.S b/include/arch/aarch32/el3_common_macros.S index 7559de446..4fd746d5a 100644 --- a/include/arch/aarch32/el3_common_macros.S +++ b/include/arch/aarch32/el3_common_macros.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -329,6 +329,11 @@ bl inv_dcache_range #endif + /* + * zeromem uses r12 whereas it is used to save previous BL arg3, + * save it in r7 + */ + mov r7, r12 ldr r0, =__BSS_START__ ldr r1, =__BSS_SIZE__ bl zeromem @@ -339,6 +344,9 @@ bl zeromem #endif + /* Restore r12 */ + mov r12, r7 + #if defined(IMAGE_BL1) || (defined(IMAGE_BL2) && BL2_AT_EL3 && BL2_IN_XIP_MEM) /* ----------------------------------------------------- * Copy data from ROM to RAM. -- cgit v1.2.3