arm64: ftrace: use function_nocfi for _mcount as well
PATCH v3 1/1 arm64: ftrace: use function_nocfi for _mcount as well
Commit 800618f955a9 ("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.
---
Changes in v3:
- Droped fixes tag as it isn't critical.
- Modified commit description in order to make this change for consistency.
- Picked up Sami's review tag.
Changes in v2:
- Added fixes tag.
- Extended commit description.
- Picked up Mark's ack.
arch/arm64/include/asm/ftrace.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/arm64/include/asm/ftrace.h +1 -1
@@ -15,7 +15,7 @@#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS #define ARCH_SUPPORTS_FTRACE_OPS 1#else -#define MCOUNT_ADDR ((unsigned long)_mcount) +#define MCOUNT_ADDR ((unsigned long)function_nocfi(_mcount))#endif /* The BL at the callsite's adjusted rec->ip */
Signature · 1 line
2.17.1
Quoted 8 lines · Sumit Garg
Commit
800618f955a9("arm64: ftrace: usefunction_nocfiforftrace_call") only fixed address offtrace_callbut address of_mcountneeds to be fixed as well. Usefunction_nocfi()to get the actual address of_mcountfunction as withCONFIG_CFI_CLANG, the compiler replaces function pointers with jump table addresses which breaks dynamic ftrace as the address of_mcountis replaced with the address of _mcount.cfi_jt.[...]
Applied to arm64 (for-next/misc), thanks!
[1/1] arm64: ftrace: use function_nocfi for _mcount as well
https://git.kernel.org/arm64/c/de56379f21c7
Cheers,
Signature · 5 lines
Will https://fixes.arm64.dev https://next.arm64.dev https://will.arm64.dev