Skip to content

Commit

Permalink
arm: cortex_m: enable null-pointer exception detection in the tests
Browse files Browse the repository at this point in the history
Enable the null-pointer dereferencing detection by default
throughout the test-suite. Explicitly disable this for the
gen_isr_table test which needs to perform vector table reads.
Disable null-pointer exception detection on qemu_cortex_m3
board, as DWT it is not emulated by QEMU on this platform.
Additionally, disable null-pointer exception detection on
mps2_an521 (QEMU target), as DWT is not present and the MPU
based solution won't work, since the target does not have
the area 0x0 - 0x400 mapped, but the QEMU still permits
read access.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
  • Loading branch information
ioannisg authored and carlescufi committed Mar 3, 2021
1 parent d86d2c6 commit 1b22f6b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions arch/arm/core/aarch32/cortex_m/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions boards/arm/mps2_an521/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 6 additions & 0 deletions boards/arm/qemu_cortex_m3/Kconfig.defconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 7 additions & 0 deletions tests/kernel/gen_isr_table/testcase.yaml
Original file line number Diff line number Diff line change
@@ -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:
Expand Down

0 comments on commit 1b22f6b

Please sign in to comment.