diff --git a/Makefile b/Makefile index 5a7806476b823afd3ef450af774799a061cc94a4..6fb9e25af29ad943de52cdb93499ad004f093560 100644 --- a/Makefile +++ b/Makefile @@ -916,6 +916,7 @@ $(eval $(call assert_booleans,\ RAS_TRAP_LOWER_EL_ERR_ACCESS \ COT_DESC_IN_DTB \ USE_SP804_TIMER \ + AARCH32_EXCEPTION_DEBUG \ ))) $(eval $(call assert_numerics,\ @@ -1005,6 +1006,7 @@ $(eval $(call add_defines,\ RAS_TRAP_LOWER_EL_ERR_ACCESS \ COT_DESC_IN_DTB \ USE_SP804_TIMER \ + AARCH32_EXCEPTION_DEBUG \ ))) ifeq (${SANITIZE_UB},trap) diff --git a/bl1/aarch32/bl1_entrypoint.S b/bl1/aarch32/bl1_entrypoint.S index f2b236e4304c3b23304e185eb3910d8eed1932da..09ad3b035e893cfea97a61fa4adcea673f5a7a72 100644 --- a/bl1/aarch32/bl1_entrypoint.S +++ b/bl1/aarch32/bl1_entrypoint.S @@ -21,10 +21,19 @@ */ vector_base bl1_vector_table b bl1_entrypoint +#if AARCH32_EXCEPTION_DEBUG + b report_undef_inst /* Undef */ +#else b report_exception /* Undef */ +#endif b bl1_aarch32_smc_handler /* SMC call */ +#if AARCH32_EXCEPTION_DEBUG + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ +#else b report_exception /* Prefetch abort */ b report_exception /* Data abort */ +#endif 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 087b6656dc64813c849ed7ca219ffe96c8b6ee50..dff4e36a4aec016b83567f7b88cb26ab15bf95b9 100644 --- a/bl2/aarch32/bl2_el3_exceptions.S +++ b/bl2/aarch32/bl2_el3_exceptions.S @@ -12,10 +12,19 @@ vector_base bl2_vector_table b bl2_entrypoint +#if AARCH32_EXCEPTION_DEBUG + b report_undef_inst /* Undef */ +#else b report_exception /* Undef */ +#endif b report_exception /* SVC call */ +#if AARCH32_EXCEPTION_DEBUG + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ +#else b report_exception /* Prefetch abort */ b report_exception /* Data abort */ +#endif 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 102fd2f5143c9337c2b65633c54a224ef7cec181..bfd721ca1d5a04ca7f0c30246a789934bcc1e646 100644 --- a/bl2/aarch32/bl2_entrypoint.S +++ b/bl2/aarch32/bl2_entrypoint.S @@ -14,10 +14,19 @@ vector_base bl2_vector_table b bl2_entrypoint +#if AARCH32_EXCEPTION_DEBUG + b report_undef_inst /* Undef */ +#else b report_exception /* Undef */ +#endif b report_exception /* SVC call */ +#if AARCH32_EXCEPTION_DEBUG + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ +#else b report_exception /* Prefetch abort */ b report_exception /* Data abort */ +#endif 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 6391f537cd2cafb4462efce603c111caa508f8e9..426176d98e3f4e1f1ac3c8a696964e29e4124cd2 100644 --- a/bl2u/aarch32/bl2u_entrypoint.S +++ b/bl2u/aarch32/bl2u_entrypoint.S @@ -14,10 +14,19 @@ vector_base bl2u_vector_table b bl2u_entrypoint +#if AARCH32_EXCEPTION_DEBUG + b report_undef_inst /* Undef */ +#else b report_exception /* Undef */ +#endif b report_exception /* SVC call */ +#if AARCH32_EXCEPTION_DEBUG + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ +#else b report_exception /* Prefetch abort */ b report_exception /* Data abort */ +#endif 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 c3b516eb4cc7e2e0cb6a554a8c6e551db919d2f4..b73943aca81da405e219e38ab6378b99fb2ca2d4 100644 --- a/bl32/sp_min/aarch32/entrypoint.S +++ b/bl32/sp_min/aarch32/entrypoint.S @@ -49,10 +49,19 @@ vector_base sp_min_vector_table b sp_min_entrypoint +#if AARCH32_EXCEPTION_DEBUG + b report_undef_inst /* Undef */ +#else b plat_panic_handler /* Undef */ +#endif b sp_min_handle_smc /* Syscall */ +#if AARCH32_EXCEPTION_DEBUG + b report_prefetch_abort /* Prefetch abort */ + b report_data_abort /* Data abort */ +#else b plat_panic_handler /* Prefetch abort */ b plat_panic_handler /* Data abort */ +#endif 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 9d410df07ead4f94912804b8f363db369bff5384..450798ae63891c601460933a600000b753af4589 100644 --- a/common/aarch32/debug.S +++ b/common/aarch32/debug.S @@ -14,6 +14,11 @@ .globl asm_assert .globl do_panic .globl report_exception +#if AARCH32_EXCEPTION_DEBUG + .globl report_undef_inst + .globl report_prefetch_abort + .globl report_data_abort +#endif /* Since the max decimal input number is 65536 */ #define MAX_DEC_DIVISOR 10000 @@ -205,3 +210,38 @@ func report_exception bl plat_report_exception no_ret plat_panic_handler endfunc report_exception + +#if AARCH32_EXCEPTION_DEBUG + /*********************************************************** + * This function is called from the vector table for + * undefined instruction. The lr_und is given as an + * argument to platform handler. + ***********************************************************/ +func report_undef_inst + mrs r0, lr_und + bl plat_report_undef_inst + no_ret plat_panic_handler +endfunc report_undef_inst + + /*********************************************************** + * 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 + mrs r0, lr_abt + bl plat_report_prefetch_abort + no_ret plat_panic_handler +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 + mrs r0, lr_abt + bl plat_report_data_abort + no_ret plat_panic_handler +endfunc report_data_abort +#endif diff --git a/include/plat/common/platform.h b/include/plat/common/platform.h index ebcc8557745946cf0c40c0f8c2f8eaa85ececcce..9b81a8413474a791febe944141b18ca626f3de9a 100644 --- a/include/plat/common/platform.h +++ b/include/plat/common/platform.h @@ -109,6 +109,11 @@ 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); +#if AARCH32_EXCEPTION_DEBUG +void plat_report_undef_inst(unsigned int fault_address); +void plat_report_prefetch_abort(unsigned int fault_address); +void plat_report_data_abort(unsigned int fault_address); +#endif int plat_crash_console_init(void); int plat_crash_console_putc(int c); void plat_crash_console_flush(void); diff --git a/make_helpers/defaults.mk b/make_helpers/defaults.mk index 578bd59876a8681ab7e2ae8b78eba0aa063ea5e1..f05981d91cc3cd1d797b89af43a30087ccd9c92e 100644 --- a/make_helpers/defaults.mk +++ b/make_helpers/defaults.mk @@ -126,6 +126,9 @@ ENC_KEY := 1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef # Default dummy nonce for firmware encryption ENC_NONCE := 1234567890abcdef12345678 +# Flag to enable exception debug for AARCH32 +AARCH32_EXCEPTION_DEBUG := 0 + # Build flag to treat usage of deprecated platform and framework APIs as error. ERROR_DEPRECATED := 0 diff --git a/plat/common/aarch32/platform_helpers.S b/plat/common/aarch32/platform_helpers.S index 5b9cb591460009ec333b6414adffdc7ebda7a6d0..d2c20b4a7d408a8d731a0418f88d63094726549f 100644 --- a/plat/common/aarch32/platform_helpers.S +++ b/plat/common/aarch32/platform_helpers.S @@ -8,6 +8,11 @@ #include <asm_macros.S> .weak plat_report_exception +#if AARCH32_EXCEPTION_DEBUG + .weak plat_report_undef_inst + .weak plat_report_prefetch_abort + .weak plat_report_data_abort +#endif .weak plat_reset_handler .weak plat_disable_acp .weak bl1_plat_prepare_exit @@ -23,6 +28,35 @@ func plat_report_exception bx lr endfunc plat_report_exception +#if AARCH32_EXCEPTION_DEBUG + /* ----------------------------------------------------- + * Placeholder function which should be redefined by + * each platform. + * ----------------------------------------------------- + */ +func plat_report_undef_inst + bx lr +endfunc plat_report_undef_inst + + /* ----------------------------------------------------- + * 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 +#endif + /* ----------------------------------------------------- * Placeholder function which should be redefined by * each platform.