* [PATCH v3] arm64: ftrace: use function_nocfi for _mcount as well
@ 2021-10-11 12:50 Sumit Garg
2021-10-12 8:46 ` Will Deacon
0 siblings, 1 reply; 2+ messages in thread
From: Sumit Garg @ 2021-10-11 12:50 UTC (permalink / raw)
To: will, catalin.marinas
Cc: linux-arm-kernel, rostedt, mingo, samitolvanen, ben.dai,
mark.rutland, nathan, keescook, ndesaulniers, daniel.thompson,
linux-kernel, llvm, Sumit Garg
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.
Signed-off-by: Sumit Garg <sumit.garg@linaro.org>
Acked-by: Mark Rutland <mark.rutland@arm.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
---
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(-)
diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
index 91fa4baa1a93..347b0cc68f07 100644
--- a/arch/arm64/include/asm/ftrace.h
+++ b/arch/arm64/include/asm/ftrace.h
@@ -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 */
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH v3] arm64: ftrace: use function_nocfi for _mcount as well
2021-10-11 12:50 [PATCH v3] arm64: ftrace: use function_nocfi for _mcount as well Sumit Garg
@ 2021-10-12 8:46 ` Will Deacon
0 siblings, 0 replies; 2+ messages in thread
From: Will Deacon @ 2021-10-12 8:46 UTC (permalink / raw)
To: catalin.marinas, Sumit Garg
Cc: kernel-team, Will Deacon, linux-kernel, llvm, samitolvanen,
mingo, rostedt, daniel.thompson, ndesaulniers, ben.dai, nathan,
keescook, mark.rutland, linux-arm-kernel
On Mon, 11 Oct 2021 18:20:59 +0530, Sumit Garg wrote:
> 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.
>
> [...]
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,
--
Will
https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-10-12 8:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-11 12:50 [PATCH v3] arm64: ftrace: use function_nocfi for _mcount as well Sumit Garg
2021-10-12 8:46 ` Will Deacon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).