mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: akpm@osdl.org
To: torvalds@osdl.org
Cc: linux-kernel@vger.kernel.org, akpm@osdl.org, ak@suse.de
Subject: [patch 075/198] x86_64: Some fixes for single step handling
Date: Tue, 12 Apr 2005 03:31:45 -0700	[thread overview]
Message-ID: <200504121031.j3CAVpMH005427@shell0.pdx.osdl.net> (raw)


From: "Andi Kleen" <ak@suse.de>

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>
---

 25-akpm/arch/x86_64/kernel/signal.c |   18 ++++--------------
 25-akpm/arch/x86_64/kernel/traps.c  |   10 ++++++++--
 2 files changed, 12 insertions(+), 16 deletions(-)

diff -puN arch/x86_64/kernel/signal.c~x86_64-some-fixes-for-single-step-handling arch/x86_64/kernel/signal.c
--- 25/arch/x86_64/kernel/signal.c~x86_64-some-fixes-for-single-step-handling	2005-04-12 03:21:21.347891528 -0700
+++ 25-akpm/arch/x86_64/kernel/signal.c	2005-04-12 03:21:21.352890768 -0700
@@ -185,7 +185,6 @@ static inline int
 setup_sigcontext(struct sigcontext __user *sc, struct pt_regs *regs, unsigned long mask, struct task_struct *me)
 {
 	int err = 0;
-	unsigned long eflags;
 
 	err |= __put_user(0, &sc->gs);
 	err |= __put_user(0, &sc->fs);
@@ -209,11 +208,7 @@ setup_sigcontext(struct sigcontext __use
 	err |= __put_user(me->thread.trap_no, &sc->trapno);
 	err |= __put_user(me->thread.error_code, &sc->err);
 	err |= __put_user(regs->rip, &sc->rip);
-	eflags = regs->eflags;
-	if (current->ptrace & PT_PTRACED) {
-		eflags &= ~TF_MASK;
-	}
-	err |= __put_user(eflags, &sc->eflags);
+	err |= __put_user(regs->eflags, &sc->eflags);
 	err |= __put_user(mask, &sc->oldmask);
 	err |= __put_user(me->thread.cr2, &sc->cr2);
 
@@ -323,14 +318,9 @@ static void setup_rt_frame(int sig, stru
 	regs->rsp = (unsigned long)frame;
 
 	set_fs(USER_DS);
-	if (regs->eflags & TF_MASK) {
-		if ((current->ptrace & (PT_PTRACED | PT_DTRACE)) == (PT_PTRACED | PT_DTRACE)) {
-			ptrace_notify(SIGTRAP);
-		} else {
-			regs->eflags &= ~TF_MASK;
-		}
-	}
-
+	regs->eflags &= ~TF_MASK;
+	if (test_thread_flag(TIF_SINGLESTEP))
+		ptrace_notify(SIGTRAP);
 #ifdef DEBUG_SIG
 	printk("SIG deliver (%s:%d): sp=%p pc=%p ra=%p\n",
 		current->comm, current->pid, frame, regs->rip, frame->pretcode);
diff -puN arch/x86_64/kernel/traps.c~x86_64-some-fixes-for-single-step-handling arch/x86_64/kernel/traps.c
--- 25/arch/x86_64/kernel/traps.c~x86_64-some-fixes-for-single-step-handling	2005-04-12 03:21:21.349891224 -0700
+++ 25-akpm/arch/x86_64/kernel/traps.c	2005-04-12 03:21:21.353890616 -0700
@@ -688,8 +688,14 @@ asmlinkage void *do_debug(struct pt_regs
 		 */
                 if ((regs->cs & 3) == 0)
                        goto clear_TF_reenable;
-		if ((tsk->ptrace & (PT_DTRACE|PT_PTRACED)) == PT_DTRACE)
-			goto clear_TF;
+		/*
+		 * Was the TF flag set by a debugger? If so, clear it now,
+		 * so that register information is correct.
+		 */
+		if (tsk->ptrace & PT_DTRACE) {
+			regs->eflags &= ~TF_MASK;
+			tsk->ptrace &= ~PT_DTRACE;
+		}
 	}
 
 	/* Ok, finally something we can handle */
_

                 reply	other threads:[~2005-04-12 19:48 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200504121031.j3CAVpMH005427@shell0.pdx.osdl.net \
    --to=akpm@osdl.org \
    --cc=ak@suse.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®