.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | #ifndef _ASM_X86_KPROBES_H |
---|
2 | 3 | #define _ASM_X86_KPROBES_H |
---|
3 | 4 | /* |
---|
4 | 5 | * 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. |
---|
19 | 6 | * |
---|
20 | 7 | * Copyright (C) IBM Corporation, 2002, 2004 |
---|
21 | 8 | * |
---|
.. | .. |
---|
24 | 11 | |
---|
25 | 12 | #include <asm-generic/kprobes.h> |
---|
26 | 13 | |
---|
27 | | -#define BREAKPOINT_INSTRUCTION 0xcc |
---|
28 | | - |
---|
29 | 14 | #ifdef CONFIG_KPROBES |
---|
30 | 15 | #include <linux/types.h> |
---|
31 | 16 | #include <linux/ptrace.h> |
---|
32 | 17 | #include <linux/percpu.h> |
---|
| 18 | +#include <asm/text-patching.h> |
---|
33 | 19 | #include <asm/insn.h> |
---|
34 | 20 | |
---|
35 | 21 | #define __ARCH_WANT_KPROBES_INSN_SLOT |
---|
.. | .. |
---|
38 | 24 | struct kprobe; |
---|
39 | 25 | |
---|
40 | 26 | 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 | + |
---|
45 | 28 | #define MAX_STACK_SIZE 64 |
---|
46 | 29 | #define CUR_STACK_SIZE(ADDR) \ |
---|
47 | 30 | (current_top_of_stack() - (unsigned long)(ADDR)) |
---|
.. | .. |
---|
53 | 36 | |
---|
54 | 37 | /* optinsn template addresses */ |
---|
55 | 38 | extern __visible kprobe_opcode_t optprobe_template_entry[]; |
---|
| 39 | +extern __visible kprobe_opcode_t optprobe_template_clac[]; |
---|
56 | 40 | extern __visible kprobe_opcode_t optprobe_template_val[]; |
---|
57 | 41 | extern __visible kprobe_opcode_t optprobe_template_call[]; |
---|
58 | 42 | 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) |
---|
60 | 44 | #define MAX_OPTINSN_SIZE \ |
---|
61 | 45 | (((unsigned long)optprobe_template_end - \ |
---|
62 | 46 | (unsigned long)optprobe_template_entry) + \ |
---|
63 | | - MAX_OPTIMIZED_LENGTH + RELATIVEJUMP_SIZE) |
---|
| 47 | + MAX_OPTIMIZED_LENGTH + JMP32_INSN_SIZE) |
---|
64 | 48 | |
---|
65 | 49 | extern const int kretprobe_blacklist_size; |
---|
66 | 50 | |
---|
.. | .. |
---|
82 | 66 | */ |
---|
83 | 67 | bool boostable; |
---|
84 | 68 | bool if_modifier; |
---|
| 69 | + /* Number of bytes of text poked */ |
---|
| 70 | + int tp_len; |
---|
85 | 71 | }; |
---|
86 | 72 | |
---|
87 | 73 | struct arch_optimized_insn { |
---|
88 | 74 | /* copy of the original instructions */ |
---|
89 | | - kprobe_opcode_t copied_insn[RELATIVE_ADDR_SIZE]; |
---|
| 75 | + kprobe_opcode_t copied_insn[DISP32_SIZE]; |
---|
90 | 76 | /* detour code buffer */ |
---|
91 | 77 | kprobe_opcode_t *insn; |
---|
92 | 78 | /* the size of instructions copied to detour code buffer */ |
---|
.. | .. |
---|
120 | 106 | extern int kprobe_int3_handler(struct pt_regs *regs); |
---|
121 | 107 | extern int kprobe_debug_handler(struct pt_regs *regs); |
---|
122 | 108 | |
---|
| 109 | +#else |
---|
| 110 | + |
---|
| 111 | +static inline int kprobe_debug_handler(struct pt_regs *regs) { return 0; } |
---|
| 112 | + |
---|
123 | 113 | #endif /* CONFIG_KPROBES */ |
---|
124 | 114 | #endif /* _ASM_X86_KPROBES_H */ |
---|