Skip to content

Commit 1f2aaed

Browse files
rnavmpe
authored andcommitted
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 <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/7d9c316adfa1fb787ad268bb4691e7e4059ff2d5.1587488954.git.naveen.n.rao@linux.vnet.ibm.com
1 parent 03b5141 commit 1f2aaed

File tree

1 file changed

+4
-14
lines changed

1 file changed

+4
-14
lines changed

arch/powerpc/kernel/module_64.c

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -400,19 +400,9 @@ static unsigned long stub_for_addr(const Elf64_Shdr *sechdrs,
400400
}
401401

402402
#ifdef CONFIG_MPROFILE_KERNEL
403-
static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
403+
static bool is_mprofile_ftrace_call(const char *name)
404404
{
405-
if (strcmp("_mcount", name))
406-
return false;
407-
408-
/*
409-
* Check if this is one of the -mprofile-kernel sequences.
410-
*/
411-
if (instruction[-1] == PPC_INST_STD_LR &&
412-
instruction[-2] == PPC_INST_MFLR)
413-
return true;
414-
415-
if (instruction[-1] == PPC_INST_MFLR)
405+
if (!strcmp("_mcount", name))
416406
return true;
417407

418408
return false;
@@ -436,7 +426,7 @@ static void squash_toc_save_inst(const char *name, unsigned long addr)
436426
#else
437427
static void squash_toc_save_inst(const char *name, unsigned long addr) { }
438428

439-
static bool is_mprofile_mcount_callsite(const char *name, u32 *instruction)
429+
static bool is_mprofile_ftrace_call(const char *name)
440430
{
441431
return false;
442432
}
@@ -448,7 +438,7 @@ static int restore_r2(const char *name, u32 *instruction, struct module *me)
448438
{
449439
u32 *prev_insn = instruction - 1;
450440

451-
if (is_mprofile_mcount_callsite(name, prev_insn))
441+
if (is_mprofile_ftrace_call(name))
452442
return 1;
453443

454444
/*

0 commit comments

Comments
 (0)