]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
powerpc/ftrace: Remove ftrace init tramp once kernel init is complete
authorNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Mon, 16 May 2022 07:14:22 +0000 (12:44 +0530)
committerStefan Bader <stefan.bader@canonical.com>
Fri, 26 Aug 2022 08:54:05 +0000 (10:54 +0200)
BugLink: https://bugs.launchpad.net/bugs/1986724
commit 84ade0a6655bee803d176525ef457175cbf4df22 upstream.

Stop using the ftrace trampoline for init section once kernel init is
complete.

Fixes: 67361cf8071286 ("powerpc/ftrace: Handle large kernel configs")
Cc: stable@vger.kernel.org # v4.20+
Signed-off-by: Naveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n.rao@linux.vnet.ibm.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
arch/powerpc/include/asm/ftrace.h
arch/powerpc/kernel/trace/ftrace.c
arch/powerpc/mm/mem.c

index debe8c4f7062608ed43320ec16ae41251031ea6a..02d32d6422cd8b6141075165b28a99792919432c 100644 (file)
@@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
 #endif /* PPC64_ELF_ABI_v1 */
 #endif /* CONFIG_FTRACE_SYSCALLS */
 
-#ifdef CONFIG_PPC64
+#if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
 #include <asm/paca.h>
 
 static inline void this_cpu_disable_ftrace(void)
@@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void)
        return get_paca()->ftrace_enabled;
 }
 
+void ftrace_free_init_tramp(void);
 #else /* CONFIG_PPC64 */
 static inline void this_cpu_disable_ftrace(void) { }
 static inline void this_cpu_enable_ftrace(void) { }
 static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
 static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
+static inline void ftrace_free_init_tramp(void) { }
 #endif /* CONFIG_PPC64 */
 #endif /* !__ASSEMBLY__ */
 
index d89c5df4f20620c5911b5c224e820ffb3ecb688c..660040c2d7b543c379b59493b39377d751bb4c63 100644 (file)
@@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
 
        /* Is this a known long jump tramp? */
        for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
-               if (!ftrace_tramps[i])
-                       break;
-               else if (ftrace_tramps[i] == tramp)
+               if (ftrace_tramps[i] == tramp)
                        return 0;
 
        /* Is this a known plt tramp? */
@@ -881,6 +879,17 @@ void arch_ftrace_update_code(int command)
 
 extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[];
 
+void ftrace_free_init_tramp(void)
+{
+       int i;
+
+       for (i = 0; i < NUM_FTRACE_TRAMPS && ftrace_tramps[i]; i++)
+               if (ftrace_tramps[i] == (unsigned long)ftrace_tramp_init) {
+                       ftrace_tramps[i] = 0;
+                       return;
+               }
+}
+
 int __init ftrace_dyn_arch_init(void)
 {
        int i;
index 05b9c3f31456c6f32c064ded4a1a491b9e971f2d..543a044560e93511e2d796b978faeac69dbce931 100644 (file)
@@ -22,6 +22,7 @@
 #include <asm/kasan.h>
 #include <asm/svm.h>
 #include <asm/mmzone.h>
+#include <asm/ftrace.h>
 
 #include <mm/mmu_decl.h>
 
@@ -314,6 +315,7 @@ void free_initmem(void)
        mark_initmem_nx();
        init_mem_is_free = true;
        free_initmem_default(POISON_FREE_INITMEM);
+       ftrace_free_init_tramp();
 }
 
 /*