uprobes/x86: Cleanup the single-stepping code
authorOleg Nesterov <oleg@redhat.com>
Sun, 28 Oct 2012 16:57:30 +0000 (17:57 +0100)
committerOleg Nesterov <oleg@redhat.com>
Sat, 3 Nov 2012 16:15:12 +0000 (17:15 +0100)
No functional changes.

Now that default arch_uprobe_enable/disable_step() helpers do nothing,
x86 has no reason to reimplement them. Change arch_uprobe_*_xol() hooks
to do the necessary work and remove the x86-specific hooks.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
arch/x86/kernel/uprobes.c

index aafa5557b3964a57bf0abbdd9c849786688f1ce9..c71025b674623133219377a70b1e27f380a95ffa 100644 (file)
@@ -478,6 +478,11 @@ int arch_uprobe_pre_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
        regs->ip = current->utask->xol_vaddr;
        pre_xol_rip_insn(auprobe, regs, autask);
 
+       autask->saved_tf = !!(regs->flags & X86_EFLAGS_TF);
+       regs->flags |= X86_EFLAGS_TF;
+       if (test_tsk_thread_flag(current, TIF_BLOCKSTEP))
+               set_task_blockstep(current, false);
+
        return 0;
 }
 
@@ -603,6 +608,16 @@ int arch_uprobe_post_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
        if (auprobe->fixups & UPROBE_FIX_CALL)
                result = adjust_ret_addr(regs->sp, correction);
 
+       /*
+        * arch_uprobe_pre_xol() doesn't save the state of TIF_BLOCKSTEP
+        * so we can get an extra SIGTRAP if we do not clear TF. We need
+        * to examine the opcode to make it right.
+        */
+       if (utask->autask.saved_tf)
+               send_sig(SIGTRAP, current, 0);
+       else if (!(auprobe->fixups & UPROBE_FIX_SETF))
+               regs->flags &= ~X86_EFLAGS_TF;
+
        return result;
 }
 
@@ -647,6 +662,10 @@ void arch_uprobe_abort_xol(struct arch_uprobe *auprobe, struct pt_regs *regs)
        current->thread.trap_nr = utask->autask.saved_trap_nr;
        handle_riprel_post_xol(auprobe, regs, NULL);
        instruction_pointer_set(regs, utask->vaddr);
+
+       /* clear TF if it was set by us in arch_uprobe_pre_xol() */
+       if (!utask->autask.saved_tf)
+               regs->flags &= ~X86_EFLAGS_TF;
 }
 
 /*
@@ -676,38 +695,3 @@ bool arch_uprobe_skip_sstep(struct arch_uprobe *auprobe, struct pt_regs *regs)
                send_sig(SIGTRAP, current, 0);
        return ret;
 }
-
-void arch_uprobe_enable_step(struct arch_uprobe *auprobe)
-{
-       struct task_struct *task = current;
-       struct arch_uprobe_task *autask = &task->utask->autask;
-       struct pt_regs *regs = task_pt_regs(task);
-
-       autask->saved_tf = !!(regs->flags & X86_EFLAGS_TF);
-
-       regs->flags |= X86_EFLAGS_TF;
-       if (test_tsk_thread_flag(task, TIF_BLOCKSTEP))
-               set_task_blockstep(task, false);
-}
-
-void arch_uprobe_disable_step(struct arch_uprobe *auprobe)
-{
-       struct task_struct *task = current;
-       struct arch_uprobe_task *autask = &task->utask->autask;
-       bool trapped = (task->utask->state == UTASK_SSTEP_TRAPPED);
-       struct pt_regs *regs = task_pt_regs(task);
-       /*
-        * The state of TIF_BLOCKSTEP was not saved so we can get an extra
-        * SIGTRAP if we do not clear TF. We need to examine the opcode to
-        * make it right.
-        */
-       if (unlikely(trapped)) {
-               if (!autask->saved_tf)
-                       regs->flags &= ~X86_EFLAGS_TF;
-       } else {
-               if (autask->saved_tf)
-                       send_sig(SIGTRAP, task, 0);
-               else if (!(auprobe->fixups & UPROBE_FIX_SETF))
-                       regs->flags &= ~X86_EFLAGS_TF;
-       }
-}
This page took 0.027572 seconds and 5 git commands to generate.