mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-29 18:08:19 +00:00
fix(core): fix nmi handling
[no changelog]
This commit is contained in:
parent
4754fd8e34
commit
64c22a8e65
@ -803,16 +803,48 @@ __attribute__((naked, no_stack_protector)) void GTZC_IRQHandler(void) {
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
__attribute__((no_stack_protector, used)) static void nmi_handler(
|
__attribute__((no_stack_protector, used)) static void nmi_handler(void) {
|
||||||
uint32_t msp, uint32_t exc_return) {
|
mpu_mode_t mpu_mode = mpu_reconfig(MPU_MODE_DEFAULT);
|
||||||
mpu_reconfig(MPU_MODE_DEFAULT);
|
|
||||||
// Clear pending Clock security interrupt flag
|
|
||||||
#ifdef STM32U5
|
#ifdef STM32U5
|
||||||
|
if ((RCC->CIFR & RCC_CIFR_CSSF) != 0) {
|
||||||
RCC->CICR = RCC_CICR_CSSC;
|
RCC->CICR = RCC_CICR_CSSC;
|
||||||
#else
|
#else
|
||||||
|
if ((RCC->CIR & RCC_CIR_CSSF) != 0) {
|
||||||
RCC->CIR = RCC_CIR_CSSC;
|
RCC->CIR = RCC_CIR_CSSC;
|
||||||
#endif
|
#endif
|
||||||
systask_exit_fault(msp, exc_return);
|
// Clock Security System triggered NMI
|
||||||
|
systask_exit_fault(true, __get_MSP());
|
||||||
|
}
|
||||||
|
#ifdef STM32U5
|
||||||
|
else if (FLASH->ECCR & FLASH_ECCR_ECCD_Msk) {
|
||||||
|
// FLASH ECC double error
|
||||||
|
uint32_t addr = FLASH->ECCR & FLASH_ECCR_ADDR_ECC_Msk;
|
||||||
|
uint32_t bankid =
|
||||||
|
(FLASH->ECCR & FLASH_ECCR_BK_ECC_Msk) >> FLASH_ECCR_BK_ECC_Pos;
|
||||||
|
#if defined(BOARDLOADER)
|
||||||
|
// In boardloader, this is a fatal error only if the address
|
||||||
|
// is in the bootloader code region.
|
||||||
|
if (bankid == 0 && addr >= BOARDLOADER_START &&
|
||||||
|
addr < BOARDLOADER_START + BOARDLOADER_MAXSIZE) {
|
||||||
|
systask_exit_fault(false, __get_MSP());
|
||||||
|
}
|
||||||
|
#elif defined(BOOTLOADER)
|
||||||
|
// In bootloader, this is a fatal error only if the address
|
||||||
|
// is in the bootloader code region.
|
||||||
|
if (bankid == 0 && addr >= BOOTLOADER_START &&
|
||||||
|
addr < BOOTLOADER_START + BOOTLOADER_MAXSIZE) {
|
||||||
|
systask_exit_fault(false, __get_MSP());
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)addr;
|
||||||
|
(void)bankid;
|
||||||
|
// In application/prodtest this is a fatal error
|
||||||
|
systask_exit_fault(false, __get_MSP());
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif // STM32U5
|
||||||
|
|
||||||
|
mpu_restore(mpu_mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
__attribute__((no_stack_protector)) void NMI_Handler(void) {
|
__attribute__((no_stack_protector)) void NMI_Handler(void) {
|
||||||
|
Loading…
Reference in New Issue
Block a user