From 9bafb37470d34ece89c1ba7ad4b7a170736dad6f Mon Sep 17 00:00:00 2001 From: Ben Dai Date: Wed, 31 Mar 2021 09:29:17 +0800 Subject: [PATCH] ANDROID: arm64: Fix the address of ftrace_call compiled with CFI_CLANG When CONFIG_CFI_CLANG and CONFIG_DYNAMIC_FTRACE are enabled, LLVM will generate a jump function named ftrace_call.cfi_jt for ftrace_call, which makes "&ftrace_call" in ftrace_update_ftrace_func() actually the address of ftrace_call.cfi_jt. As a result, the tracer can't be really enabled through runtime modification. Use __va_function() to get the actual address of ftrace_call to fix the issue. Bug: 184105181 Signed-off-by: Ben Dai Change-Id: Ic9272cd4ab447b3b145d8e397e5c9010c49f7a12 --- arch/arm64/kernel/ftrace.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/kernel/ftrace.c b/arch/arm64/kernel/ftrace.c index 4254d7808def..95120aea9c76 100644 --- a/arch/arm64/kernel/ftrace.c +++ b/arch/arm64/kernel/ftrace.c @@ -58,7 +58,7 @@ int ftrace_update_ftrace_func(ftrace_func_t func) unsigned long pc; u32 new; - pc = (unsigned long)&ftrace_call; + pc = (unsigned long)__va_function(ftrace_call); new = aarch64_insn_gen_branch_imm(pc, (unsigned long)func, AARCH64_INSN_BRANCH_LINK);