diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index 587f420b8a..5a40e0d11e 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -78,6 +78,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y) ARCHOPTIMIZATION += -fsanitize=kernel-address endif +ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-reads=0 +endif + +ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-writes=0 +endif + ifeq ($(CONFIG_UNWINDER_ARM),y) ARCHOPTIMIZATION += -funwind-tables -fasynchronous-unwind-tables endif diff --git a/arch/risc-v/src/common/Toolchain.defs b/arch/risc-v/src/common/Toolchain.defs index 95b1636b3a..892d69c31a 100644 --- a/arch/risc-v/src/common/Toolchain.defs +++ b/arch/risc-v/src/common/Toolchain.defs @@ -230,6 +230,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y) ARCHOPTIMIZATION += -fsanitize=kernel-address endif +ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-reads=0 +endif + +ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-writes=0 +endif + ifeq ($(CONFIG_MM_UBSAN_ALL),y) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) endif diff --git a/arch/xtensa/src/lx6/Toolchain.defs b/arch/xtensa/src/lx6/Toolchain.defs index bc8fa1b240..c68770234f 100644 --- a/arch/xtensa/src/lx6/Toolchain.defs +++ b/arch/xtensa/src/lx6/Toolchain.defs @@ -47,6 +47,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y) ARCHOPTIMIZATION += -fsanitize=kernel-address endif +ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-reads=0 +endif + +ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-writes=0 +endif + ifeq ($(CONFIG_MM_UBSAN_ALL),y) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) endif diff --git a/arch/xtensa/src/lx7/Toolchain.defs b/arch/xtensa/src/lx7/Toolchain.defs index 8f7101f7f4..a7f0ee98da 100644 --- a/arch/xtensa/src/lx7/Toolchain.defs +++ b/arch/xtensa/src/lx7/Toolchain.defs @@ -47,6 +47,14 @@ ifeq ($(CONFIG_MM_KASAN_ALL),y) ARCHOPTIMIZATION += -fsanitize=kernel-address endif +ifeq ($(CONFIG_MM_KASAN_DISABLE_READS_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-reads=0 +endif + +ifeq ($(CONFIG_MM_KASAN_DISABLE_WRITES_CHECK),y) + ARCHOPTIMIZATION += --param asan-instrument-writes=0 +endif + ifeq ($(CONFIG_MM_UBSAN_ALL),y) ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION) endif diff --git a/mm/Kconfig b/mm/Kconfig index c6859f21cb..a73a37ac57 100644 --- a/mm/Kconfig +++ b/mm/Kconfig @@ -265,6 +265,23 @@ config MM_KASAN_ALL to check. Enabling this option will get image size increased and performance decreased significantly. +config MM_KASAN_DISABLE_READS_CHECK + bool "Disable reads check" + depends on MM_KASAN + default n + ---help--- + This option disable kasan reads check. It speeds up performance + compared with default read/write check. Only disable it when you are + sure there's no need to do so. Or performance is too bad and only focus + on writes check. + +config MM_KASAN_DISABLE_WRITES_CHECK + bool "Disable writes check" + depends on MM_KASAN + default n + ---help--- + This option disable kasan writes check. + config MM_UBSAN bool "Undefined Behavior Sanitizer" default n