@@ -34,7 +34,7 @@ DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
34
34
DEFINE_PER_CPU (struct kprobe_ctlblk , kprobe_ctlblk );
35
35
36
36
static void __kprobes
37
- post_kprobe_handler (struct kprobe_ctlblk * , struct pt_regs * );
37
+ post_kprobe_handler (struct kprobe * , struct kprobe_ctlblk * , struct pt_regs * );
38
38
39
39
static void __kprobes arch_prepare_ss_slot (struct kprobe * p )
40
40
{
@@ -68,7 +68,7 @@ static void __kprobes arch_simulate_insn(struct kprobe *p, struct pt_regs *regs)
68
68
p -> ainsn .api .handler ((u32 )p -> opcode , (long )p -> addr , regs );
69
69
70
70
/* single step simulated, now go for post processing */
71
- post_kprobe_handler (kcb , regs );
71
+ post_kprobe_handler (p , kcb , regs );
72
72
}
73
73
74
74
int __kprobes arch_prepare_kprobe (struct kprobe * p )
@@ -177,19 +177,6 @@ static void __kprobes kprobes_restore_local_irqflag(struct kprobe_ctlblk *kcb,
177
177
regs -> pstate |= kcb -> saved_irqflag ;
178
178
}
179
179
180
- static void __kprobes
181
- set_ss_context (struct kprobe_ctlblk * kcb , unsigned long addr )
182
- {
183
- kcb -> ss_ctx .ss_pending = true;
184
- kcb -> ss_ctx .match_addr = addr + sizeof (kprobe_opcode_t );
185
- }
186
-
187
- static void __kprobes clear_ss_context (struct kprobe_ctlblk * kcb )
188
- {
189
- kcb -> ss_ctx .ss_pending = false;
190
- kcb -> ss_ctx .match_addr = 0 ;
191
- }
192
-
193
180
static void __kprobes setup_singlestep (struct kprobe * p ,
194
181
struct pt_regs * regs ,
195
182
struct kprobe_ctlblk * kcb , int reenter )
@@ -209,7 +196,6 @@ static void __kprobes setup_singlestep(struct kprobe *p,
209
196
/* prepare for single stepping */
210
197
slot = (unsigned long )p -> ainsn .api .insn ;
211
198
212
- set_ss_context (kcb , slot ); /* mark pending ss */
213
199
kprobes_save_local_irqflag (kcb , regs );
214
200
instruction_pointer_set (regs , slot );
215
201
} else {
@@ -243,13 +229,8 @@ static int __kprobes reenter_kprobe(struct kprobe *p,
243
229
}
244
230
245
231
static void __kprobes
246
- post_kprobe_handler (struct kprobe_ctlblk * kcb , struct pt_regs * regs )
232
+ post_kprobe_handler (struct kprobe * cur , struct kprobe_ctlblk * kcb , struct pt_regs * regs )
247
233
{
248
- struct kprobe * cur = kprobe_running ();
249
-
250
- if (!cur )
251
- return ;
252
-
253
234
/* return addr restore if non-branching insn */
254
235
if (cur -> ainsn .api .restore != 0 )
255
236
instruction_pointer_set (regs , cur -> ainsn .api .restore );
@@ -364,33 +345,23 @@ static void __kprobes kprobe_handler(struct pt_regs *regs)
364
345
*/
365
346
}
366
347
367
- static int __kprobes
368
- kprobe_ss_hit (struct kprobe_ctlblk * kcb , unsigned long addr )
369
- {
370
- if ((kcb -> ss_ctx .ss_pending )
371
- && (kcb -> ss_ctx .match_addr == addr )) {
372
- clear_ss_context (kcb ); /* clear pending ss */
373
- return DBG_HOOK_HANDLED ;
374
- }
375
- /* not ours, kprobes should ignore it */
376
- return DBG_HOOK_ERROR ;
377
- }
378
-
379
348
static int __kprobes
380
349
kprobe_breakpoint_ss_handler (struct pt_regs * regs , unsigned int esr )
381
350
{
382
351
struct kprobe_ctlblk * kcb = get_kprobe_ctlblk ();
383
- int retval ;
384
-
385
- /* return error if this is not our step */
386
- retval = kprobe_ss_hit (kcb , instruction_pointer (regs ));
352
+ unsigned long addr = instruction_pointer (regs );
353
+ struct kprobe * cur = kprobe_running ();
387
354
388
- if (retval == DBG_HOOK_HANDLED ) {
355
+ if (cur && (kcb -> kprobe_status == KPROBE_HIT_SS )
356
+ && ((unsigned long )& cur -> ainsn .api .insn [1 ] == addr )) {
389
357
kprobes_restore_local_irqflag (kcb , regs );
390
- post_kprobe_handler (kcb , regs );
358
+ post_kprobe_handler (cur , kcb , regs );
359
+
360
+ return DBG_HOOK_HANDLED ;
391
361
}
392
362
393
- return retval ;
363
+ /* not ours, kprobes should ignore it */
364
+ return DBG_HOOK_ERROR ;
394
365
}
395
366
396
367
static struct break_hook kprobes_break_ss_hook = {
0 commit comments