Skip to contentSkip to conversation

riscv/ftrace: Set FTRACE_FORCE_LIST_FUNC if DYNAMIC_FTRACE_WITH_REGS is not set

PATCH New Liao Chang 1 participant 1 message Sep 16, 2022

Subsystems (2)
lore
Share & tools
lore

Liao Chang

author
#0 lore raw

PATCH 1/1 riscv/ftrace: Set FTRACE_FORCE_LIST_FUNC if DYNAMIC_FTRACE_WITH_REGS is not set

With the following configuration options:

CONFIG_FUNCTION_TRACER=y
CONFIG_DYNAMIC_FTRACE is not set
CONFIG_DYNAMIC_FTRACE_WITH_REGS is not set

Setting function tracer leads to Linux being stuck:

echo function > /sys/kernel/tracing/current_tracer

The reason is: for static tracing, RISC-V mcount only support passing up ip and parent_ip, if it does not force list func, some C side effects occurs, where a function is called without passing a valid third parameter, then kernel will trap into page fault when jump from mcount to function_trace_call().

Fix this stuck issue by force kernel to use indirect list trace function, when CONFIG_DYNAMIC_FTRACE_WITH_REGS is not set.

Fixes 71e736a7d655 ("riscv/ftrace: Add ARCH_SUPPORTS_FTRACE_OPS support")
---
 arch/riscv/include/asm/ftrace.h | 3 +++
 1 file changed, 3 insertions(+)
arch/riscv/include/asm/ftrace.h +3 -0
index 04dad3380041..a9d365e46b52 100644
@@ -23,7 +23,10 @@
 #define MCOUNT_NAME mcount
 #endif
 
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
 #define ARCH_SUPPORTS_FTRACE_OPS 1
+#endif
+
 #ifndef __ASSEMBLY__
 void MCOUNT_NAME(void);
 static inline unsigned long ftrace_call_adjust(unsigned long addr)
Signature · 1 line
2.17.1