Skip to content

Commit de56379

Browse files
b49020willdeacon
authored andcommitted
arm64: ftrace: use function_nocfi for _mcount as well
Commit 800618f ("arm64: ftrace: use function_nocfi for ftrace_call") only fixed address of ftrace_call but address of _mcount needs to be fixed as well. Use function_nocfi() to get the actual address of _mcount function as with CONFIG_CFI_CLANG, the compiler replaces function pointers with jump table addresses which breaks dynamic ftrace as the address of _mcount is replaced with the address of _mcount.cfi_jt. With mainline, this won't be a problem since by default CONFIG_DYNAMIC_FTRACE_WITH_REGS=y with Clang >= 10 as it supports -fpatchable-function-entry and CFI requires Clang 12 but for consistency we should add function_nocfi() for _mcount as well. Signed-off-by: Sumit Garg <[email protected]> Acked-by: Mark Rutland <[email protected]> Reviewed-by: Sami Tolvanen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 1dfde08 commit de56379

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

arch/arm64/include/asm/ftrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
1616
#define ARCH_SUPPORTS_FTRACE_OPS 1
1717
#else
18-
#define MCOUNT_ADDR ((unsigned long)_mcount)
18+
#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount))
1919
#endif
2020

2121
/* The BL at the callsite's adjusted rec->ip */

0 commit comments

Comments
 (0)