diff options
author | Masami Hiramatsu <mhiramat@redhat.com> | 2008-01-30 07:32:02 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:32:02 -0500 |
commit | 59e87cdcd268daa85c0732e147c59e0c1bacd704 (patch) | |
tree | 67b6e008478e5f14f4c73406f97661c7009233fd /arch/x86/kernel/kprobes.c | |
parent | 40102d4a41312ad4134c0b802ad074445ce8b17b (diff) |
x86: move deeply indented code to reenter_kprobe
Move some deeply indented code related to re-entrance processing
from kprobe_handler() to reenter_kprobe().
Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com>
Cc: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Cc: Jim Keniston <jkenisto@us.ibm.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/kprobes.c')
-rw-r--r-- | arch/x86/kernel/kprobes.c | 46 |
1 files changed, 23 insertions, 23 deletions
diff --git a/arch/x86/kernel/kprobes.c b/arch/x86/kernel/kprobes.c index 7dd918633c30..4e33329ce8a3 100644 --- a/arch/x86/kernel/kprobes.c +++ b/arch/x86/kernel/kprobes.c | |||
@@ -432,14 +432,32 @@ void __kprobes arch_prepare_kretprobe(struct kretprobe_instance *ri, | |||
432 | * within the handler. We save the original kprobes variables and just single | 432 | * within the handler. We save the original kprobes variables and just single |
433 | * step on the instruction of the new probe without calling any user handlers. | 433 | * step on the instruction of the new probe without calling any user handlers. |
434 | */ | 434 | */ |
435 | static void __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs, | 435 | static int __kprobes reenter_kprobe(struct kprobe *p, struct pt_regs *regs, |
436 | struct kprobe_ctlblk *kcb) | 436 | struct kprobe_ctlblk *kcb) |
437 | { | 437 | { |
438 | if (kcb->kprobe_status == KPROBE_HIT_SS && | ||
439 | *p->ainsn.insn == BREAKPOINT_INSTRUCTION) { | ||
440 | regs->flags &= ~X86_EFLAGS_TF; | ||
441 | regs->flags |= kcb->kprobe_saved_flags; | ||
442 | return 0; | ||
443 | #ifdef CONFIG_X86_64 | ||
444 | } else if (kcb->kprobe_status == KPROBE_HIT_SSDONE) { | ||
445 | /* TODO: Provide re-entrancy from post_kprobes_handler() and | ||
446 | * avoid exception stack corruption while single-stepping on | ||
447 | * the instruction of the new probe. | ||
448 | */ | ||
449 | arch_disarm_kprobe(p); | ||
450 | regs->ip = (unsigned long)p->addr; | ||
451 | reset_current_kprobe(); | ||
452 | return 1; | ||
453 | #endif | ||
454 | } | ||
438 | save_previous_kprobe(kcb); | 455 | save_previous_kprobe(kcb); |
439 | set_current_kprobe(p, regs, kcb); | 456 | set_current_kprobe(p, regs, kcb); |
440 | kprobes_inc_nmissed_count(p); | 457 | kprobes_inc_nmissed_count(p); |
441 | prepare_singlestep(p, regs); | 458 | prepare_singlestep(p, regs); |
442 | kcb->kprobe_status = KPROBE_REENTER; | 459 | kcb->kprobe_status = KPROBE_REENTER; |
460 | return 1; | ||
443 | } | 461 | } |
444 | 462 | ||
445 | /* | 463 | /* |
@@ -466,27 +484,9 @@ static int __kprobes kprobe_handler(struct pt_regs *regs) | |||
466 | if (kprobe_running()) { | 484 | if (kprobe_running()) { |
467 | p = get_kprobe(addr); | 485 | p = get_kprobe(addr); |
468 | if (p) { | 486 | if (p) { |
469 | if (kcb->kprobe_status == KPROBE_HIT_SS && | 487 | ret = reenter_kprobe(p, regs, kcb); |
470 | *p->ainsn.insn == BREAKPOINT_INSTRUCTION) { | 488 | if (kcb->kprobe_status == KPROBE_REENTER) |
471 | regs->flags &= ~X86_EFLAGS_TF; | 489 | return 1; |
472 | regs->flags |= kcb->kprobe_saved_flags; | ||
473 | goto no_kprobe; | ||
474 | #ifdef CONFIG_X86_64 | ||
475 | } else if (kcb->kprobe_status == KPROBE_HIT_SSDONE) { | ||
476 | /* TODO: Provide re-entrancy from | ||
477 | * post_kprobes_handler() and avoid exception | ||
478 | * stack corruption while single-stepping on | ||
479 | * the instruction of the new probe. | ||
480 | */ | ||
481 | arch_disarm_kprobe(p); | ||
482 | regs->ip = (unsigned long)p->addr; | ||
483 | reset_current_kprobe(); | ||
484 | ret = 1; | ||
485 | goto no_kprobe; | ||
486 | #endif | ||
487 | } | ||
488 | reenter_kprobe(p, regs, kcb); | ||
489 | return 1; | ||
490 | } else { | 490 | } else { |
491 | if (*addr != BREAKPOINT_INSTRUCTION) { | 491 | if (*addr != BREAKPOINT_INSTRUCTION) { |
492 | /* The breakpoint instruction was removed by | 492 | /* The breakpoint instruction was removed by |