24
24
#include <asm/set_memory.h>
25
25
#include <asm/sections.h>
26
26
#include <asm/dis.h>
27
- #include "kprobes.h"
28
27
#include "entry.h"
29
28
30
29
DEFINE_PER_CPU (struct kprobe * , current_kprobe );
31
30
DEFINE_PER_CPU (struct kprobe_ctlblk , kprobe_ctlblk );
32
31
33
32
struct kretprobe_blackpoint kretprobe_blacklist [] = { };
34
33
35
- static int insn_page_in_use ;
36
-
37
34
void * alloc_insn_page (void )
38
35
{
39
36
void * page ;
@@ -45,26 +42,6 @@ void *alloc_insn_page(void)
45
42
return page ;
46
43
}
47
44
48
- static void * alloc_s390_insn_page (void )
49
- {
50
- if (xchg (& insn_page_in_use , 1 ) == 1 )
51
- return NULL ;
52
- return & kprobes_insn_page ;
53
- }
54
-
55
- static void free_s390_insn_page (void * page )
56
- {
57
- xchg (& insn_page_in_use , 0 );
58
- }
59
-
60
- struct kprobe_insn_cache kprobe_s390_insn_slots = {
61
- .mutex = __MUTEX_INITIALIZER (kprobe_s390_insn_slots .mutex ),
62
- .alloc = alloc_s390_insn_page ,
63
- .free = free_s390_insn_page ,
64
- .pages = LIST_HEAD_INIT (kprobe_s390_insn_slots .pages ),
65
- .insn_size = MAX_INSN_SIZE ,
66
- };
67
-
68
45
static void copy_instruction (struct kprobe * p )
69
46
{
70
47
kprobe_opcode_t insn [MAX_INSN_SIZE ];
@@ -78,10 +55,10 @@ static void copy_instruction(struct kprobe *p)
78
55
if (probe_is_insn_relative_long (& insn [0 ])) {
79
56
/*
80
57
* For pc-relative instructions in RIL-b or RIL-c format patch
81
- * the RI2 displacement field. We have already made sure that
82
- * the insn slot for the patched instruction is within the same
83
- * 2GB area as the original instruction (either kernel image or
84
- * module area). Therefore the new displacement will always fit.
58
+ * the RI2 displacement field. The insn slot for the to be
59
+ * patched instruction is within the same 4GB area like the
60
+ * original instruction. Therefore the new displacement will
61
+ * always fit.
85
62
*/
86
63
disp = * (s32 * )& insn [1 ];
87
64
addr = (u64 )(unsigned long )p -> addr ;
@@ -93,34 +70,6 @@ static void copy_instruction(struct kprobe *p)
93
70
}
94
71
NOKPROBE_SYMBOL (copy_instruction );
95
72
96
- static int s390_get_insn_slot (struct kprobe * p )
97
- {
98
- /*
99
- * Get an insn slot that is within the same 2GB area like the original
100
- * instruction. That way instructions with a 32bit signed displacement
101
- * field can be patched and executed within the insn slot.
102
- */
103
- p -> ainsn .insn = NULL ;
104
- if (is_kernel ((unsigned long )p -> addr ))
105
- p -> ainsn .insn = get_s390_insn_slot ();
106
- else if (is_module_addr (p -> addr ))
107
- p -> ainsn .insn = get_insn_slot ();
108
- return p -> ainsn .insn ? 0 : - ENOMEM ;
109
- }
110
- NOKPROBE_SYMBOL (s390_get_insn_slot );
111
-
112
- static void s390_free_insn_slot (struct kprobe * p )
113
- {
114
- if (!p -> ainsn .insn )
115
- return ;
116
- if (is_kernel ((unsigned long )p -> addr ))
117
- free_s390_insn_slot (p -> ainsn .insn , 0 );
118
- else
119
- free_insn_slot (p -> ainsn .insn , 0 );
120
- p -> ainsn .insn = NULL ;
121
- }
122
- NOKPROBE_SYMBOL (s390_free_insn_slot );
123
-
124
73
/* Check if paddr is at an instruction boundary */
125
74
static bool can_probe (unsigned long paddr )
126
75
{
@@ -174,7 +123,8 @@ int arch_prepare_kprobe(struct kprobe *p)
174
123
/* Make sure the probe isn't going on a difficult instruction */
175
124
if (probe_is_prohibited_opcode (p -> addr ))
176
125
return - EINVAL ;
177
- if (s390_get_insn_slot (p ))
126
+ p -> ainsn .insn = get_insn_slot ();
127
+ if (!p -> ainsn .insn )
178
128
return - ENOMEM ;
179
129
copy_instruction (p );
180
130
return 0 ;
@@ -216,7 +166,10 @@ NOKPROBE_SYMBOL(arch_disarm_kprobe);
216
166
217
167
void arch_remove_kprobe (struct kprobe * p )
218
168
{
219
- s390_free_insn_slot (p );
169
+ if (!p -> ainsn .insn )
170
+ return ;
171
+ free_insn_slot (p -> ainsn .insn , 0 );
172
+ p -> ainsn .insn = NULL ;
220
173
}
221
174
NOKPROBE_SYMBOL (arch_remove_kprobe );
222
175
0 commit comments