1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 22:38:08 +00:00

fix(core/embed): make HardFault processing safer

[no changelog]
This commit is contained in:
cepetr 2024-08-20 08:55:15 +02:00 committed by cepetr
parent 2bb5b5c0ce
commit 0b93d0d848

View File

@ -5,7 +5,16 @@ void fault_handlers_init(void) {
SCB->SHCSR |= (SCB_SHCSR_USGFAULTENA_Msk | SCB_SHCSR_BUSFAULTENA_Msk);
}
void HardFault_Handler(void) { error_shutdown("(HF)"); }
void HardFault_Handler(void) {
// A HardFault may also be caused by exception escalation.
// To ensure we have enough space to handle the exception,
// we set the stack pointer to the end of the stack.
extern uint8_t _estack; // linker script symbol
// Fix stack pointer
__set_MSP((uint32_t)&_estack);
error_shutdown("(HF)");
}
void MemManage_Handler(void) { error_shutdown("(MM)"); }