diff --git a/arch/Kconfig b/arch/Kconfig index dd38c7b598c..ed6fb3e1c77 100644 --- a/arch/Kconfig +++ b/arch/Kconfig @@ -35,6 +35,21 @@ config XTENSA endchoice + +menu "General Architecture Options" + +config HW_STACK_PROTECTION + bool "Hardware Stack Protection" + depends on ARCH_HAS_STACK_PROTECTION + help + Select this option to enable hardware stack protection. + +endmenu + +config ARCH_HAS_STACK_PROTECTION + bool + + # # Hidden PM feature configs which are to be selected by # individual SoC. diff --git a/arch/arc/Kconfig b/arch/arc/Kconfig index 7ee9d273661..35e25c9150a 100644 --- a/arch/arc/Kconfig +++ b/arch/arc/Kconfig @@ -55,6 +55,7 @@ menu "ARCv2 Family Options" config CPU_ARCV2 bool + select ARCH_HAS_STACK_PROTECTION default y help This option signifies the use of a CPU of the ARCv2 family. @@ -104,10 +105,9 @@ config RGF_NUM_BANKS and restore general purpose registers. config ARC_STACK_CHECKING - bool "Enable Stack Checking" - depends on CPU_ARCV2 + bool + default y if HW_STACK_PROTECTION select THREAD_STACK_INFO - default n help ARCV2 has a special feature allowing to check stack overflows. This enables code that allows using this debug feature diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 46c464e8ca0..3ffe44e0c1f 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -13,18 +13,16 @@ choice source "arch/x86/soc/*/Kconfig.soc" endchoice -menu "x86 Options" +menu "X86 Architecture Options" depends on X86 config ARCH default "x86" - config ARCH_DEFCONFIG string default "arch/x86/defconfig" - source "arch/x86/core/Kconfig" # @@ -36,11 +34,13 @@ config CPU_ATOM bool select CMOV select CPU_HAS_FPU + select ARCH_HAS_STACK_PROTECTION if X86_MMU help This option signifies the use of a CPU from the Atom family. config CPU_MINUTEIA # Hidden + select ARCH_HAS_STACK_PROTECTION if X86_MMU bool help This option signifies the use of a CPU from the Minute IA family. @@ -80,11 +80,9 @@ config X86_MMU config X86_STACK_PROTECTION bool - default n - depends on X86_MMU + default y if HW_STACK_PROTECTION select SET_GDT select GDT_DYNAMIC - prompt "MMU-based stack overflow protection" help This option leverages the MMU to cause a system fatal error if the bounds of the current process stack are overflowed. This is done @@ -247,9 +245,7 @@ config CACHE_FLUSHING This links in the sys_cache_flush() function. A mechanism for flushing the cache must be selected as well. By default, that mechanism is discovered at runtime. -endmenu -menu "Board Capabilities" config PIC_DISABLE bool "Disable PIC" default n @@ -308,8 +304,6 @@ config X86_FIXED_IRQ_MAPPING endmenu - - source "arch/x86/soc/*/Kconfig" endmenu diff --git a/tests/kernel/fatal/prj-arc.conf b/tests/kernel/fatal/prj-arc.conf deleted file mode 100644 index 0ed7ef8429d..00000000000 --- a/tests/kernel/fatal/prj-arc.conf +++ /dev/null @@ -1 +0,0 @@ -CONFIG_ARC_STACK_CHECKING=y diff --git a/tests/kernel/fatal/prj-x86-mmu.conf b/tests/kernel/fatal/prj-x86-mmu.conf deleted file mode 100644 index 2bdf1ff4717..00000000000 --- a/tests/kernel/fatal/prj-x86-mmu.conf +++ /dev/null @@ -1,3 +0,0 @@ -CONFIG_X86_MMU=y -CONFIG_X86_STACK_PROTECTION=y - diff --git a/tests/kernel/fatal/prj.conf b/tests/kernel/fatal/prj.conf index 3c5ffb4ec28..9b29bffe594 100644 --- a/tests/kernel/fatal/prj.conf +++ b/tests/kernel/fatal/prj.conf @@ -1,3 +1,2 @@ -CONFIG_STACK_SENTINEL=y -CONFIG_X86_STACK_PROTECTION=n +CONFIG_HW_STACK_PROTECTION=y diff --git a/tests/kernel/fatal/sentinel.conf b/tests/kernel/fatal/sentinel.conf new file mode 100644 index 00000000000..dd3fa86e31c --- /dev/null +++ b/tests/kernel/fatal/sentinel.conf @@ -0,0 +1,3 @@ +CONFIG_STACK_SENTINEL=y +CONFIG_HW_STACK_PROTECTION=n + diff --git a/tests/kernel/fatal/testcase.yaml b/tests/kernel/fatal/testcase.yaml index c8a0b002e27..f6e39ed29cf 100644 --- a/tests/kernel/fatal/testcase.yaml +++ b/tests/kernel/fatal/testcase.yaml @@ -2,12 +2,8 @@ tests: - stack-sentinel: arch_exclude: arc tags: core ignore_faults -- arc-stack-checking: - arch_whitelist: arc - extra_args: CONF_FILE=prj-arc.conf + extra_args: CONF_FILE=sentinel.conf +- stack-protection: + extra_args: CONF_FILE=prj.conf tags: core ignore_faults -- x86-mmu-stack-checking: - platform_whitelist: qemu_x86 qemu_x86_iamcu - extra_args: CONF_FILE=prj-x86-mmu.conf - tags: core ignore_faults - + filter: ARCH_HAS_STACK_PROTECTION