mirror of
https://github.com/ARM-software/arm-trusted-firmware.git
synced 2025-04-16 09:34:18 +00:00
Merge changes from topic "panic_cleanup" into integration
* changes: refactor(bl31): use elx_panic for sysreg_handler64 refactor(aarch64): rename do_panic and el3_panic refactor(aarch64): remove weak links to el3_panic refactor(aarch64): refactor usage of elx_panic refactor(aarch64): cleanup HANDLE_EA_EL3_FIRST_NS usage
This commit is contained in:
commit
dc2b8e8028
11 changed files with 81 additions and 85 deletions
|
@ -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
|
||||
*/
|
||||
|
@ -15,8 +15,8 @@
|
|||
|
||||
.globl report_unhandled_exception
|
||||
.globl report_unhandled_interrupt
|
||||
.globl el3_panic
|
||||
.globl elx_panic
|
||||
.globl report_el3_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
|
||||
|
@ -305,7 +297,7 @@ endfunc 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
|
||||
|
@ -463,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
|
||||
|
|
|
@ -190,7 +190,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.
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -569,7 +569,7 @@ sysreg_handler64:
|
|||
*/
|
||||
|
||||
tst w0, w0
|
||||
b.mi do_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 */
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
.globl asm_print_hex
|
||||
.globl asm_print_hex_bits
|
||||
.globl asm_assert
|
||||
.globl do_panic
|
||||
.globl el3_panic
|
||||
.globl report_exception
|
||||
.globl report_prefetch_abort
|
||||
.globl report_data_abort
|
||||
|
@ -159,14 +159,14 @@ asm_print_hex_bits:
|
|||
endfunc asm_print_hex
|
||||
|
||||
/***********************************************************
|
||||
* The common implementation of do_panic for all BL stages
|
||||
* The common implementation of el3_panic for all BL stages
|
||||
***********************************************************/
|
||||
|
||||
.section .rodata.panic_str, "aS"
|
||||
panic_msg: .asciz "PANIC at PC : 0x"
|
||||
panic_end: .asciz "\r\n"
|
||||
|
||||
func do_panic
|
||||
func el3_panic
|
||||
/* Have LR copy point to PC at the time of panic */
|
||||
sub r6, lr, #4
|
||||
|
||||
|
@ -194,7 +194,7 @@ func do_panic
|
|||
_panic_handler:
|
||||
mov lr, r6
|
||||
b plat_panic_handler
|
||||
endfunc do_panic
|
||||
endfunc el3_panic
|
||||
|
||||
/***********************************************************
|
||||
* This function is called from the vector table for
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -13,7 +13,8 @@
|
|||
.globl asm_print_hex_bits
|
||||
.globl asm_print_newline
|
||||
.globl asm_assert
|
||||
.globl do_panic
|
||||
.globl el3_panic
|
||||
.globl elx_panic
|
||||
|
||||
/* Since the max decimal input number is 65536 */
|
||||
#define MAX_DEC_DIVISOR 10000
|
||||
|
@ -145,54 +146,33 @@ func asm_print_newline
|
|||
endfunc asm_print_newline
|
||||
|
||||
/***********************************************************
|
||||
* The common implementation of do_panic for all BL stages
|
||||
* The common implementation of el3_panic for all BL stages
|
||||
***********************************************************/
|
||||
|
||||
.section .rodata.panic_str, "aS"
|
||||
panic_msg: .asciz "PANIC at PC : 0x"
|
||||
|
||||
func elx_panic
|
||||
#if CRASH_REPORTING && defined(IMAGE_BL31)
|
||||
b report_elx_panic
|
||||
#endif /* CRASH_REPORTING && IMAGE_BL31 */
|
||||
|
||||
b panic_common
|
||||
endfunc elx_panic
|
||||
|
||||
/* ---------------------------------------------------------------------------
|
||||
* do_panic assumes that it is invoked from a C Runtime Environment ie a
|
||||
* el3_panic assumes that it is invoked from a C Runtime Environment ie a
|
||||
* valid stack exists. This call will not return.
|
||||
* Clobber list : if CRASH_REPORTING is not enabled then x30, x0 - x6
|
||||
* ---------------------------------------------------------------------------
|
||||
*/
|
||||
|
||||
/* 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 */
|
||||
func el3_panic
|
||||
#if CRASH_REPORTING && defined(IMAGE_BL31)
|
||||
b report_el3_panic
|
||||
#endif /* CRASH_REPORTING && IMAGE_BL31 */
|
||||
|
||||
panic_common:
|
||||
/*
|
||||
* el3_panic will be redefined by the BL31
|
||||
* crash reporting mechanism (if enabled)
|
||||
*/
|
||||
el3_panic:
|
||||
mov x6, x30
|
||||
bl plat_crash_console_init
|
||||
|
||||
|
@ -218,4 +198,5 @@ _panic_handler:
|
|||
* called, not the address of the call from el3_panic. */
|
||||
mov x30, x6
|
||||
b plat_panic_handler
|
||||
endfunc do_panic
|
||||
|
||||
endfunc el3_panic
|
||||
|
|
|
@ -3204,9 +3204,20 @@ as Group 0 secure interrupt, Group 1 secure interrupt or Group 1 NS interrupt.
|
|||
|
||||
Common helper functions
|
||||
-----------------------
|
||||
Function : elx_panic()
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Function : do_panic()
|
||||
~~~~~~~~~~~~~~~~~~~~~
|
||||
::
|
||||
|
||||
Argument : void
|
||||
Return : void
|
||||
|
||||
This API is called from assembly files when reporting a critical failure
|
||||
that has occured in lower EL and is been trapped in EL3. This call
|
||||
**must not** return.
|
||||
|
||||
Function : el3_panic()
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
::
|
||||
|
||||
|
@ -3214,9 +3225,8 @@ Function : do_panic()
|
|||
Return : void
|
||||
|
||||
This API is called from assembly files when encountering a critical failure that
|
||||
cannot be recovered from. It also invokes elx_panic() which allows to report a
|
||||
crash from lower exception level. This function assumes that it is invoked from
|
||||
a C runtime environment i.e. valid stack exists. This call **must not** return.
|
||||
cannot be recovered from. This function assumes that it is invoked from a C
|
||||
runtime environment i.e. valid stack exists. This call **must not** return.
|
||||
|
||||
Function : panic()
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
@ -3228,7 +3238,7 @@ Function : panic()
|
|||
|
||||
This API called from C files when encountering a critical failure that cannot
|
||||
be recovered from. This function in turn prints backtrace (if enabled) and calls
|
||||
do_panic(). This call **must not** return.
|
||||
el3_panic(). This call **must not** return.
|
||||
|
||||
Crash Reporting mechanism (in BL31)
|
||||
-----------------------------------
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2022, Arm Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2015-2023 Arm Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
@ -99,15 +99,31 @@ void backtrace(const char *cookie);
|
|||
#define backtrace(x)
|
||||
#endif
|
||||
|
||||
void __dead2 do_panic(void);
|
||||
void __dead2 el3_panic(void);
|
||||
void __dead2 elx_panic(void);
|
||||
|
||||
#define panic() \
|
||||
do { \
|
||||
backtrace(__func__); \
|
||||
console_flush(); \
|
||||
do_panic(); \
|
||||
el3_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(); \
|
||||
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);
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
.globl el2_panic
|
||||
|
||||
/***********************************************************
|
||||
* The common implementation of do_panic for all BL stages
|
||||
* The common implementation of el3_panic for all BL stages
|
||||
***********************************************************/
|
||||
|
||||
.section .rodata.panic_str, "aS"
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (c) 2014-2022, ARM Limited and Contributors. All rights reserved.
|
||||
* Copyright (c) 2014-2023, Arm Limited and Contributors. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
@ -77,7 +77,7 @@ const char *get_el_str(unsigned int el)
|
|||
return "EL1";
|
||||
}
|
||||
|
||||
/* RAS functions common to AArch64 ARM platforms */
|
||||
/* Handler for External Aborts from lower EL including RAS errors */
|
||||
void plat_default_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *cookie,
|
||||
void *handle, uint64_t flags)
|
||||
{
|
||||
|
@ -93,12 +93,9 @@ void plat_default_ea_handler(unsigned int ea_reason, uint64_t syndrome, void *co
|
|||
ERROR("Unhandled External Abort received on 0x%lx from %s\n",
|
||||
read_mpidr_el1(), get_el_str(level));
|
||||
ERROR("exception reason=%u syndrome=0x%" PRIx64 "\n", ea_reason, syndrome);
|
||||
#if HANDLE_EA_EL3_FIRST_NS
|
||||
/* Skip backtrace for lower EL */
|
||||
if (level != MODE_EL3) {
|
||||
console_flush();
|
||||
do_panic();
|
||||
}
|
||||
#endif
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
* Copyright (c) 2015-2021, Renesas Electronics Corporation. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
|
@ -126,7 +126,7 @@ warm_reset:
|
|||
exit:
|
||||
ret x9
|
||||
_panic:
|
||||
b do_panic
|
||||
b el3_panic
|
||||
#endif
|
||||
|
||||
endfunc plat_get_my_entrypoint
|
||||
|
|
Loading…
Add table
Reference in a new issue