2424#include <asm/set_memory.h>
2525#include <asm/sections.h>
2626#include <asm/dis.h>
27- #include "kprobes.h"
2827#include "entry.h"
2928
3029DEFINE_PER_CPU (struct kprobe * , current_kprobe );
3130DEFINE_PER_CPU (struct kprobe_ctlblk , kprobe_ctlblk );
3231
3332struct kretprobe_blackpoint kretprobe_blacklist [] = { };
3433
35- static int insn_page_in_use ;
36-
3734void * alloc_insn_page (void )
3835{
3936 void * page ;
@@ -45,26 +42,6 @@ void *alloc_insn_page(void)
4542 return page ;
4643}
4744
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-
6845static void copy_instruction (struct kprobe * p )
6946{
7047 kprobe_opcode_t insn [MAX_INSN_SIZE ];
@@ -78,10 +55,10 @@ static void copy_instruction(struct kprobe *p)
7855 if (probe_is_insn_relative_long (& insn [0 ])) {
7956 /*
8057 * 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.
8562 */
8663 disp = * (s32 * )& insn [1 ];
8764 addr = (u64 )(unsigned long )p -> addr ;
@@ -93,34 +70,6 @@ static void copy_instruction(struct kprobe *p)
9370}
9471NOKPROBE_SYMBOL (copy_instruction );
9572
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-
12473/* Check if paddr is at an instruction boundary */
12574static bool can_probe (unsigned long paddr )
12675{
@@ -174,7 +123,8 @@ int arch_prepare_kprobe(struct kprobe *p)
174123 /* Make sure the probe isn't going on a difficult instruction */
175124 if (probe_is_prohibited_opcode (p -> addr ))
176125 return - EINVAL ;
177- if (s390_get_insn_slot (p ))
126+ p -> ainsn .insn = get_insn_slot ();
127+ if (!p -> ainsn .insn )
178128 return - ENOMEM ;
179129 copy_instruction (p );
180130 return 0 ;
@@ -216,7 +166,10 @@ NOKPROBE_SYMBOL(arch_disarm_kprobe);
216166
217167void arch_remove_kprobe (struct kprobe * p )
218168{
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 ;
220173}
221174NOKPROBE_SYMBOL (arch_remove_kprobe );
222175
0 commit comments