aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/traps_64.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2008-01-30 07:30:50 -0500
committerIngo Molnar <mingo@elte.hu>2008-01-30 07:30:50 -0500
commite1f287735c1e58c653b516931b5d3dd899edcb77 (patch)
tree1a2948cfe8ff679135971e2c573d11b847fee93d /arch/x86/kernel/traps_64.c
parent7122ec8158b0f88befd94f4da8feae2c8d08d1b4 (diff)
x86 single_step: TIF_FORCED_TF
This changes the single-step support to use a new thread_info flag TIF_FORCED_TF instead of the PT_DTRACE flag in task_struct.ptrace. This keeps arch implementation uses out of this non-arch field. This changes the ptrace access to eflags to mask TF and maintain the TIF_FORCED_TF flag directly if userland sets TF, instead of relying on ptrace_signal_deliver. The 64-bit and 32-bit kernels are harmonized on this same behavior. The ptrace_signal_deliver approach works now, but this change makes the low-level register access code reliable when called from different contexts than a ptrace stop, which will be possible in the future. The 64-bit do_debug exception handler is also changed not to clear TF from user-mode registers. This matches the 32-bit kernel's behavior. Signed-off-by: Roland McGrath <roland@redhat.com> Signed-off-by: Ingo Molnar <mingo@elte.hu> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel/traps_64.c')
-rw-r--r--arch/x86/kernel/traps_64.c23
1 files changed, 5 insertions, 18 deletions
diff --git a/arch/x86/kernel/traps_64.c b/arch/x86/kernel/traps_64.c
index aa248d754533..874aca397b02 100644
--- a/arch/x86/kernel/traps_64.c
+++ b/arch/x86/kernel/traps_64.c
@@ -865,27 +865,14 @@ asmlinkage void __kprobes do_debug(struct pt_regs * regs,
865 865
866 tsk->thread.debugreg6 = condition; 866 tsk->thread.debugreg6 = condition;
867 867
868 /* Mask out spurious TF errors due to lazy TF clearing */ 868
869 /*
870 * Single-stepping through TF: make sure we ignore any events in
871 * kernel space (but re-enable TF when returning to user mode).
872 */
869 if (condition & DR_STEP) { 873 if (condition & DR_STEP) {
870 /*
871 * The TF error should be masked out only if the current
872 * process is not traced and if the TRAP flag has been set
873 * previously by a tracing process (condition detected by
874 * the PT_DTRACE flag); remember that the i386 TRAP flag
875 * can be modified by the process itself in user mode,
876 * allowing programs to debug themselves without the ptrace()
877 * interface.
878 */
879 if (!user_mode(regs)) 874 if (!user_mode(regs))
880 goto clear_TF_reenable; 875 goto clear_TF_reenable;
881 /*
882 * Was the TF flag set by a debugger? If so, clear it now,
883 * so that register information is correct.
884 */
885 if (tsk->ptrace & PT_DTRACE) {
886 regs->eflags &= ~TF_MASK;
887 tsk->ptrace &= ~PT_DTRACE;
888 }
889 } 876 }
890 877
891 /* Ok, finally something we can handle */ 878 /* Ok, finally something we can handle */