Skip to content

Commit

Permalink
arch: arm: BusFault, NMI, and HardFault in Secure state when in test
Browse files Browse the repository at this point in the history
This commit enables the option to route the BusFault,
HardFault, and NMI exceptions in Secure state, when
building for Cortex-M CPUs with ARM_SECURE_FIRMWARE=y.
This allows the various test to utilize BusFault,
HardFault and NMI exceptions during testing.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information
ioannisg committed Aug 9, 2019
1 parent 7f74825 commit a3ee56f
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
7 changes: 7 additions & 0 deletions arch/arm/core/Kconfig
Expand Up @@ -105,6 +105,13 @@ comment "Secure firmware"
comment "Non-secure firmware"
depends on !ARM_SECURE_FIRMWARE

config ARM_SECURE_BUSFAULT_HARDFAULT_NMI
bool "BusFault, HardFault, and NMI target Secure state"
depends on ARM_SECURE_FIRMWARE
help
Force NMI, HardFault, and BusFault (in Mainline ARMv8-M)
exceptions as Secure exceptions.

config ARM_FIRMWARE_HAS_SECURE_ENTRY_FUNCS
bool "Secure Firmware has Secure Entry functions"
depends on ARM_SECURE_FIRMWARE
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/include/cortex_m/exc.h
Expand Up @@ -112,7 +112,8 @@ static ALWAYS_INLINE void z_ExcSetup(void)
#endif /* CONFIG_ARM_SECURE_FIRMWARE */
#endif /* CONFIG_CPU_CORTEX_M_HAS_PROGRAMMABLE_FAULT_PRIOS */

#if defined(CONFIG_ARM_SECURE_FIRMWARE)
#if defined(CONFIG_ARM_SECURE_FIRMWARE) && \
!defined(CONFIG_ARM_SECURE_BUSFAULT_HARDFAULT_NMI)
/* Set NMI, Hard, and Bus Faults as Non-Secure.
* NMI and Bus Faults targeting the Secure state will
* escalate to a SecureFault or SecureHardFault.
Expand All @@ -126,7 +127,7 @@ static ALWAYS_INLINE void z_ExcSetup(void)
* in a PE with the Main Extension instead generate a
* SecureHardFault in a PE without the Main Extension.
*/
#endif /* CONFIG_ARM_SECURE_FIRMWARE */
#endif /* ARM_SECURE_FIRMWARE && !ARM_SECURE_BUSFAULT_HARDFAULT_NMI */
}

/**
Expand Down
15 changes: 15 additions & 0 deletions subsys/testsuite/Kconfig
Expand Up @@ -111,4 +111,19 @@ config TEST_FLASH_DRIVERS
This option will help test the flash drivers. This should be enabled
only when using qemu_x86.

config TEST_ARM_CORTEX_M
bool
depends on CPU_CORTEX_M
default y
select ARM_SECURE_BUSFAULT_HARDFAULT_NMI if ARM_SECURE_FIRMWARE
help
ARM Cortex-M configuration required when testing.

Currently, this option is only utilized, to force routing
BusFault, HardFault, and NMI exceptions to Secure State,
when building a Secure ARMv8-M firmware. This will allow
the testing suite to utilize these exceptions, in tests.
Note that by default, when building with ARM_SECURE_FIRMWARE
set, these exceptions are set to target the Non-Secure state.

endmenu

0 comments on commit a3ee56f

Please sign in to comment.