From ab020f304efdac61d38876a95005d8478659faae Mon Sep 17 00:00:00 2001 From: Furquan Shaikh Date: Wed, 10 Sep 2014 12:19:38 -0700 Subject: arm64: Adapt stage_entry to make it usable by secmon stage_entry is the best place to enter for secmon, since it sets up all the stacks right. The only need we need to take care is losing out on the parameter passed to secmon. This patch adds an entry point for secmon rmodule and moves the argument from x0 to x25, which is restored just before the jump to c_entry BUG=chrome-os-partner:30785 BRANCH=None TEST=Compiles successfully Change-Id: I9638e9716b3bd5bff272e88fe9d965528d71e394 Signed-off-by: Patrick Georgi Original-Commit-Id: ffedb03208bafab6d5886db0259ec205dd20588f Original-Change-Id: I74a7a609fbc08692d68708abe132cd219c89b456 Original-Signed-off-by: Furquan Shaikh Original-Reviewed-on: https://chromium-review.googlesource.com/217570 Original-Reviewed-by: Aaron Durbin Original-Tested-by: Furquan Shaikh Original-Commit-Queue: Furquan Shaikh Reviewed-on: http://review.coreboot.org/9079 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer --- src/arch/arm64/stage_entry.S | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/arch/arm64/stage_entry.S b/src/arch/arm64/stage_entry.S index 301711e8f9..6b8ca7b424 100644 --- a/src/arch/arm64/stage_entry.S +++ b/src/arch/arm64/stage_entry.S @@ -17,6 +17,14 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +/* + * ======================== stage_entry.S ===================================== + * This file acts as an entry point to the different stages of arm64 as well as + * for the secure monitor. They share the same process of setting up stacks and + * jumping to c code. It is important to save x25 from corruption as it contains + * the argument for secure monitor. + * ============================================================================= + */ #include #define __ASSEMBLY__ @@ -71,6 +79,10 @@ ENDPROC(cpu_get_exception_stack) * 16-byte aligned stack. The programming enviroment uses SP_EL0 as its main * stack while keeping SP_ELx reserved for exception entry. */ +/* + * IMPORTANT: Ensure x25 is not corrupted because it saves the argument to + * secmon + */ ENTRY(arm64_c_environment) bl smp_processor_id /* x0 = cpu */ mov x24, x0 @@ -92,14 +104,22 @@ ENTRY(arm64_c_environment) mov sp, x0 /* Get entry point by dereferencing c_entry. */ - ldr x0, 1f - ldr x0, [x0] - br x0 + ldr x1, 1f + ldr x1, [x1] + /* Move back the arguments from x25 to x0 */ + mov x0, x25 + br x1 .align 3 1: .quad c_entry ENDPROC(arm64_c_environment) +ENTRY(__rmodule_entry) + /* Save the arguments to secmon in x25 */ + mov x25, x0 + b arm64_c_environment +ENDPROC(__rmodule_entry) + CPU_RESET_ENTRY(arm64_cpu_startup) read_current x0, sctlr bic x0, x0, #(1 << 25) /* Little Endian */ -- cgit v1.2.3