x86/ftrace: enable dynamic ftrace without CONFIG_MODULES
authorMike Rapoport (IBM) <rppt@kernel.org>
Sun, 5 May 2024 16:06:25 +0000 (19:06 +0300)
committerLuis Chamberlain <mcgrof@kernel.org>
Tue, 14 May 2024 07:31:44 +0000 (00:31 -0700)
Dynamic ftrace must allocate memory for code and this was impossible
without CONFIG_MODULES.

With execmem separated from the modules code, execmem_text_alloc() is
available regardless of CONFIG_MODULES.

Remove dependency of dynamic ftrace on CONFIG_MODULES and make
CONFIG_DYNAMIC_FTRACE select CONFIG_EXECMEM in Kconfig.

Signed-off-by: Mike Rapoport (IBM) <rppt@kernel.org>
Reviewed-by: Steven Rostedt (Google) <rostedt@goodmis.org>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
arch/x86/Kconfig
arch/x86/kernel/ftrace.c

index fe196f49d27828a314b4438a3ef99c4c4d480991..965d65edbae04719cdccf5d873a70beb9a60c4b9 100644 (file)
@@ -34,6 +34,7 @@ config X86_64
        select SWIOTLB
        select ARCH_HAS_ELFCORE_COMPAT
        select ZONE_DMA32
+       select EXECMEM if DYNAMIC_FTRACE
 
 config FORCE_DYNAMIC_FTRACE
        def_bool y
index c8ddb7abda7cf862edbd185c8b89eb10eaf4ef57..8da0e66ca22dec8d8076ce0a4377f3cfc50b3619 100644 (file)
@@ -261,8 +261,6 @@ void arch_ftrace_update_code(int command)
 /* Currently only x86_64 supports dynamic trampolines */
 #ifdef CONFIG_X86_64
 
-#ifdef CONFIG_MODULES
-/* Module allocation simplifies allocating memory for code */
 static inline void *alloc_tramp(unsigned long size)
 {
        return execmem_alloc(EXECMEM_FTRACE, size);
@@ -271,14 +269,6 @@ static inline void tramp_free(void *tramp)
 {
        execmem_free(tramp);
 }
-#else
-/* Trampolines can only be created if modules are supported */
-static inline void *alloc_tramp(unsigned long size)
-{
-       return NULL;
-}
-static inline void tramp_free(void *tramp) { }
-#endif
 
 /* Defined as markers to the end of the ftrace default trampolines */
 extern void ftrace_regs_caller_end(void);