arch: arm: ignore stack pointer limit checks during HF and NMI
Ignore stack pointer limit checking during a HardFault or NMI exception, to allow for the Fault handling function to execute properly. Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
parent
4a41f42e73
commit
91dc3bd0f9
1 changed files with 18 additions and 0 deletions
|
@ -524,4 +524,22 @@ void _FaultInit(void)
|
||||||
#else
|
#else
|
||||||
#error Unknown ARM architecture
|
#error Unknown ARM architecture
|
||||||
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
#endif /* CONFIG_ARMV6_M_ARMV8_M_BASELINE */
|
||||||
|
#if defined(CONFIG_BUILTIN_STACK_GUARD)
|
||||||
|
/* If Stack guarding via SP limit checking is enabled, disable
|
||||||
|
* SP limit checking inside HardFault and NMI. This is done
|
||||||
|
* in order to allow for the desired fault logging to execute
|
||||||
|
* properly in all cases.
|
||||||
|
*
|
||||||
|
* Note that this could allow a Secure Firmware Main Stack
|
||||||
|
* to descend into non-secure region during HardFault and
|
||||||
|
* NMI exception entry. To prevent from this, non-secure
|
||||||
|
* memory regions must be located higher than secure memory
|
||||||
|
* regions.
|
||||||
|
*
|
||||||
|
* For Non-Secure Firmware this could allow the Non-Secure Main
|
||||||
|
* Stack to attempt to descend into secure region, in which case a
|
||||||
|
* Secure Hard Fault will occur and we can track the fault from there.
|
||||||
|
*/
|
||||||
|
SCB->CCR |= SCB_CCR_STKOFHFNMIGN_Msk;
|
||||||
|
#endif /* CONFIG_BUILTIN_STACK_GUARD */
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue