提交 35dace6e 编写于 作者: N Naveen N. Rao 提交者: Zheng Zengkai

powerpc/ftrace: Remove ftrace init tramp once kernel init is complete

stable inclusion
from stable-v5.10.128
commit 6a656280e775821f75c0b9ca599b10174210fbdb
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YM2H

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=6a656280e775821f75c0b9ca599b10174210fbdb

--------------------------------

commit 84ade0a6 upstream.

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

Fixes: 67361cf8 ("powerpc/ftrace: Handle large kernel configs")
Cc: stable@vger.kernel.org # v4.20+
Signed-off-by: NNaveen N. Rao <naveen.n.rao@linux.vnet.ibm.com>
Signed-off-by: NMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20220516071422.463738-1-naveen.n.rao@linux.vnet.ibm.comSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Reviewed-by: NWei Li <liwei391@huawei.com>
上级 b6662d3e
...@@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name ...@@ -96,7 +96,7 @@ static inline bool arch_syscall_match_sym_name(const char *sym, const char *name
#endif /* PPC64_ELF_ABI_v1 */ #endif /* PPC64_ELF_ABI_v1 */
#endif /* CONFIG_FTRACE_SYSCALLS */ #endif /* CONFIG_FTRACE_SYSCALLS */
#ifdef CONFIG_PPC64 #if defined(CONFIG_PPC64) && defined(CONFIG_FUNCTION_TRACER)
#include <asm/paca.h> #include <asm/paca.h>
static inline void this_cpu_disable_ftrace(void) static inline void this_cpu_disable_ftrace(void)
...@@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void) ...@@ -120,11 +120,13 @@ static inline u8 this_cpu_get_ftrace_enabled(void)
return get_paca()->ftrace_enabled; return get_paca()->ftrace_enabled;
} }
void ftrace_free_init_tramp(void);
#else /* CONFIG_PPC64 */ #else /* CONFIG_PPC64 */
static inline void this_cpu_disable_ftrace(void) { } static inline void this_cpu_disable_ftrace(void) { }
static inline void this_cpu_enable_ftrace(void) { } static inline void this_cpu_enable_ftrace(void) { }
static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { } static inline void this_cpu_set_ftrace_enabled(u8 ftrace_enabled) { }
static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; } static inline u8 this_cpu_get_ftrace_enabled(void) { return 1; }
static inline void ftrace_free_init_tramp(void) { }
#endif /* CONFIG_PPC64 */ #endif /* CONFIG_PPC64 */
#endif /* !__ASSEMBLY__ */ #endif /* !__ASSEMBLY__ */
......
...@@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp) ...@@ -336,9 +336,7 @@ static int setup_mcount_compiler_tramp(unsigned long tramp)
/* Is this a known long jump tramp? */ /* Is this a known long jump tramp? */
for (i = 0; i < NUM_FTRACE_TRAMPS; i++) for (i = 0; i < NUM_FTRACE_TRAMPS; i++)
if (!ftrace_tramps[i]) if (ftrace_tramps[i] == tramp)
break;
else if (ftrace_tramps[i] == tramp)
return 0; return 0;
/* Is this a known plt tramp? */ /* Is this a known plt tramp? */
...@@ -882,6 +880,17 @@ void arch_ftrace_update_code(int command) ...@@ -882,6 +880,17 @@ void arch_ftrace_update_code(int command)
extern unsigned int ftrace_tramp_text[], ftrace_tramp_init[]; 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 __init ftrace_dyn_arch_init(void)
{ {
int i; int i;
......
...@@ -51,6 +51,7 @@ ...@@ -51,6 +51,7 @@
#include <asm/kasan.h> #include <asm/kasan.h>
#include <asm/svm.h> #include <asm/svm.h>
#include <asm/mmzone.h> #include <asm/mmzone.h>
#include <asm/ftrace.h>
#include <mm/mmu_decl.h> #include <mm/mmu_decl.h>
...@@ -347,6 +348,7 @@ void free_initmem(void) ...@@ -347,6 +348,7 @@ void free_initmem(void)
mark_initmem_nx(); mark_initmem_nx();
init_mem_is_free = true; init_mem_is_free = true;
free_initmem_default(POISON_FREE_INITMEM); free_initmem_default(POISON_FREE_INITMEM);
ftrace_free_init_tramp();
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册