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 diff --git a/common/aarch64/debug.S b/common/aarch64/debug.S index 742e022d5..5fdaf6417 100644 --- a/common/aarch64/debug.S +++ b/common/aarch64/debug.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 */ @@ -160,31 +160,10 @@ endfunc asm_print_newline /* This is for the non el3 BL stages to compile through */ .weak el3_panic - .weak elx_panic func do_panic #if CRASH_REPORTING - str x0, [sp, #-0x10]! - mrs x0, currentel - ubfx x0, x0, #MODE_EL_SHIFT, #MODE_EL_WIDTH - cmp x0, #MODE_EL3 -#if !HANDLE_EA_EL3_FIRST_NS - ldr x0, [sp], #0x10 - b.eq el3_panic -#else - b.ne to_panic_common - - /* Check EL the exception taken from */ - mrs x0, spsr_el3 - ubfx x0, x0, #SPSR_EL_SHIFT, #SPSR_EL_WIDTH - cmp x0, #MODE_EL3 - b.ne elx_panic - ldr x0, [sp], #0x10 b el3_panic - -to_panic_common: - ldr x0, [sp], #0x10 -#endif /* HANDLE_EA_EL3_FIRST_NS */ #endif /* CRASH_REPORTING */ panic_common: diff --git a/include/common/debug.h b/include/common/debug.h index af47999c3..9f5f7c371 100644 --- a/include/common/debug.h +++ b/include/common/debug.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2013-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -100,6 +100,7 @@ void backtrace(const char *cookie); #endif void __dead2 do_panic(void); +void __dead2 report_elx_panic(void); #define panic() \ do { \ @@ -108,6 +109,21 @@ void __dead2 do_panic(void); do_panic(); \ } while (false) +#if CRASH_REPORTING +/* -------------------------------------------------------------------- + * do_lower_el_panic assumes it's called due to a panic from a lower EL + * This call will not return. + * -------------------------------------------------------------------- + */ +#define lower_el_panic() \ + do { \ + console_flush(); \ + report_elx_panic(); \ + } while (false) +#else +#define lower_el_panic() +#endif + /* Function called when stack protection check code detects a corrupted stack */ void __dead2 __stack_chk_fail(void); diff --git a/plat/common/aarch64/plat_common.c b/plat/common/aarch64/plat_common.c index 3495323e3..042916a7d 100644 --- a/plat/common/aarch64/plat_common.c +++ b/plat/common/aarch64/plat_common.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014-2023, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2014-2023, Arm Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -94,5 +94,8 @@ void plat_default_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *co read_mpidr_el1(), get_el_str(level)); ERROR("exception reason=%u syndrome=0x%" PRIx64 "\n", ea_reason, syndrome); - panic(); + /* We reached here due to a panic from a lower EL and assuming this is the default + * platform registered handler that we could call on a lower EL panic. + */ + lower_el_panic(); }