1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2025-01-11 16:00:57 +00:00

core/embed: add explicit fault handlers

This commit is contained in:
Pavol Rusnak 2019-12-11 15:08:42 +00:00
parent c8c27dcd2f
commit b34675401c
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 27 additions and 2 deletions

View File

@ -109,7 +109,32 @@ int main(void) {
// MicroPython default exception handler
void __attribute__((noreturn)) nlr_jump_fail(void *val) {
ensure(secfalse, "uncaught exception");
error_shutdown("Internal error", "(UE)", NULL, NULL);
}
// interrupt handlers
void NMI_Handler(void) {
// Clock Security System triggered NMI
if ((RCC->CIR & RCC_CIR_CSSF) != 0) {
error_shutdown("Internal error", "(CS)", NULL, NULL);
}
}
void HardFault_Handler(void) {
error_shutdown("Internal error", "(HF)", NULL, NULL);
}
void MemManage_Handler(void) {
error_shutdown("Internal error", "(MM)", NULL, NULL);
}
void BusFault_Handler(void) {
error_shutdown("Internal error", "(BF)", NULL, NULL);
}
void UsageFault_Handler(void) {
error_shutdown("Internal error", "(UF)", NULL, NULL);
}
void PendSV_Handler(void) { pendsv_isr_handler(); }

View File

@ -163,7 +163,7 @@ void clear_otg_hs_memory(void) {
uint32_t __stack_chk_guard = 0;
void __attribute__((noreturn)) __stack_chk_fail(void) {
ensure(secfalse, "Stack smashing detected");
error_shutdown("Internal error", "(SS)", NULL, NULL);
}
uint8_t HW_ENTROPY_DATA[HW_ENTROPY_LEN];