tracing: move function tracer options to Kconfig
Move function tracer options to Kconfig to make it easier to add new methods for generating __mcount_loc, and to make the options available also when building kernel modules. Note that FTRACE_MCOUNT_USE_* options are updated on rebuild and therefore, work even if the .config was generated in a different environment. Signed-off-by: Sami Tolvanen <samitolvanen@google.com> Acked-by: Steven Rostedt (VMware) <rostedt@goodmis.org> Signed-off-by: Kees Cook <keescook@chromium.org> Link: https://lore.kernel.org/r/20201211184633.3213045-2-samitolvanen@google.com
This commit is contained in:
parent
e71ba9452f
commit
3b15cdc159
3 changed files with 26 additions and 16 deletions
18
Makefile
18
Makefile
|
@ -851,12 +851,8 @@ KBUILD_CFLAGS += $(DEBUG_CFLAGS)
|
||||||
export DEBUG_CFLAGS
|
export DEBUG_CFLAGS
|
||||||
|
|
||||||
ifdef CONFIG_FUNCTION_TRACER
|
ifdef CONFIG_FUNCTION_TRACER
|
||||||
ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
ifdef CONFIG_FTRACE_MCOUNT_USE_CC
|
||||||
# gcc 5 supports generating the mcount tables directly
|
|
||||||
ifeq ($(call cc-option-yn,-mrecord-mcount),y)
|
|
||||||
CC_FLAGS_FTRACE += -mrecord-mcount
|
CC_FLAGS_FTRACE += -mrecord-mcount
|
||||||
export CC_USING_RECORD_MCOUNT := 1
|
|
||||||
endif
|
|
||||||
ifdef CONFIG_HAVE_NOP_MCOUNT
|
ifdef CONFIG_HAVE_NOP_MCOUNT
|
||||||
ifeq ($(call cc-option-yn, -mnop-mcount),y)
|
ifeq ($(call cc-option-yn, -mnop-mcount),y)
|
||||||
CC_FLAGS_FTRACE += -mnop-mcount
|
CC_FLAGS_FTRACE += -mnop-mcount
|
||||||
|
@ -864,6 +860,12 @@ ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||||
|
ifdef CONFIG_HAVE_C_RECORDMCOUNT
|
||||||
|
BUILD_C_RECORDMCOUNT := y
|
||||||
|
export BUILD_C_RECORDMCOUNT
|
||||||
|
endif
|
||||||
|
endif
|
||||||
ifdef CONFIG_HAVE_FENTRY
|
ifdef CONFIG_HAVE_FENTRY
|
||||||
ifeq ($(call cc-option-yn, -mfentry),y)
|
ifeq ($(call cc-option-yn, -mfentry),y)
|
||||||
CC_FLAGS_FTRACE += -mfentry
|
CC_FLAGS_FTRACE += -mfentry
|
||||||
|
@ -873,12 +875,6 @@ endif
|
||||||
export CC_FLAGS_FTRACE
|
export CC_FLAGS_FTRACE
|
||||||
KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
|
KBUILD_CFLAGS += $(CC_FLAGS_FTRACE) $(CC_FLAGS_USING)
|
||||||
KBUILD_AFLAGS += $(CC_FLAGS_USING)
|
KBUILD_AFLAGS += $(CC_FLAGS_USING)
|
||||||
ifdef CONFIG_DYNAMIC_FTRACE
|
|
||||||
ifdef CONFIG_HAVE_C_RECORDMCOUNT
|
|
||||||
BUILD_C_RECORDMCOUNT := y
|
|
||||||
export BUILD_C_RECORDMCOUNT
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
# We trigger additional mismatches with less inlining
|
# We trigger additional mismatches with less inlining
|
||||||
|
|
|
@ -602,6 +602,22 @@ config FTRACE_MCOUNT_RECORD
|
||||||
depends on DYNAMIC_FTRACE
|
depends on DYNAMIC_FTRACE
|
||||||
depends on HAVE_FTRACE_MCOUNT_RECORD
|
depends on HAVE_FTRACE_MCOUNT_RECORD
|
||||||
|
|
||||||
|
config FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
|
||||||
|
bool
|
||||||
|
depends on FTRACE_MCOUNT_RECORD
|
||||||
|
|
||||||
|
config FTRACE_MCOUNT_USE_CC
|
||||||
|
def_bool y
|
||||||
|
depends on $(cc-option,-mrecord-mcount)
|
||||||
|
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
|
||||||
|
depends on FTRACE_MCOUNT_RECORD
|
||||||
|
|
||||||
|
config FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||||
|
def_bool y
|
||||||
|
depends on !FTRACE_MCOUNT_USE_PATCHABLE_FUNCTION_ENTRY
|
||||||
|
depends on !FTRACE_MCOUNT_USE_CC
|
||||||
|
depends on FTRACE_MCOUNT_RECORD
|
||||||
|
|
||||||
config TRACING_MAP
|
config TRACING_MAP
|
||||||
bool
|
bool
|
||||||
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
|
depends on ARCH_HAVE_NMI_SAFE_CMPXCHG
|
||||||
|
|
|
@ -178,8 +178,7 @@ cmd_modversions_c = \
|
||||||
fi
|
fi
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifdef CONFIG_FTRACE_MCOUNT_RECORD
|
ifdef CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||||
ifndef CC_USING_RECORD_MCOUNT
|
|
||||||
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
|
# compiler will not generate __mcount_loc use recordmcount or recordmcount.pl
|
||||||
ifdef BUILD_C_RECORDMCOUNT
|
ifdef BUILD_C_RECORDMCOUNT
|
||||||
ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
|
ifeq ("$(origin RECORDMCOUNT_WARN)", "command line")
|
||||||
|
@ -206,8 +205,7 @@ recordmcount_source := $(srctree)/scripts/recordmcount.pl
|
||||||
endif # BUILD_C_RECORDMCOUNT
|
endif # BUILD_C_RECORDMCOUNT
|
||||||
cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \
|
cmd_record_mcount = $(if $(findstring $(strip $(CC_FLAGS_FTRACE)),$(_c_flags)), \
|
||||||
$(sub_cmd_record_mcount))
|
$(sub_cmd_record_mcount))
|
||||||
endif # CC_USING_RECORD_MCOUNT
|
endif # CONFIG_FTRACE_MCOUNT_USE_RECORDMCOUNT
|
||||||
endif # CONFIG_FTRACE_MCOUNT_RECORD
|
|
||||||
|
|
||||||
ifdef CONFIG_STACK_VALIDATION
|
ifdef CONFIG_STACK_VALIDATION
|
||||||
ifneq ($(SKIP_STACK_VALIDATION),1)
|
ifneq ($(SKIP_STACK_VALIDATION),1)
|
||||||
|
|
Loading…
Add table
Reference in a new issue