diff --git a/arch/arm/core/aarch32/cortex_m/Kconfig b/arch/arm/core/aarch32/cortex_m/Kconfig index 2a52d924a9b02d..da8be9c6c1f072 100644 --- a/arch/arm/core/aarch32/cortex_m/Kconfig +++ b/arch/arm/core/aarch32/cortex_m/Kconfig @@ -310,6 +310,9 @@ endmenu choice CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION bool "Enable and use null-pointer exception" + default CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_DWT if TEST_ARM_CORTEX_M && !ARM_NONSECURE_FIRMWARE && CPU_CORTEX_M_HAS_DWT + default CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_MPU if TEST_ARM_CORTEX_M && !ARM_NONSECURE_FIRMWARE && ARM_MPU && !CPU_CORTEX_M_HAS_DWT + default CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE help There are 2 implementations available, one based on DWT and the other based on MPU. Use this choice diff --git a/boards/arm/mps2_an521/Kconfig.defconfig b/boards/arm/mps2_an521/Kconfig.defconfig index 2dcef350bdc200..42536e04566fda 100644 --- a/boards/arm/mps2_an521/Kconfig.defconfig +++ b/boards/arm/mps2_an521/Kconfig.defconfig @@ -3,6 +3,14 @@ if BOARD_MPS2_AN521 +# MPU-based null-pointer dereferencing detection cannot +# be applied as the (0x0 - 0x400) is unmapped but QEMU +# will still permit bus access. +choice CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION + bool + default CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE if QEMU_TARGET +endchoice + config BOARD default "mps2_an521_nonsecure" if TRUSTED_EXECUTION_NONSECURE default "mps2_an521" diff --git a/boards/arm/qemu_cortex_m3/Kconfig.defconfig b/boards/arm/qemu_cortex_m3/Kconfig.defconfig index 2db7e0b54ae37b..864bd34d861c8f 100644 --- a/boards/arm/qemu_cortex_m3/Kconfig.defconfig +++ b/boards/arm/qemu_cortex_m3/Kconfig.defconfig @@ -12,4 +12,10 @@ config GPIO_STELLARIS default y depends on GPIO +# DWT is not properly emulated in QEMU +choice CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION + bool + default CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE +endchoice + endif # BOARD_QEMU_CORTEX_M3 diff --git a/tests/kernel/gen_isr_table/testcase.yaml b/tests/kernel/gen_isr_table/testcase.yaml index 71912d0fb80005..52ee3db7837fd6 100644 --- a/tests/kernel/gen_isr_table/testcase.yaml +++ b/tests/kernel/gen_isr_table/testcase.yaml @@ -1,18 +1,25 @@ tests: arch.interrupt.gen_isr_table.arm_baseline: + arch_allow: arm platform_allow: bbc_microbit atsamr21_xpro nrf51dk_nrf51422 nucleo_g071rb qemu_cortex_m0 filter: CONFIG_GEN_ISR_TABLES and CONFIG_ARMV6_M_ARMV8_M_BASELINE tags: interrupt isr_table + extra_configs: + - CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y arch.interrupt.gen_isr_table.arm_mainline: + arch_allow: arm platform_exclude: stmf103_mini nucleo_f103rb olimexino_stm32 stm32_min_dev_black stm32_min_dev_blue usb_kw24d512 v2m_beetle cc1352r1_launchxl cc26x2r1_launchxl olimex_stm32_h103 cc1352r_sensortag filter: CONFIG_GEN_ISR_TABLES and CONFIG_ARMV7_M_ARMV8_M_MAINLINE tags: interrupt isr_table + extra_configs: + - CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y arch.interrupt.gen_isr_table.disabled: arch_allow: arm extra_configs: - CONFIG_GEN_ISR_TABLES=n + - CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_DETECTION_NONE=y tags: interrupt isr_table build_only: true arch.interrupt.gen_isr_table.arc: