diff options
author | Roland McGrath <roland@redhat.com> | 2008-01-30 07:30:50 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@elte.hu> | 2008-01-30 07:30:50 -0500 |
commit | e1f287735c1e58c653b516931b5d3dd899edcb77 (patch) | |
tree | 1a2948cfe8ff679135971e2c573d11b847fee93d /arch/x86/ia32 | |
parent | 7122ec8158b0f88befd94f4da8feae2c8d08d1b4 (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/ia32')
-rw-r--r-- | arch/x86/ia32/ptrace32.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/arch/x86/ia32/ptrace32.c b/arch/x86/ia32/ptrace32.c index 9d754b640205..5dee33417313 100644 --- a/arch/x86/ia32/ptrace32.c +++ b/arch/x86/ia32/ptrace32.c | |||
@@ -89,6 +89,15 @@ static int putreg32(struct task_struct *child, unsigned regno, u32 val) | |||
89 | __u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8]; | 89 | __u64 *flags = &stack[offsetof(struct pt_regs, eflags)/8]; |
90 | 90 | ||
91 | val &= FLAG_MASK; | 91 | val &= FLAG_MASK; |
92 | /* | ||
93 | * If the user value contains TF, mark that | ||
94 | * it was not "us" (the debugger) that set it. | ||
95 | * If not, make sure it stays set if we had. | ||
96 | */ | ||
97 | if (val & X86_EFLAGS_TF) | ||
98 | clear_tsk_thread_flag(child, TIF_FORCED_TF); | ||
99 | else if (test_tsk_thread_flag(child, TIF_FORCED_TF)) | ||
100 | val |= X86_EFLAGS_TF; | ||
92 | *flags = val | (*flags & ~FLAG_MASK); | 101 | *flags = val | (*flags & ~FLAG_MASK); |
93 | break; | 102 | break; |
94 | } | 103 | } |
@@ -179,9 +188,17 @@ static int getreg32(struct task_struct *child, unsigned regno, u32 *val) | |||
179 | R32(eax, rax); | 188 | R32(eax, rax); |
180 | R32(orig_eax, orig_rax); | 189 | R32(orig_eax, orig_rax); |
181 | R32(eip, rip); | 190 | R32(eip, rip); |
182 | R32(eflags, eflags); | ||
183 | R32(esp, rsp); | 191 | R32(esp, rsp); |
184 | 192 | ||
193 | case offsetof(struct user32, regs.eflags): | ||
194 | /* | ||
195 | * If the debugger set TF, hide it from the readout. | ||
196 | */ | ||
197 | *val = stack[offsetof(struct pt_regs, eflags)/8]; | ||
198 | if (test_tsk_thread_flag(child, TIF_FORCED_TF)) | ||
199 | *val &= ~X86_EFLAGS_TF; | ||
200 | break; | ||
201 | |||
185 | case offsetof(struct user32, u_debugreg[0]): | 202 | case offsetof(struct user32, u_debugreg[0]): |
186 | *val = child->thread.debugreg0; | 203 | *val = child->thread.debugreg0; |
187 | break; | 204 | break; |
@@ -425,4 +442,3 @@ asmlinkage long sys32_ptrace(long request, u32 pid, u32 addr, u32 data) | |||
425 | put_task_struct(child); | 442 | put_task_struct(child); |
426 | return ret; | 443 | return ret; |
427 | } | 444 | } |
428 | |||