From 6dc5979a6cb2121e4c16e7bd62e24030e0f42755 Mon Sep 17 00:00:00 2001 From: Yann Gautier Date: Fri, 15 Feb 2019 16:42:20 +0100 Subject: [PATCH] feat(debug): add helpers for aborts on AARCH32 New helper functions are created to handle data & prefetch aborts in AARCH32. They call platform functions, just like what report_exception is doing. As extended MSR/MRS instructions (to access lr_abt in monitor mode) are only available if CPU (Armv7) has virtualization extension, the functions branch to original report_exception handlers if this is not the case. Those new helpers are created mainly to distinguish data and prefetch aborts, as they both share the same mode. This adds 40 bytes of code. Change-Id: I5dd31930344ad4e3a658f8a9d366a87a300aeb67 Signed-off-by: Yann Gautier --- bl1/aarch32/bl1_entrypoint.S | 6 ++--- bl2/aarch32/bl2_el3_exceptions.S | 6 ++--- bl2/aarch32/bl2_entrypoint.S | 6 ++--- bl2u/aarch32/bl2u_entrypoint.S | 6 ++--- bl32/sp_min/aarch32/entrypoint.S | 6 ++--- common/aarch32/debug.S | 34 +++++++++++++++++++++++++- include/plat/common/platform.h | 2 ++ plat/common/aarch32/platform_helpers.S | 22 ++++++++++++++++- 8 files changed, 71 insertions(+), 17 deletions(-) diff --git a/bl1/aarch32/bl1_entrypoint.S b/bl1/aarch32/bl1_entrypoint.S index 94dfd3738..b22015eb9 100644 --- a/bl1/aarch32/bl1_entrypoint.S +++ b/bl1/aarch32/bl1_entrypoint.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -23,8 +23,8 @@ vector_base bl1_vector_table b bl1_entrypoint b report_exception /* Undef */ b bl1_aarch32_smc_handler /* SMC call */ - b report_exception /* Prefetch abort */ - b report_exception /* Data abort */ + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ b report_exception /* Reserved */ b report_exception /* IRQ */ b report_exception /* FIQ */ diff --git a/bl2/aarch32/bl2_el3_exceptions.S b/bl2/aarch32/bl2_el3_exceptions.S index 087b6656d..eaa258261 100644 --- a/bl2/aarch32/bl2_el3_exceptions.S +++ b/bl2/aarch32/bl2_el3_exceptions.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2017-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,8 +14,8 @@ vector_base bl2_vector_table b bl2_entrypoint b report_exception /* Undef */ b report_exception /* SVC call */ - b report_exception /* Prefetch abort */ - b report_exception /* Data abort */ + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ b report_exception /* Reserved */ b report_exception /* IRQ */ b report_exception /* FIQ */ diff --git a/bl2/aarch32/bl2_entrypoint.S b/bl2/aarch32/bl2_entrypoint.S index 6e8e2c1e1..678d9c2f0 100644 --- a/bl2/aarch32/bl2_entrypoint.S +++ b/bl2/aarch32/bl2_entrypoint.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,8 +16,8 @@ vector_base bl2_vector_table b bl2_entrypoint b report_exception /* Undef */ b report_exception /* SVC call */ - b report_exception /* Prefetch abort */ - b report_exception /* Data abort */ + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ b report_exception /* Reserved */ b report_exception /* IRQ */ b report_exception /* FIQ */ diff --git a/bl2u/aarch32/bl2u_entrypoint.S b/bl2u/aarch32/bl2u_entrypoint.S index e4dd03dec..106378915 100644 --- a/bl2u/aarch32/bl2u_entrypoint.S +++ b/bl2u/aarch32/bl2u_entrypoint.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -16,8 +16,8 @@ vector_base bl2u_vector_table b bl2u_entrypoint b report_exception /* Undef */ b report_exception /* SVC call */ - b report_exception /* Prefetch abort */ - b report_exception /* Data abort */ + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ b report_exception /* Reserved */ b report_exception /* IRQ */ b report_exception /* FIQ */ diff --git a/bl32/sp_min/aarch32/entrypoint.S b/bl32/sp_min/aarch32/entrypoint.S index 39f1065f0..f10296724 100644 --- a/bl32/sp_min/aarch32/entrypoint.S +++ b/bl32/sp_min/aarch32/entrypoint.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2021, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -51,8 +51,8 @@ vector_base sp_min_vector_table b sp_min_entrypoint b plat_panic_handler /* Undef */ b sp_min_handle_smc /* Syscall */ - b plat_panic_handler /* Prefetch abort */ - b plat_panic_handler /* Data abort */ + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ b plat_panic_handler /* Reserved */ b plat_panic_handler /* IRQ */ b sp_min_handle_fiq /* FIQ */ diff --git a/common/aarch32/debug.S b/common/aarch32/debug.S index 9d410df07..ae0bb7ac7 100644 --- a/common/aarch32/debug.S +++ b/common/aarch32/debug.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -14,6 +14,8 @@ .globl asm_assert .globl do_panic .globl report_exception + .globl report_prefetch_abort + .globl report_data_abort /* Since the max decimal input number is 65536 */ #define MAX_DEC_DIVISOR 10000 @@ -205,3 +207,33 @@ func report_exception bl plat_report_exception no_ret plat_panic_handler endfunc report_exception + + /*********************************************************** + * This function is called from the vector table for + * unhandled exceptions. The lr_abt is given as an + * argument to platform handler. + ***********************************************************/ +func report_prefetch_abort +#if ARM_ARCH_MAJOR == 7 && !defined(ARMV7_SUPPORTS_VIRTUALIZATION) + b report_exception +#else + mrs r0, lr_abt + bl plat_report_prefetch_abort + no_ret plat_panic_handler +#endif +endfunc report_prefetch_abort + + /*********************************************************** + * This function is called from the vector table for + * unhandled exceptions. The lr_abt is given as an + * argument to platform handler. + ***********************************************************/ +func report_data_abort +#if ARM_ARCH_MAJOR == 7 && !defined(ARMV7_SUPPORTS_VIRTUALIZATION) + b report_exception +#else + mrs r0, lr_abt + bl plat_report_data_abort + no_ret plat_panic_handler +#endif +endfunc report_data_abort diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index 31607c2e9..da7462467 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -118,6 +118,8 @@ unsigned int plat_ic_get_interrupt_id(unsigned int raw); ******************************************************************************/ uintptr_t plat_get_my_stack(void); void plat_report_exception(unsigned int exception_type); +void plat_report_prefetch_abort(unsigned int fault_address); +void plat_report_data_abort(unsigned int fault_address); int plat_crash_console_init(void); int plat_crash_console_putc(int c); void plat_crash_console_flush(void); diff --git a/plat/common/aarch32/platform_helpers.S b/plat/common/aarch32/platform_helpers.S index 5b9cb5914..75cc456c4 100644 --- a/plat/common/aarch32/platform_helpers.S +++ b/plat/common/aarch32/platform_helpers.S @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016-2019, ARM Limited and Contributors. All rights reserved. + * Copyright (c) 2016-2022, ARM Limited and Contributors. All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ @@ -8,6 +8,8 @@ #include .weak plat_report_exception + .weak plat_report_prefetch_abort + .weak plat_report_data_abort .weak plat_reset_handler .weak plat_disable_acp .weak bl1_plat_prepare_exit @@ -23,6 +25,24 @@ func plat_report_exception bx lr endfunc plat_report_exception + /* ----------------------------------------------------- + * Placeholder function which should be redefined by + * each platform. + * ----------------------------------------------------- + */ +func plat_report_prefetch_abort + bx lr +endfunc plat_report_prefetch_abort + + /* ----------------------------------------------------- + * Placeholder function which should be redefined by + * each platform. + * ----------------------------------------------------- + */ +func plat_report_data_abort + bx lr +endfunc plat_report_data_abort + /* ----------------------------------------------------- * Placeholder function which should be redefined by * each platform.