mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Roland McGrath <roland@redhat.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org
Cc: Thomas Gleixner <tglx@linutronix.de>, Ingo Molnar <mingo@elte.hu>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH 10/27] ptrace: generic resume
Date: Sun, 25 Nov 2007 14:01:09 -0800 (PST)	[thread overview]
Message-ID: <20071125220109.10BC726F8C5@magilla.localdomain> (raw)
In-Reply-To: Roland McGrath's message of  Sunday, 25 November 2007 13:55:07 -0800 <20071125215507.4B89226F8C5@magilla.localdomain>


This makes ptrace_request handle all the ptrace requests that wake
up the traced task.  These do low-level ptrace implementation magic
that is not arch-specific and should be kept out of arch code.  The
implementations on each arch usually do the same thing.  The new
generic code makes use of the arch_has_single_step macro and generic
entry points to handle PTRACE_SINGLESTEP.

Signed-off-by: Roland McGrath <roland@redhat.com>
---
 kernel/ptrace.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index 7c76f2f..309796a 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -366,6 +366,50 @@ static int ptrace_setsiginfo(struct task_struct *child, siginfo_t __user * data)
 	return error;
 }
 
+
+#ifdef PTRACE_SINGLESTEP
+#define is_singlestep(request)		((request) == PTRACE_SINGLESTEP)
+#else
+#define is_singlestep(request)		0
+#endif
+
+#ifdef PTRACE_SYSEMU
+#define is_sysemu_singlestep(request)	((request) == PTRACE_SYSEMU_SINGLESTEP)
+#else
+#define is_sysemu_singlestep(request)	0
+#endif
+
+static int ptrace_resume(struct task_struct *child, long request, long data)
+{
+	if (!valid_signal(data))
+		return -EIO;
+
+	if (request == PTRACE_SYSCALL)
+		set_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+	else
+		clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
+
+#ifdef TIF_SYSCALL_EMU
+	if (request == PTRACE_SYSEMU || request == PTRACE_SYSEMU_SINGLESTEP)
+		set_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+	else
+		clear_tsk_thread_flag(child, TIF_SYSCALL_EMU);
+#endif
+
+	if (is_singlestep(request) || is_sysemu_singlestep(request)) {
+		if (unlikely(!arch_has_single_step()))
+			return -EIO;
+		user_enable_single_step(child);
+	}
+	else
+		user_disable_single_step(child);
+
+	child->exit_code = data;
+	wake_up_process(child);
+
+	return 0;
+}
+
 int ptrace_request(struct task_struct *child, long request,
 		   long addr, long data)
 {
@@ -390,6 +434,23 @@ int ptrace_request(struct task_struct *child, long request,
 	case PTRACE_DETACH:	 /* detach a process that was attached. */
 		ret = ptrace_detach(child, data);
 		break;
+
+#ifdef PTRACE_SINGLESTEP
+	case PTRACE_SINGLESTEP:
+#endif
+#ifdef PTRACE_SYSEMU
+	case PTRACE_SYSEMU:
+	case PTRACE_SYSEMU_SINGLESTEP:
+#endif
+	case PTRACE_SYSCALL:
+	case PTRACE_CONT:
+		return ptrace_resume(child, request, data);
+
+	case PTRACE_KILL:
+		if (child->exit_state)	/* already dead */
+			return 0;
+		return ptrace_resume(child, request, SIGKILL);
+
 	default:
 		break;
 	}

  parent reply	other threads:[~2007-11-25 22:02 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-11-25 21:55 [PATCH 01/27] ptrace: arch_has_single_step Roland McGrath
2007-11-25 21:58 ` [PATCH 02/27] x86: segment selector macros Roland McGrath
2007-11-25 21:58 ` [PATCH 03/27] x86: remove TRAP_FLAG Roland McGrath
2007-11-25 21:59 ` [PATCH 04/27] x86: arch_has_single_step Roland McGrath
2007-11-25 21:59 ` [PATCH 05/27] x86: single_step moved Roland McGrath
2007-11-25 21:59 ` [PATCH 06/27] x86: single_step segment macros Roland McGrath
2007-11-25 22:00 ` [PATCH 07/27] x86: single_step 0xf0 Roland McGrath
2007-11-25 22:00 ` [PATCH 08/27] x86: single_step: share code Roland McGrath
2007-11-25 22:00 ` [PATCH 09/27] x86 single_step: TIF_FORCED_TF Roland McGrath
2007-11-25 22:01 ` Roland McGrath [this message]
2007-11-25 22:23   ` [PATCH 10/27] ptrace: generic resume Christoph Hellwig
2007-11-25 22:37     ` Roland McGrath
2007-11-25 22:01 ` [PATCH 11/27] x86-64: ptrace " Roland McGrath
2007-11-25 22:01 ` [PATCH 12/27] x86-32: " Roland McGrath
2007-11-25 22:03 ` [PATCH 13/27] powerpc: arch_has_single_step Roland McGrath
2007-11-25 22:04 ` [PATCH 14/27] powerpc: ptrace generic resume Roland McGrath
2007-12-03  8:12   ` Srinivasa Ds
2007-11-25 22:04 ` [PATCH 15/27] x86-32 ptrace: use task_pt_regs Roland McGrath
2007-11-25 22:04 ` [PATCH 16/27] x86-64 " Roland McGrath
2007-11-25 22:04 ` [PATCH 17/27] x86-64 ptrace debugreg cleanup Roland McGrath
2007-11-25 22:05 ` [PATCH 18/27] x86-64 ia32 " Roland McGrath
2007-11-25 22:05 ` [PATCH 19/27] x86-32 " Roland McGrath
2007-11-25 22:05 ` [PATCH 20/27] ptrace: arch_has_block_step Roland McGrath
2007-11-28 23:39   ` David Wilder
2007-11-28 23:58     ` Roland McGrath
2007-11-25 22:06 ` [PATCH 21/27] ptrace: generic PTRACE_SINGLEBLOCK Roland McGrath
2007-11-25 22:06 ` [PATCH 22/27] x86: debugctlmsr constants Roland McGrath
2007-11-25 22:08 ` [PATCH 23/27] x86: debugctlmsr kconfig Roland McGrath
2007-11-26  1:09   ` Denys Vlasenko
2007-11-26  7:51     ` Roland McGrath
2007-11-26 22:52       ` Denys Vlasenko
2007-11-26  1:57   ` Dave Jones
2007-11-26  8:06     ` Roland McGrath
2007-11-25 22:08 ` [PATCH 24/27] x86: debugctlmsr context switch Roland McGrath
2007-11-25 22:08 ` [PATCH 25/27] x86: debugctlmsr arch_has_block_step Roland McGrath
2007-11-25 22:08 ` [PATCH 26/27] x86: debugctlmsr kprobes Roland McGrath
2007-11-25 22:08 ` [PATCH 27/27] x86: PTRACE_SINGLEBLOCK Roland McGrath
2007-11-25 22:22 ` [PATCH 01/27] ptrace: arch_has_single_step Christoph Hellwig
2007-11-25 22:59   ` Roland McGrath
2007-11-27  8:53 ` Andrew Morton
2007-11-27 10:38   ` Ingo Molnar
2007-11-27 23:05   ` Roland McGrath
2007-11-27 23:58     ` Ingo Molnar
2007-11-28  0:08       ` Roland McGrath

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=20071125220109.10BC726F8C5@magilla.localdomain \
    --to=roland@redhat.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.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®