arm: cortex-m: shrink hidden option for null-pointer detection

Shrink the name of the hidden cortex-m option for the
null-pointer dereference detection feature.

Signed-off-by: Ioannis Glaropoulos <Ioannis.Glaropoulos@nordicsemi.no>
This commit is contained in:
Ioannis Glaropoulos 2021-05-26 16:26:36 +02:00 committed by Kumar Gala
commit b3b36f69a6
5 changed files with 22 additions and 22 deletions

View file

@ -352,7 +352,7 @@ config NULL_POINTER_EXCEPTION_DETECTION_DWT
depends on CPU_CORTEX_M_HAS_DWT depends on CPU_CORTEX_M_HAS_DWT
depends on !TRUSTED_EXECUTION_NONSECURE depends on !TRUSTED_EXECUTION_NONSECURE
select CORTEX_M_DWT select CORTEX_M_DWT
select CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION select CORTEX_M_NULL_POINTER_EXCEPTION
help help
Null pointer dereference detection implemented Null pointer dereference detection implemented
using the DWT unit functionality. using the DWT unit functionality.
@ -369,7 +369,7 @@ config NULL_POINTER_EXCEPTION_DETECTION_MPU
bool "Use MPU for null pointer exception detection" bool "Use MPU for null pointer exception detection"
depends on !TRUSTED_EXECUTION_NONSECURE depends on !TRUSTED_EXECUTION_NONSECURE
depends on ARM_MPU depends on ARM_MPU
select CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION select CORTEX_M_NULL_POINTER_EXCEPTION
help help
Null pointer dereference detection implemented Null pointer dereference detection implemented
using MPU functionality. using MPU functionality.
@ -383,7 +383,7 @@ config NULL_POINTER_EXCEPTION_DETECTION_MPU
- In ARMv8-M, explicit null-pointer dereference - In ARMv8-M, explicit null-pointer dereference
detection with MPU requires, additionally, that detection with MPU requires, additionally, that
the area: [0x0, the area: [0x0,
CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE) CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE)
is not unmapped (covered by an MPU region already). is not unmapped (covered by an MPU region already).
If it is unmapped null-pointer dereferencing may If it is unmapped null-pointer dereferencing may
still be idirectly detected (e.g. via a precise still be idirectly detected (e.g. via a precise
@ -392,7 +392,7 @@ config NULL_POINTER_EXCEPTION_DETECTION_MPU
endchoice endchoice
config CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION config CORTEX_M_NULL_POINTER_EXCEPTION
bool bool
help help
Enable and use the null pointer exception option. Enable and use the null pointer exception option.
@ -400,15 +400,15 @@ config CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION
detecting null pointer dereferencing (raising a detecting null pointer dereferencing (raising a
CPU fault). Supporting the feature results in an CPU fault). Supporting the feature results in an
increased code footprint, determined by option increased code footprint, determined by option
CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE. CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE.
Note: this hidden option is selected by the choice Note: this hidden option is selected by the choice
symbols corresponding to the DWT-based or to the symbols corresponding to the DWT-based or to the
MPU-based solution. MPU-based solution.
if CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION if CORTEX_M_NULL_POINTER_EXCEPTION
config CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE config CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE
hex "Size of paged unmapped to implement null pointer detection" hex "Size of paged unmapped to implement null pointer detection"
default 0x400 default 0x400
help help
@ -417,7 +417,7 @@ config CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE
offers enhanced detection performance to the cost of offers enhanced detection performance to the cost of
wasting a large flash area that code may not use. wasting a large flash area that code may not use.
endif # CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION endif # CORTEX_M_NULL_POINTER_EXCEPTION
rsource "tz/Kconfig" rsource "tz/Kconfig"

View file

@ -53,8 +53,8 @@ bool z_arm_debug_monitor_event_error_check(void)
/* The area (0x0 - <size>) monitored by DWT needs to be a power of 2, /* The area (0x0 - <size>) monitored by DWT needs to be a power of 2,
* so we add a build assert that catches it. * so we add a build assert that catches it.
*/ */
BUILD_ASSERT(!(CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE & BUILD_ASSERT(!(CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE &
(CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1)), (CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1)),
"the size of the partition must be power of 2"); "the size of the partition must be power of 2");
static int z_arm_debug_enable_null_pointer_detection(const struct device *arg) static int z_arm_debug_enable_null_pointer_detection(const struct device *arg)
@ -79,7 +79,7 @@ static int z_arm_debug_enable_null_pointer_detection(const struct device *arg)
/* Use comparators 0, 1, R/W access check */ /* Use comparators 0, 1, R/W access check */
DWT->COMP0 = 0; DWT->COMP0 = 0;
DWT->COMP1 = CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1; DWT->COMP1 = CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1;
DWT->FUNCTION0 = DWT->FUNCTION0 =
((0x4 << DWT_FUNCTION_MATCH_Pos) & DWT_FUNCTION_MATCH_Msk) ((0x4 << DWT_FUNCTION_MATCH_Pos) & DWT_FUNCTION_MATCH_Msk)
@ -112,7 +112,7 @@ static int z_arm_debug_enable_null_pointer_detection(const struct device *arg)
/* Set mask according to the desired size */ /* Set mask according to the desired size */
DWT->MASK0 = 32 - __builtin_clzl( DWT->MASK0 = 32 - __builtin_clzl(
CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1); CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1);
#endif #endif
return 0; return 0;

View file

@ -16,6 +16,6 @@
* first stage vector table. * first stage vector table.
*/ */
#if defined(CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION) #if defined(CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION)
. = MAX(ABSOLUTE(.), CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE); . = MAX(ABSOLUTE(.), CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE);
#endif /* CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION */ #endif /* CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION */

View file

@ -355,12 +355,12 @@ int z_arm_mpu_init(void)
*/ */
#if defined(CONFIG_NULL_POINTER_EXCEPTION_DETECTION_MPU) #if defined(CONFIG_NULL_POINTER_EXCEPTION_DETECTION_MPU)
#if (defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE)) && \ #if (defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE)) && \
(CONFIG_FLASH_BASE_ADDRESS > CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE) (CONFIG_FLASH_BASE_ADDRESS > CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE)
#pragma message "Null-Pointer exception detection cannot be configured on un-mapped flash areas" #pragma message "Null-Pointer exception detection cannot be configured on un-mapped flash areas"
#else #else
const struct z_arm_mpu_partition unmap_region = { const struct z_arm_mpu_partition unmap_region = {
.start = 0x0, .start = 0x0,
.size = CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE, .size = CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE,
#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE)
/* Overlapping region (with any permissions) /* Overlapping region (with any permissions)
* will result in fault generation * will result in fault generation
@ -377,16 +377,16 @@ int z_arm_mpu_init(void)
* (size and alignment). * (size and alignment).
*/ */
_ARCH_MEM_PARTITION_ALIGN_CHECK(0x0, _ARCH_MEM_PARTITION_ALIGN_CHECK(0x0,
CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE); CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE);
#if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE) #if defined(CONFIG_ARMV8_M_BASELINE) || defined(CONFIG_ARMV8_M_MAINLINE)
/* ARMv8-M requires that the area: /* ARMv8-M requires that the area:
* 0x0 - CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE * 0x0 - CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE
* is not unmapped (belongs to a valid MPU region already). * is not unmapped (belongs to a valid MPU region already).
*/ */
if ((arm_cmse_mpu_region_get(0x0) == -EINVAL) || if ((arm_cmse_mpu_region_get(0x0) == -EINVAL) ||
(arm_cmse_mpu_region_get( (arm_cmse_mpu_region_get(
CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1) CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION_PAGE_SIZE - 1)
== -EINVAL)) { == -EINVAL)) {
__ASSERT(0, __ASSERT(0,
"Null pointer detection page unmapped\n"); "Null pointer detection page unmapped\n");

View file

@ -481,7 +481,7 @@ void test_arm_user_interrupt(void)
} }
#endif /* CONFIG_USERSPACE */ #endif /* CONFIG_USERSPACE */
#if defined(CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION) #if defined(CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION)
#pragma GCC push_options #pragma GCC push_options
#pragma GCC optimize("O0") #pragma GCC optimize("O0")
/* Avoid compiler optimizing null pointer de-referencing. */ /* Avoid compiler optimizing null pointer de-referencing. */
@ -511,7 +511,7 @@ void test_arm_null_pointer_exception(void)
TC_PRINT("Skipped\n"); TC_PRINT("Skipped\n");
} }
#endif /* CONFIG_CORTEX_M_DEBUG_NULL_POINTER_EXCEPTION */ #endif /* CONFIG_CORTEX_M_NULL_POINTER_EXCEPTION */
/** /**
* @} * @}