aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorAndi Kleen <ak@suse.de>2005-04-16 18:24:57 -0400
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-16 18:24:57 -0400
commitbe61bff789fe44bfb6d9282d8f7eccc860bdcfb6 (patch)
tree6c11d1fe32e7811c923ca5c7c21b89a78b5dd52f /arch
parentaa85b9af5bdae1f8b84d80367324e4410c3f0674 (diff)
[PATCH] x86_64: Some fixes for single step handling
Ported from i386/Linus Be more careful with TF handling to fix some copy protection codes in Wine Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch')
-rw-r--r--arch/x86_64/kernel/signal.c18
-rw-r--r--arch/x86_64/kernel/traps.c10
2 files changed, 12 insertions, 16 deletions
diff --git a/arch/x86_64/kernel/signal.c b/arch/x86_64/kernel/signal.c
index 5ace32c6ac5c..4ff0f0117a09 100644
--- a/arch/x86_64/kernel/signal.c
+++ b/arch/x86_64/kernel/signal.c
@@ -185,7 +185,6 @@ static inline int
185setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask, struct task_struct *me) 185setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask, struct task_struct *me)
186{ 186{
187 int err = 0; 187 int err = 0;
188 unsigned long eflags;
189 188
190 err |= __put_user(0, &sc->gs); 189 err |= __put_user(0, &sc->gs);
191 err |= __put_user(0, &sc->fs); 190 err |= __put_user(0, &sc->fs);
@@ -209,11 +208,7 @@ setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned lo
209 err |= __put_user(me->thread.trap_no, &sc->trapno); 208 err |= __put_user(me->thread.trap_no, &sc->trapno);
210 err |= __put_user(me->thread.error_code, &sc->err); 209 err |= __put_user(me->thread.error_code, &sc->err);
211 err |= __put_user(regs->rip, &sc->rip); 210 err |= __put_user(regs->rip, &sc->rip);
212 eflags = regs->eflags; 211 err |= __put_user(regs->eflags, &sc->eflags);
213 if (current->ptrace & PT_PTRACED) {
214 eflags &= ~TF_MASK;
215 }
216 err |= __put_user(eflags, &sc->eflags);
217 err |= __put_user(mask, &sc->oldmask); 212 err |= __put_user(mask, &sc->oldmask);
218 err |= __put_user(me->thread.cr2, &sc->cr2); 213 err |= __put_user(me->thread.cr2, &sc->cr2);
219 214
@@ -323,14 +318,9 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info,
323 regs->rsp = (unsigned long)frame; 318 regs->rsp = (unsigned long)frame;
324 319
325 set_fs(USER_DS); 320 set_fs(USER_DS);
326 if (regs->eflags & TF_MASK) { 321 regs->eflags &= ~TF_MASK;
327 if ((current->ptrace & (PT_PTRACED | PT_DTRACE)) == (PT_PTRACED | PT_DTRACE)) { 322 if (test_thread_flag(TIF_SINGLESTEP))
328 ptrace_notify(SIGTRAP); 323 ptrace_notify(SIGTRAP);
329 } else {
330 regs->eflags &= ~TF_MASK;
331 }
332 }
333
334#ifdef DEBUG_SIG 324#ifdef DEBUG_SIG
335 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n", 325 printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
336 current->comm, current->pid, frame, regs->rip, frame->pretcode); 326 current->comm, current->pid, frame, regs->rip, frame->pretcode);
diff --git a/arch/x86_64/kernel/traps.c b/arch/x86_64/kernel/traps.c
index 2707a27b81cd..09e4a6460e74 100644
--- a/arch/x86_64/kernel/traps.c
+++ b/arch/x86_64/kernel/traps.c
@@ -688,8 +688,14 @@ asmlinkage void *do_debug(struct pt_regs * regs, unsigned long error_code)
688 */ 688 */
689 if ((regs->cs & 3) == 0) 689 if ((regs->cs & 3) == 0)
690 goto clear_TF_reenable; 690 goto clear_TF_reenable;
691 if ((tsk->ptrace & (PT_DTRACE|PT_PTRACED)) == PT_DTRACE) 691 /*
692 goto clear_TF; 692 * Was the TF flag set by a debugger? If so, clear it now,
693 * so that register information is correct.
694 */
695 if (tsk->ptrace & PT_DTRACE) {
696 regs->eflags &= ~TF_MASK;
697 tsk->ptrace &= ~PT_DTRACE;
698 }
693 } 699 }
694 700
695 /* Ok, finally something we can handle */ 701 /* Ok, finally something we can handle */