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/kernel/ptrace_64.c | |
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/kernel/ptrace_64.c')
-rw-r--r-- | arch/x86/kernel/ptrace_64.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/arch/x86/kernel/ptrace_64.c b/arch/x86/kernel/ptrace_64.c index 4abfbced9b26..035d53e99c57 100644 --- a/arch/x86/kernel/ptrace_64.c +++ b/arch/x86/kernel/ptrace_64.c | |||
@@ -143,6 +143,15 @@ static int putreg(struct task_struct *child, | |||
143 | return 0; | 143 | return 0; |
144 | case offsetof(struct user_regs_struct, eflags): | 144 | case offsetof(struct user_regs_struct, eflags): |
145 | value &= FLAG_MASK; | 145 | value &= FLAG_MASK; |
146 | /* | ||
147 | * If the user value contains TF, mark that | ||
148 | * it was not "us" (the debugger) that set it. | ||
149 | * If not, make sure it stays set if we had. | ||
150 | */ | ||
151 | if (value & X86_EFLAGS_TF) | ||
152 | clear_tsk_thread_flag(child, TIF_FORCED_TF); | ||
153 | else if (test_tsk_thread_flag(child, TIF_FORCED_TF)) | ||
154 | value |= X86_EFLAGS_TF; | ||
146 | tmp = get_stack_long(child, EFL_OFFSET); | 155 | tmp = get_stack_long(child, EFL_OFFSET); |
147 | tmp &= ~FLAG_MASK; | 156 | tmp &= ~FLAG_MASK; |
148 | value |= tmp; | 157 | value |= tmp; |
@@ -189,6 +198,17 @@ static unsigned long getreg(struct task_struct *child, unsigned long regno) | |||
189 | if (child->thread.gsindex != GS_TLS_SEL) | 198 | if (child->thread.gsindex != GS_TLS_SEL) |
190 | return 0; | 199 | return 0; |
191 | return get_desc_base(&child->thread.tls_array[GS_TLS]); | 200 | return get_desc_base(&child->thread.tls_array[GS_TLS]); |
201 | case offsetof(struct user_regs_struct, eflags): | ||
202 | /* | ||
203 | * If the debugger set TF, hide it from the readout. | ||
204 | */ | ||
205 | regno = regno - sizeof(struct pt_regs); | ||
206 | val = get_stack_long(child, regno); | ||
207 | if (test_tsk_thread_flag(child, TIF_IA32)) | ||
208 | val &= 0xffffffff; | ||
209 | if (test_tsk_thread_flag(child, TIF_FORCED_TF)) | ||
210 | val &= ~X86_EFLAGS_TF; | ||
211 | return val; | ||
192 | default: | 212 | default: |
193 | regno = regno - sizeof(struct pt_regs); | 213 | regno = regno - sizeof(struct pt_regs); |
194 | val = get_stack_long(child, regno); | 214 | val = get_stack_long(child, regno); |