forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-08 01573e231f18eb2d99162747186f59511f56b64d
kernel/arch/x86/include/asm/kprobes.h
....@@ -1,21 +1,8 @@
1
+/* SPDX-License-Identifier: GPL-2.0-or-later */
12 #ifndef _ASM_X86_KPROBES_H
23 #define _ASM_X86_KPROBES_H
34 /*
45 * Kernel Probes (KProbes)
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License, or
9
- * (at your option) any later version.
10
- *
11
- * This program is distributed in the hope that it will be useful,
12
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
- * GNU General Public License for more details.
15
- *
16
- * You should have received a copy of the GNU General Public License
17
- * along with this program; if not, write to the Free Software
18
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
196 *
207 * Copyright (C) IBM Corporation, 2002, 2004
218 *
....@@ -24,12 +11,11 @@
2411
2512 #include <asm-generic/kprobes.h>
2613
27
-#define BREAKPOINT_INSTRUCTION 0xcc
28
-
2914 #ifdef CONFIG_KPROBES
3015 #include <linux/types.h>
3116 #include <linux/ptrace.h>
3217 #include <linux/percpu.h>
18
+#include <asm/text-patching.h>
3319 #include <asm/insn.h>
3420
3521 #define __ARCH_WANT_KPROBES_INSN_SLOT
....@@ -38,10 +24,7 @@
3824 struct kprobe;
3925
4026 typedef u8 kprobe_opcode_t;
41
-#define RELATIVEJUMP_OPCODE 0xe9
42
-#define RELATIVEJUMP_SIZE 5
43
-#define RELATIVECALL_OPCODE 0xe8
44
-#define RELATIVE_ADDR_SIZE 4
27
+
4528 #define MAX_STACK_SIZE 64
4629 #define CUR_STACK_SIZE(ADDR) \
4730 (current_top_of_stack() - (unsigned long)(ADDR))
....@@ -53,14 +36,15 @@
5336
5437 /* optinsn template addresses */
5538 extern __visible kprobe_opcode_t optprobe_template_entry[];
39
+extern __visible kprobe_opcode_t optprobe_template_clac[];
5640 extern __visible kprobe_opcode_t optprobe_template_val[];
5741 extern __visible kprobe_opcode_t optprobe_template_call[];
5842 extern __visible kprobe_opcode_t optprobe_template_end[];
59
-#define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + RELATIVE_ADDR_SIZE)
43
+#define MAX_OPTIMIZED_LENGTH (MAX_INSN_SIZE + DISP32_SIZE)
6044 #define MAX_OPTINSN_SIZE \
6145 (((unsigned long)optprobe_template_end - \
6246 (unsigned long)optprobe_template_entry) + \
63
- MAX_OPTIMIZED_LENGTH + RELATIVEJUMP_SIZE)
47
+ MAX_OPTIMIZED_LENGTH + JMP32_INSN_SIZE)
6448
6549 extern const int kretprobe_blacklist_size;
6650
....@@ -82,11 +66,13 @@
8266 */
8367 bool boostable;
8468 bool if_modifier;
69
+ /* Number of bytes of text poked */
70
+ int tp_len;
8571 };
8672
8773 struct arch_optimized_insn {
8874 /* copy of the original instructions */
89
- kprobe_opcode_t copied_insn[RELATIVE_ADDR_SIZE];
75
+ kprobe_opcode_t copied_insn[DISP32_SIZE];
9076 /* detour code buffer */
9177 kprobe_opcode_t *insn;
9278 /* the size of instructions copied to detour code buffer */
....@@ -120,5 +106,9 @@
120106 extern int kprobe_int3_handler(struct pt_regs *regs);
121107 extern int kprobe_debug_handler(struct pt_regs *regs);
122108
109
+#else
110
+
111
+static inline int kprobe_debug_handler(struct pt_regs *regs) { return 0; }
112
+
123113 #endif /* CONFIG_KPROBES */
124114 #endif /* _ASM_X86_KPROBES_H */