1 /* SPDX-License-Identifier: GPL-2.0 */
2 /* Copyright (C) 2017 Andes Technology Corporation */
4 #include <linux/init.h>
5 #include <linux/linkage.h>
8 #include <asm/unistd.h>
9 #include <asm/thread_info.h>
10 #include <asm/asm-offsets.h>
11 #include <asm-generic/export.h>
12 #include <asm/ftrace.h>
16 #define FENTRY_RA_OFFSET 8
17 #define ABI_SIZE_ON_STACK 80
30 addi sp, sp, -ABI_SIZE_ON_STACK
56 addi sp, sp, ABI_SIZE_ON_STACK
59 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
61 addi sp, sp, -PT_SIZE_ON_STACK
77 /* Restore t0 with PT_EPC */
79 restore_from_x6_to_x31
81 addi sp, sp, PT_SIZE_ON_STACK
83 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */
85 SYM_FUNC_START(ftrace_caller)
88 addi a0, t0, -FENTRY_RA_OFFSET
89 la a1, function_trace_op
94 SYM_INNER_LABEL(ftrace_call, SYM_L_GLOBAL)
97 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
100 addi a1, a1, -FENTRY_RA_OFFSET
101 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
104 SYM_INNER_LABEL(ftrace_graph_call, SYM_L_GLOBAL)
109 SYM_FUNC_END(ftrace_caller)
111 #ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
112 SYM_FUNC_START(ftrace_regs_caller)
115 addi a0, t0, -FENTRY_RA_OFFSET
116 la a1, function_trace_op
121 SYM_INNER_LABEL(ftrace_regs_call, SYM_L_GLOBAL)
124 #ifdef CONFIG_FUNCTION_GRAPH_TRACER
127 addi a1, a1, -FENTRY_RA_OFFSET
128 #ifdef HAVE_FUNCTION_GRAPH_FP_TEST
131 SYM_INNER_LABEL(ftrace_graph_regs_call, SYM_L_GLOBAL)
137 SYM_FUNC_END(ftrace_regs_caller)
138 #endif /* CONFIG_DYNAMIC_FTRACE_WITH_REGS */