forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-04 1543e317f1da31b75942316931e8f491a8920811
kernel/arch/arm64/include/asm/ftrace.h
....@@ -1,20 +1,42 @@
1
+/* SPDX-License-Identifier: GPL-2.0-only */
12 /*
23 * arch/arm64/include/asm/ftrace.h
34 *
45 * Copyright (C) 2013 Linaro Limited
56 * Author: AKASHI Takahiro <takahiro.akashi@linaro.org>
6
- *
7
- * This program is free software; you can redistribute it and/or modify
8
- * it under the terms of the GNU General Public License version 2 as
9
- * published by the Free Software Foundation.
107 */
118 #ifndef __ASM_FTRACE_H
129 #define __ASM_FTRACE_H
1310
1411 #include <asm/insn.h>
1512
13
+#define HAVE_FUNCTION_GRAPH_FP_TEST
14
+
15
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
16
+#define ARCH_SUPPORTS_FTRACE_OPS 1
17
+#else
1618 #define MCOUNT_ADDR ((unsigned long)_mcount)
19
+#endif
20
+
21
+/* The BL at the callsite's adjusted rec->ip */
1722 #define MCOUNT_INSN_SIZE AARCH64_INSN_SIZE
23
+
24
+#define FTRACE_PLT_IDX 0
25
+#define FTRACE_REGS_PLT_IDX 1
26
+#define NR_FTRACE_PLTS 2
27
+
28
+/*
29
+ * Currently, gcc tends to save the link register after the local variables
30
+ * on the stack. This causes the max stack tracer to report the function
31
+ * frame sizes for the wrong functions. By defining
32
+ * ARCH_FTRACE_SHIFT_STACK_TRACER, it will tell the stack tracer to expect
33
+ * to find the return address on the stack after the local variables have
34
+ * been set up.
35
+ *
36
+ * Note, this may change in the future, and we will need to deal with that
37
+ * if it were to happen.
38
+ */
39
+#define ARCH_FTRACE_SHIFT_STACK_TRACER 1
1840
1941 #ifndef __ASSEMBLY__
2042 #include <linux/compat.h>
....@@ -33,12 +55,24 @@
3355 static inline unsigned long ftrace_call_adjust(unsigned long addr)
3456 {
3557 /*
58
+ * Adjust addr to point at the BL in the callsite.
59
+ * See ftrace_init_nop() for the callsite sequence.
60
+ */
61
+ if (IS_ENABLED(CONFIG_DYNAMIC_FTRACE_WITH_REGS))
62
+ return addr + AARCH64_INSN_SIZE;
63
+ /*
3664 * addr is the address of the mcount call instruction.
3765 * recordmcount does the necessary offset calculation.
3866 */
3967 return addr;
4068 }
4169
70
+#ifdef CONFIG_DYNAMIC_FTRACE_WITH_REGS
71
+struct dyn_ftrace;
72
+int ftrace_init_nop(struct module *mod, struct dyn_ftrace *rec);
73
+#define ftrace_init_nop ftrace_init_nop
74
+#endif
75
+
4276 #define ftrace_return_address(n) return_address(n)
4377
4478 /*