From: Naveen N. Rao Date: Tue, 21 Apr 2020 17:35:44 +0000 (+0530) Subject: powerpc/module_64: Simplify check for -mprofile-kernel ftrace relocations X-Git-Tag: v5.8-rc1~132^2~15 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=1f2aaed2db03150428dbcd2ddee02ae6cb4bac52;p=thirdparty%2Fkernel%2Flinux.git powerpc/module_64: Simplify check for -mprofile-kernel ftrace relocations For -mprofile-kernel, we need special handling when generating stubs for ftrace calls such as _mcount(). To faciliate this, we check if a R_PPC64_REL24 relocation is for a symbol named "_mcount()" along with also checking the instruction sequence. The latter is not really required since "_mcount()" is an exported symbol and kernel modules cannot use it. As such, drop the additional checking and simplify the code. This helps unify stub creation for ftrace stubs with -mprofile-kernel and aids in code reuse. Also rename is_mprofile_mcount_callsite() to is_mprofile_ftrace_call() to reflect the checking being done. Signed-off-by: Naveen N. Rao Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/7d9c316adfa1fb787ad268bb4691e7e4059ff2d5.1587488954.git.naveen.n.rao@linux.vnet.ibm.com --- diff --git a/arch/powerpc/kernel/module_64.c b/arch/powerpc/kernel/module_64.c index 0acec12d09854..de317c158f382 100644 --- a/arch/powerpc/kernel/module_64.c +++ b/arch/powerpc/kernel/module_64.c @@ -400,19 +400,9 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs, } #ifdef CONFIG_MPROFILE_KERNEL -static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction) +static bool is_mprofile_ftrace_call(const char *name) { - if (strcmp("_mcount", name)) - return false; - - /* - * Check if this is one of the -mprofile-kernel sequences. - */ - if (instruction[-1] == PPC_INST_STD_LR && - instruction[-2] == PPC_INST_MFLR) - return true; - - if (instruction[-1] == PPC_INST_MFLR) + if (!strcmp("_mcount", name)) return true; return false; @@ -436,7 +426,7 @@ static void squash_toc_save_inst(const char *name, unsigned long addr) #else static void squash_toc_save_inst(const char *name, unsigned long addr) { } -static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction) +static bool is_mprofile_ftrace_call(const char *name) { return false; } @@ -448,7 +438,7 @@ static int restore_r2(const char *name, u32 *instruction, struct module *me) { u32 *prev_insn = instruction - 1; - if (is_mprofile_mcount_callsite(name, prev_insn)) + if (is_mprofile_ftrace_call(name)) return 1; /*