public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace
@ 2012-12-22  5:21 Simon Marchi
  2012-12-22  5:21 ` [PATCH 2/3] arch/tile: Implement user_stack_pointer Simon Marchi
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Simon Marchi @ 2012-12-22  5:21 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

Call tracehook functions for syscall tracing.

The check for TIF_SYSCALL_TRACE was removed, because the same check is
done right before in the assembly file.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
 arch/tile/kernel/intvec_32.S |    6 ++++--
 arch/tile/kernel/intvec_64.S |    6 ++++--
 arch/tile/kernel/ptrace.c    |   30 ++++++++++--------------------
 3 files changed, 18 insertions(+), 24 deletions(-)

diff --git a/arch/tile/kernel/intvec_32.S b/arch/tile/kernel/intvec_32.S
index 6943515..6c3f597 100644
--- a/arch/tile/kernel/intvec_32.S
+++ b/arch/tile/kernel/intvec_32.S
@@ -1201,7 +1201,8 @@ handle_syscall:
 	lw	r30, r31
 	andi    r30, r30, _TIF_SYSCALL_TRACE
 	bzt	r30, .Lrestore_syscall_regs
-	jal	do_syscall_trace
+	PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
+	jal	do_syscall_trace_enter
 	FEEDBACK_REENTER(handle_syscall)
 
 	/*
@@ -1252,7 +1253,8 @@ handle_syscall:
 	lw	r30, r31
 	andi    r30, r30, _TIF_SYSCALL_TRACE
 	bzt     r30, 1f
-	jal	do_syscall_trace
+	PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
+	jal	do_syscall_trace_exit
 	FEEDBACK_REENTER(handle_syscall)
 1:	{
 	 movei  r30, 0               /* not an NMI */
diff --git a/arch/tile/kernel/intvec_64.S b/arch/tile/kernel/intvec_64.S
index 7c06d59..a717279 100644
--- a/arch/tile/kernel/intvec_64.S
+++ b/arch/tile/kernel/intvec_64.S
@@ -1006,7 +1006,8 @@ handle_syscall:
 	 addi   r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET
 	 beqzt	r30, .Lrestore_syscall_regs
 	}
-	jal	do_syscall_trace
+	PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
+	jal	do_syscall_trace_enter
 	FEEDBACK_REENTER(handle_syscall)
 
 	/*
@@ -1075,7 +1076,8 @@ handle_syscall:
 	 andi    r0, r30, _TIF_SINGLESTEP
 	 beqzt   r0, 1f
 	}
-	jal	do_syscall_trace
+	PTREGS_PTR(r0, PTREGS_OFFSET_BASE)
+	jal	do_syscall_trace_exit
 	FEEDBACK_REENTER(handle_syscall)
 	andi    r0, r30, _TIF_SINGLESTEP
 
diff --git a/arch/tile/kernel/ptrace.c b/arch/tile/kernel/ptrace.c
index 9835312..0ab8b76 100644
--- a/arch/tile/kernel/ptrace.c
+++ b/arch/tile/kernel/ptrace.c
@@ -21,6 +21,7 @@
 #include <linux/uaccess.h>
 #include <linux/regset.h>
 #include <linux/elf.h>
+#include <linux/tracehook.h>
 #include <asm/traps.h>
 #include <arch/chip.h>
 
@@ -246,29 +247,18 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 }
 #endif
 
-void do_syscall_trace(void)
+int do_syscall_trace_enter(struct pt_regs *regs)
 {
-	if (!test_thread_flag(TIF_SYSCALL_TRACE))
-		return;
-
-	if (!(current->ptrace & PT_PTRACED))
-		return;
+	if (tracehook_report_syscall_entry(regs)) {
+		regs->regs[TREG_SYSCALL_NR] = -1;
+	}
 
-	/*
-	 * The 0x80 provides a way for the tracing parent to distinguish
-	 * between a syscall stop and SIGTRAP delivery
-	 */
-	ptrace_notify(SIGTRAP|((current->ptrace & PT_TRACESYSGOOD) ? 0x80 : 0));
+	return regs->regs[TREG_SYSCALL_NR];
+}
 
-	/*
-	 * this isn't the same as continuing with a signal, but it will do
-	 * for normal use.  strace only continues with a signal if the
-	 * stopping signal is not SIGTRAP.  -brl
-	 */
-	if (current->exit_code) {
-		send_sig(current->exit_code, current, 1);
-		current->exit_code = 0;
-	}
+void do_syscall_trace_exit(struct pt_regs *regs)
+{
+	tracehook_report_syscall_exit(regs, 0);
 }
 
 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/3] arch/tile: Implement user_stack_pointer
  2012-12-22  5:21 [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Simon Marchi
@ 2012-12-22  5:21 ` Simon Marchi
  2012-12-22  6:03   ` Al Viro
  2012-12-22  5:21 ` [PATCH 3/3] arch/tile: Enable HAVE_ARCH_TRACEHOOK Simon Marchi
  2012-12-26 18:42 ` [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Chris Metcalf
  2 siblings, 1 reply; 5+ messages in thread
From: Simon Marchi @ 2012-12-22  5:21 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

It is needed when we turn on HAVE_ARCH_TRACEHOOK.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
 arch/tile/include/asm/ptrace.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h
index 5ce052e..4be42fb 100644
--- a/arch/tile/include/asm/ptrace.h
+++ b/arch/tile/include/asm/ptrace.h
@@ -80,6 +80,11 @@ struct task_struct;
 extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs,
 			 int error_code);
 
+static inline unsigned long user_stack_pointer(struct pt_regs *regs)
+{
+	return regs->sp;
+}
+
 #ifdef __tilegx__
 /* We need this since sigval_t has a user pointer in it, for GETSIGINFO etc. */
 #define __ARCH_WANT_COMPAT_SYS_PTRACE
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/3] arch/tile: Enable HAVE_ARCH_TRACEHOOK
  2012-12-22  5:21 [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Simon Marchi
  2012-12-22  5:21 ` [PATCH 2/3] arch/tile: Implement user_stack_pointer Simon Marchi
