From: Torsten Duwe <[email protected]> Test whether gcc supports -fpatchable-function-entry and use it to promote DYNAMIC_FTRACE to DYNAMIC_FTRACE_WITH_REGS. Amend support for the new object section that holds the locations (__patchable_function_entries) and define a proper "notrace" attribute to switch it off.
Signed-off-by: Torsten Duwe <[email protected]> --- arch/arm64/Kconfig | 2 ++ arch/arm64/Makefile | 5 +++++ kernel/module.c | 7 ++++++- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 3adcec05b1f6..663392d1eae2 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -144,6 +144,8 @@ config ARM64 select HAVE_DEBUG_KMEMLEAK select HAVE_DMA_CONTIGUOUS select HAVE_DYNAMIC_FTRACE + select HAVE_DYNAMIC_FTRACE_WITH_REGS \ + if $(cc-option,-fpatchable-function-entry=2) select HAVE_EFFICIENT_UNALIGNED_ACCESS select HAVE_FAST_GUP select HAVE_FTRACE_MCOUNT_RECORD diff --git a/arch/arm64/Makefile b/arch/arm64/Makefile index 61de992bbea3..e827ad0298ab 100644 --- a/arch/arm64/Makefile +++ b/arch/arm64/Makefile @@ -104,6 +104,11 @@ ifeq ($(CONFIG_ARM64_MODULE_PLTS),y) KBUILD_LDFLAGS_MODULE += -T $(srctree)/arch/arm64/kernel/module.lds endif +ifeq ($(CONFIG_DYNAMIC_FTRACE_WITH_REGS),y) + KBUILD_CPPFLAGS += -DCC_USING_PATCHABLE_FUNCTION_ENTRY + CC_FLAGS_FTRACE := -fpatchable-function-entry=2 +endif + # Default value head-y := arch/arm64/kernel/head.o diff --git a/kernel/module.c b/kernel/module.c index 5933395af9a0..0759f89adbd3 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -3136,7 +3136,12 @@ static int find_module_sections(struct module *mod, struct load_info *info) #endif #ifdef CONFIG_FTRACE_MCOUNT_RECORD /* sechdrs[0].sh_size is always zero */ - mod->ftrace_callsites = section_objs(info, "__mcount_loc", + mod->ftrace_callsites = section_objs(info, +#ifdef CC_USING_PATCHABLE_FUNCTION_ENTRY + "__patchable_function_entries", +#else + "__mcount_loc", +#endif sizeof(*mod->ftrace_callsites), &mod->num_ftrace_callsites); #endif -- 2.23.0.rc1

