From 7e619ecc89355136c27d0295858e08c808aa6373 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Mon, 16 Jan 2023 15:11:47 +0000 Subject: refactor(aarch64): refactor usage of elx_panic Currently we call el3_panic for panics from EL3 and elx_panic for panics from lower ELs. When we boot into a rich OS environment and interact with BL31 using SMC/ABI calls and we can also decide to handle any lower EL panics in EL3. Panic can occur in lower EL from rich OS or during SMC/ABI calls after context switch to EL3. But after booting into any rich OS we may land in panic either from rich OS or while servicing any SMC call, here the logic to use el3_panic or elx_panic is flawed as spsr_el3[3:0] is always EL3h and end up in elx_panic even if panic occurred from EL3 during SMC handling. We try to decouple the elx_panic usage for its intended purpose, introduce lower_el_panic which would call elx_panic, currently lower_el_panic is called from default platform_ea_handle which would be called due to panic from any of the lower ELs. Also remove the weak linkage for elx_panic and rename it to report_elx_panic which could be used with lower_el_panic. Change-Id: I268bca89c01c60520d127ef6c7ba851460edc747 Signed-off-by: Govindraj Raja --- bl31/aarch64/crash_reporting.S | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) (limited to 'bl31') diff --git a/bl31/aarch64/crash_reporting.S b/bl31/aarch64/crash_reporting.S index d56b513b8..6b9767c84 100644 --- a/bl31/aarch64/crash_reporting.S +++ b/bl31/aarch64/crash_reporting.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,7 +16,7 @@ .globl report_unhandled_exception .globl report_unhandled_interrupt .globl el3_panic - .globl elx_panic + .globl report_elx_panic #if CRASH_REPORTING @@ -64,7 +64,7 @@ intr_excpt_msg: x30_msg: .asciz "x30" excpt_msg_el: - .asciz "Unhandled Exception from EL" + .asciz "Unhandled Exception from lower EL.\n" /* * Helper function to print from crash buf. @@ -194,28 +194,20 @@ endfunc report_unhandled_interrupt /* ----------------------------------------------------- * This function allows to report a crash from the lower * exception level (if crash reporting is enabled) when - * panic() is invoked from C Runtime. + * lower_el_panic() is invoked from C Runtime. * It prints the CPU state via the crash console making * use of 'cpu_context' structure where general purpose * registers are saved and the crash buf. * This function will not return. - * - * x0: Exception level * ----------------------------------------------------- */ -func elx_panic +func report_elx_panic msr spsel, #MODE_SP_ELX - mov x8, x0 /* Print the crash message */ adr x4, excpt_msg_el bl asm_print_str - /* Print exception level */ - add x0, x8, #'0' - bl plat_crash_console_putc - bl asm_print_newline - /* Report x0 - x29 values stored in 'gpregs_ctx' structure */ /* Store the ascii list pointer in x6 */ adr x6, gp_regs @@ -295,7 +287,7 @@ from_el1: mrs x2, sctlr_el1 mrs x1, tcr_el1 b test_pauth -endfunc elx_panic +endfunc report_elx_panic /* ----------------------------------------------------- * This function allows to report a crash (if crash -- cgit v1.2.1 From f300ef662844e4b4b766b317f8083b778f79e303 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Mon, 16 Jan 2023 16:44:45 +0000 Subject: refactor(aarch64): remove weak links to el3_panic Cleanup weak links to el3_panic and restrict crash_reporting usage to bl31. Crash reporting is not used with bl1, bl2 and weak linkage to el3_panic is used, this can cause ambiguity in understanding the code so remove this weak linkage and introduce funcs that should be used when we have crash reporting for el3 panics. Change-Id: Ic5c711143ba36898ef9574a078b8fa02effceb12 Signed-off-by: Govindraj Raja --- bl31/aarch64/crash_reporting.S | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'bl31') diff --git a/bl31/aarch64/crash_reporting.S b/bl31/aarch64/crash_reporting.S index 6b9767c84..4cec1103e 100644 --- a/bl31/aarch64/crash_reporting.S +++ b/bl31/aarch64/crash_reporting.S @@ -15,7 +15,7 @@ .globl report_unhandled_exception .globl report_unhandled_interrupt - .globl el3_panic + .globl report_el3_panic .globl report_elx_panic #if CRASH_REPORTING @@ -297,7 +297,7 @@ endfunc report_elx_panic * will not return. * ----------------------------------------------------- */ -func el3_panic +func report_el3_panic msr spsel, #MODE_SP_ELX prepare_crash_buf_save_x0_x1 adr x0, panic_msg @@ -455,7 +455,7 @@ print_el3_sys_regs: /* Done reporting */ no_ret plat_panic_handler -endfunc el3_panic +endfunc report_el3_panic #else /* CRASH_REPORTING */ func report_unhandled_exception -- cgit v1.2.1 From bd62ce98d2c9ef164456c6477b2e21172165dc11 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Mon, 16 Jan 2023 17:35:07 +0000 Subject: refactor(aarch64): rename do_panic and el3_panic Current panic call invokes do_panic which calls el3_panic, but now panic handles only panic from EL3 anid clear separation to use lower_el_panic() which handles panic from lower ELs. So now we can remove do_panic and just call el3_panic for all panics. Change-Id: I739c69271b9fb15c1176050877a9b0c0394dc739 Signed-off-by: Govindraj Raja --- bl31/aarch64/ea_delegate.S | 2 +- bl31/aarch64/runtime_exceptions.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'bl31') diff --git a/bl31/aarch64/ea_delegate.S b/bl31/aarch64/ea_delegate.S index dbb32344d..0661583ca 100644 --- a/bl31/aarch64/ea_delegate.S +++ b/bl31/aarch64/ea_delegate.S @@ -201,7 +201,7 @@ func delegate_async_ea */ ubfx x2, x1, #ESR_EC_SHIFT, #ESR_EC_LENGTH cmp x2, EC_SERROR - b.ne do_panic + b.ne el3_panic /* * Check for Implementation Defined Syndrome. If so, skip checking * Uncontainable error type from the syndrome as the format is unknown. diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S index 0c608597c..cf79361c2 100644 --- a/bl31/aarch64/runtime_exceptions.S +++ b/bl31/aarch64/runtime_exceptions.S @@ -563,7 +563,7 @@ sysreg_handler64: */ tst w0, w0 - b.mi do_panic /* negative return value: panic */ + b.mi el3_panic /* negative return value: panic */ b.eq 1f /* zero: do not change ELR_EL3 */ /* advance the PC to continue after the instruction */ -- cgit v1.2.1 From 17d07a552b396a282eed52bfd6bac01052a1a978 Mon Sep 17 00:00:00 2001 From: Govindraj Raja Date: Tue, 21 Feb 2023 17:43:55 +0000 Subject: refactor(bl31): use elx_panic for sysreg_handler64 When we reach sysreg_handler64 from any trap handling we are entering this path from lower EL and thus we should be calling lower_el_panic reporting mechanism to print panic report. Make report_elx_panic available through assembly func elx_panic which could be used for reporting any lower_el_panic. Change-Id: Ieb260cf20ea327a59db84198b2c6a6bfc9ca9537 Signed-off-by: Govindraj Raja --- bl31/aarch64/runtime_exceptions.S | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bl31') diff --git a/bl31/aarch64/runtime_exceptions.S b/bl31/aarch64/runtime_exceptions.S index cf79361c2..2f00e7a85 100644 --- a/bl31/aarch64/runtime_exceptions.S +++ b/bl31/aarch64/runtime_exceptions.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2022, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2023, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -563,7 +563,7 @@ sysreg_handler64: */ tst w0, w0 - b.mi el3_panic /* negative return value: panic */ + b.mi elx_panic /* negative return value: panic */ b.eq 1f /* zero: do not change ELR_EL3 */ /* advance the PC to continue after the instruction */ -- cgit v1.2.1