@ 2012-12-22  5:21 ` Simon Marchi
  2012-12-26 18:42 ` [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Chris Metcalf
  2 siblings, 0 replies; 5+ messages in thread
From: Simon Marchi @ 2012-12-22  5:21 UTC (permalink / raw)
  To: cmetcalf; +Cc: linux-kernel, Simon Marchi

Looks like we have everything needed for that.

Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
---
 arch/tile/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig
index 875d008..8cab409 100644
--- a/arch/tile/Kconfig
+++ b/arch/tile/Kconfig
@@ -21,6 +21,7 @@ config TILE
 	select ARCH_HAVE_NMI_SAFE_CMPXCHG
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
+	select HAVE_ARCH_TRACEHOOK
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 2/3] arch/tile: Implement user_stack_pointer
  2012-12-22  5:21 ` [PATCH 2/3] arch/tile: Implement user_stack_pointer Simon Marchi
@ 2012-12-22  6:03   ` Al Viro
  0 siblings, 0 replies; 5+ messages in thread
From: Al Viro @ 2012-12-22  6:03 UTC (permalink / raw)
  To: Simon Marchi; +Cc: cmetcalf, linux-kernel

On Sat, Dec 22, 2012 at 12:21:11AM -0500, Simon Marchi wrote:
> It is needed when we turn on HAVE_ARCH_TRACEHOOK.

... and if you check the mainline, you'll see it (and other missing
user_stack_pointer() instances) already in place, as part of infrastructure
for sigaltstack series.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace
  2012-12-22  5:21 [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Simon Marchi
  2012-12-22  5:21 ` [PATCH 2/3] arch/tile: Implement user_stack_pointer Simon Marchi
  2012-12-22  5:21 ` [PATCH 3/3] arch/tile: Enable HAVE_ARCH_TRACEHOOK Simon Marchi
@ 2012-12-26 18:42 ` Chris Metcalf
  2 siblings, 0 replies; 5+ messages in thread
From: Chris Metcalf @ 2012-12-26 18:42 UTC (permalink / raw)
  To: Simon Marchi; +Cc: linux-kernel

On 12/22/2012 12:21 AM, Simon Marchi wrote:
> Call tracehook functions for syscall tracing.
>
> The check for TIF_SYSCALL_TRACE was removed, because the same check is
> done right before in the assembly file.
>
> Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca>
>

I've taken this one, and patch 3/3 in this series, into the tile tree (and pushed it up to linux-next).  I fixed up ptrace.h to adjust the declarations for the modified functions.

As Al Viro pointed out, patch 2/3 is already present in v3.8-rc1.

Thanks!

-- 
Chris Metcalf, Tilera Corp.
http://www.tilera.com


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-12-26 18:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-12-22  5:21 [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Simon Marchi
2012-12-22  5:21 ` [PATCH 2/3] arch/tile: Implement user_stack_pointer Simon Marchi
2012-12-22  6:03   ` Al Viro
2012-12-22  5:21 ` [PATCH 3/3] arch/tile: Enable HAVE_ARCH_TRACEHOOK Simon Marchi
2012-12-26 18:42 ` [PATCH 1/3] arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace Chris Metcalf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox