Skip to contentSkip to conversation

tile: move declaration of sys_call_table to <asm/syscall.h>

PATCH In review Simon Marchi 3 participants 9 messages Jan 22, 2013 ptrace support

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 tile: move declaration of sys_call_table to <asm/syscall.h>

When activating syscall tracing, kernel/trace/trace_syscalls.c doesn't find sys_call_table because it includes <asm/syscall.h>, not <asm/syscalls.h>. Also, looking at the other architectures, that is probably where it should be.

---
 arch/tile/include/asm/syscall.h  |    6 ++++++
 arch/tile/include/asm/syscalls.h |    6 ------
 2 files changed, 6 insertions(+), 6 deletions(-)
arch/tile/include/asm/syscall.h +6 -0
index d35e0dc..9644b88 100644
@@ -22,6 +22,12 @@
 #include <linux/err.h>
 #include <arch/abi.h>
 
+/* The array of function pointers for syscalls. */
+extern void *sys_call_table[];
+#ifdef CONFIG_COMPAT
+extern void *compat_sys_call_table[];
+#endif
+
 /*
  * Only the low 32 bits of orig_r0 are meaningful, so we return int.
  * This importantly ignores the high bits on 64-bit, so comparisons
arch/tile/include/asm/syscalls.h +0 -6
index 4c8462a..3b18317 100644
@@ -24,12 +24,6 @@
 #include <linux/types.h>
 #include <linux/compat.h>
 
-/* The array of function pointers for syscalls. */
-extern void *sys_call_table[];
-#ifdef CONFIG_COMPAT
-extern void *compat_sys_call_table[];
-#endif
-
 /*
  * Note that by convention, any syscall which requires the current
  * register set takes an additional "struct pt_regs *" pointer; a
Signature · 1 line
1.7.1
#1 lore raw

PATCH 2/4 tile: Add definition of NR_syscalls

It is required by the syscall tracepoint mechanism.

---
 arch/tile/include/uapi/asm/unistd.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/tile/include/uapi/asm/unistd.h +2 -0
index cd7b6dd..c763c86 100644
@@ -20,6 +20,8 @@
 /* Use the standard ABI for syscalls. */
 #include <asm-generic/unistd.h>
 
+#define NR_syscalls (__NR_syscalls)
+
 /* Additional Tilera-specific syscalls. */
 #define __NR_cacheflush	(__NR_arch_specific_syscall + 1)
 __SYSCALL(__NR_cacheflush, sys_cacheflush)
Signature · 1 line
1.7.1
#2 lore raw

Re: [lttng-dev] [PATCH 2/4] tile: Add definition of NR_syscalls

Quoted 12 lines · * Simon Marchi ([email protected]) wrote:

It is required by the syscall tracepoint mechanism.

---
 arch/tile/include/uapi/asm/unistd.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/tile/include/uapi/asm/unistd.h +0 -0
index cd7b6dd..c763c86 100644

arch/tile/include/uapi/asm/unistd.h line 23

Quoted 4 lines
arch/tile/include/uapi/asm/unistd.h +1 -0
@@ -20,6 +20,8 @@
 /* Use the standard ABI for syscalls. */
 #include <asm-generic/unistd.h>
 
+#define NR_syscalls (__NR_syscalls)

The parenthesis around __NR_syscalls seems unnecessary. (unless parenthesis would happen to be missing around a __NR_syscalls definition with multiple identifiers, but clearly, the parenthesis don't belong here).

Thanks,

Mathieu

Quoted 12 lines
arch/tile/include/uapi/asm/unistd.h +1 -0
+
 /* Additional Tilera-specific syscalls. */
 #define __NR_cacheflush	(__NR_arch_specific_syscall + 1)
 __SYSCALL(__NR_cacheflush, sys_cacheflush)
Signature · 7 lines
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#3 lore raw

Re: [PATCH 2/4] tile: Add definition of NR_syscalls

In reply to Simon Marchi
Quoted 12 lines · * Simon Marchi ([email protected]) wrote:

It is required by the syscall tracepoint mechanism.

---
 arch/tile/include/uapi/asm/unistd.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
arch/tile/include/uapi/asm/unistd.h +0 -0
index cd7b6dd..c763c86 100644

arch/tile/include/uapi/asm/unistd.h line 23

Quoted 4 lines
arch/tile/include/uapi/asm/unistd.h +1 -0
@@ -20,6 +20,8 @@
 /* Use the standard ABI for syscalls. */
 #include <asm-generic/unistd.h>
 
+#define NR_syscalls (__NR_syscalls)

The parenthesis around __NR_syscalls seems unnecessary. (unless parenthesis would happen to be missing around a __NR_syscalls definition with multiple identifiers, but clearly, the parenthesis don't belong here).

Thanks,

Mathieu

Quoted 12 lines
arch/tile/include/uapi/asm/unistd.h +1 -0
+
 /* Additional Tilera-specific syscalls. */
 #define __NR_cacheflush	(__NR_arch_specific_syscall + 1)
 __SYSCALL(__NR_cacheflush, sys_cacheflush)
Signature · 7 lines
1.7.1


_______________________________________________
lttng-dev mailing list
[email protected]
http://lists.lttng.org/cgi-bin/mailman/listinfo/lttng-dev
Signature · 3 lines
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
#4 lore raw

PATCH 3/4 tile: Add support for TIF_SYSCALL_TRACEPOINT

In reply to Simon Marchi

This patch adds support for the TIF_SYSCALL_TRACEPOINT on the tile architecture. Basically, it calls the appropriate tracepoints on syscall entry and exit.

---
 arch/tile/include/asm/thread_info.h |    8 ++++++++
 arch/tile/kernel/intvec_64.S        |   14 ++++++++++----
 arch/tile/kernel/ptrace.c           |   17 ++++++++++++++---
 3 files changed, 32 insertions(+), 7 deletions(-)
arch/tile/include/asm/thread_info.h +8 -0
index e9c670d..c96331e 100644
@@ -124,6 +124,7 @@ extern void _cpu_idle(void);
 #define TIF_SECCOMP		6	/* secure computing */
 #define TIF_MEMDIE		7	/* OOM killer at work */
 #define TIF_NOTIFY_RESUME	8	/* callback before returning to user */
+#define TIF_SYSCALL_TRACEPOINT	9	/* syscall tracepoint instrumentation */
 
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -134,12 +135,19 @@ extern void _cpu_idle(void);
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_MEMDIE		(1<<TIF_MEMDIE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 
 /* Work to do on any return to user space. */
 #define _TIF_ALLWORK_MASK \
   (_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SINGLESTEP|\
    _TIF_ASYNC_TLB|_TIF_NOTIFY_RESUME)
 
+/* Work to do at syscall entry. */
+#define _TIF_SYSCALL_ENTRY_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
+
+/* Work to do at syscall exit. */
+#define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
+
 /*
  * Thread-synchronous status.
  *
arch/tile/kernel/intvec_64.S +10 -4
index fd78cd4..505e6d4 100644
@@ -1000,8 +1000,11 @@ handle_syscall:
 
 	/* Trace syscalls, if requested. */
 	addi	r31, r31, THREAD_INFO_FLAGS_OFFSET
-	ld	r30, r31
-	andi    r30, r30, _TIF_SYSCALL_TRACE
+	{
+	 ld     r30, r31
+	 moveli r32, _TIF_SYSCALL_ENTRY_WORK
+	}
+	and     r30, r30, r32
 	{
 	 addi   r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET
 	 beqzt	r30, .Lrestore_syscall_regs
@@ -1070,8 +1073,11 @@ handle_syscall:
 	FEEDBACK_REENTER(handle_syscall)
 
 	/* Do syscall trace again, if requested. */
-	ld	r30, r31
-	andi    r0, r30, _TIF_SYSCALL_TRACE
+	{
+	 ld      r30, r31
+	 moveli  r32, _TIF_SYSCALL_EXIT_WORK
+	}
+	and      r0, r30, r32
 	{
 	 andi    r0, r30, _TIF_SINGLESTEP
 	 beqzt   r0, 1f
arch/tile/kernel/ptrace.c +14 -3
index 0ab8b76..363b2dd 100644
@@ -25,6 +25,9 @@
 #include <asm/traps.h>
 #include <arch/chip.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 void user_enable_single_step(struct task_struct *child)
 {
 	set_tsk_thread_flag(child, TIF_SINGLESTEP);
@@ -249,16 +252,24 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 int do_syscall_trace_enter(struct pt_regs *regs)
 {
-	if (tracehook_report_syscall_entry(regs)) {
-		regs->regs[TREG_SYSCALL_NR] = -1;
+	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
+		if (tracehook_report_syscall_entry(regs))
+			regs->regs[TREG_SYSCALL_NR] = -1;
 	}
 
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_enter(regs, regs->regs[TREG_SYSCALL_NR]);
+
 	return regs->regs[TREG_SYSCALL_NR];
 }
 
 void do_syscall_trace_exit(struct pt_regs *regs)
 {
-	tracehook_report_syscall_exit(regs, 0);
+	if (test_thread_flag(TIF_SYSCALL_TRACE))
+		tracehook_report_syscall_exit(regs, 0);
+
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_exit(regs, regs->regs[TREG_SYSCALL_NR]);
 }
 
 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
Signature · 1 line
1.7.1
#5 lore raw

PATCH 3/4 tile: Add support for TIF_SYSCALL_TRACEPOINT

In reply to Simon Marchi

This patch adds support for the TIF_SYSCALL_TRACEPOINT on the tile architecture. Basically, it calls the appropriate tracepoints on syscall entry and exit.

---
 arch/tile/include/asm/thread_info.h |    8 ++++++++
 arch/tile/kernel/intvec_64.S        |   14 ++++++++++----
 arch/tile/kernel/ptrace.c           |   17 ++++++++++++++---
 3 files changed, 32 insertions(+), 7 deletions(-)
arch/tile/include/asm/thread_info.h +8 -0
index e9c670d..c96331e 100644
@@ -124,6 +124,7 @@ extern void _cpu_idle(void);
 #define TIF_SECCOMP		6	/* secure computing */
 #define TIF_MEMDIE		7	/* OOM killer at work */
 #define TIF_NOTIFY_RESUME	8	/* callback before returning to user */
+#define TIF_SYSCALL_TRACEPOINT	9	/* syscall tracepoint instrumentation */
 
 #define _TIF_SIGPENDING		(1<<TIF_SIGPENDING)
 #define _TIF_NEED_RESCHED	(1<<TIF_NEED_RESCHED)
@@ -134,12 +135,19 @@ extern void _cpu_idle(void);
 #define _TIF_SECCOMP		(1<<TIF_SECCOMP)
 #define _TIF_MEMDIE		(1<<TIF_MEMDIE)
 #define _TIF_NOTIFY_RESUME	(1<<TIF_NOTIFY_RESUME)
+#define _TIF_SYSCALL_TRACEPOINT	(1<<TIF_SYSCALL_TRACEPOINT)
 
 /* Work to do on any return to user space. */
 #define _TIF_ALLWORK_MASK \
   (_TIF_SIGPENDING|_TIF_NEED_RESCHED|_TIF_SINGLESTEP|\
    _TIF_ASYNC_TLB|_TIF_NOTIFY_RESUME)
 
+/* Work to do at syscall entry. */
+#define _TIF_SYSCALL_ENTRY_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
+
+/* Work to do at syscall exit. */
+#define _TIF_SYSCALL_EXIT_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_TRACEPOINT)
+
 /*
  * Thread-synchronous status.
  *
arch/tile/kernel/intvec_64.S +10 -4
index fd78cd4..505e6d4 100644
@@ -1000,8 +1000,11 @@ handle_syscall:
 
 	/* Trace syscalls, if requested. */
 	addi	r31, r31, THREAD_INFO_FLAGS_OFFSET
-	ld	r30, r31
-	andi    r30, r30, _TIF_SYSCALL_TRACE
+	{
+	 ld     r30, r31
+	 moveli r32, _TIF_SYSCALL_ENTRY_WORK
+	}
+	and     r30, r30, r32
 	{
 	 addi   r30, r31, THREAD_INFO_STATUS_OFFSET - THREAD_INFO_FLAGS_OFFSET
 	 beqzt	r30, .Lrestore_syscall_regs
@@ -1070,8 +1073,11 @@ handle_syscall:
 	FEEDBACK_REENTER(handle_syscall)
 
 	/* Do syscall trace again, if requested. */
-	ld	r30, r31
-	andi    r0, r30, _TIF_SYSCALL_TRACE
+	{
+	 ld      r30, r31
+	 moveli  r32, _TIF_SYSCALL_EXIT_WORK
+	}
+	and      r0, r30, r32
 	{
 	 andi    r0, r30, _TIF_SINGLESTEP
 	 beqzt   r0, 1f
arch/tile/kernel/ptrace.c +14 -3
index 0ab8b76..363b2dd 100644
@@ -25,6 +25,9 @@
 #include <asm/traps.h>
 #include <arch/chip.h>
 
+#define CREATE_TRACE_POINTS
+#include <trace/events/syscalls.h>
+
 void user_enable_single_step(struct task_struct *child)
 {
 	set_tsk_thread_flag(child, TIF_SINGLESTEP);
@@ -249,16 +252,24 @@ long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
 
 int do_syscall_trace_enter(struct pt_regs *regs)
 {
-	if (tracehook_report_syscall_entry(regs)) {
-		regs->regs[TREG_SYSCALL_NR] = -1;
+	if (test_thread_flag(TIF_SYSCALL_TRACE)) {
+		if (tracehook_report_syscall_entry(regs))
+			regs->regs[TREG_SYSCALL_NR] = -1;
 	}
 
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_enter(regs, regs->regs[TREG_SYSCALL_NR]);
+
 	return regs->regs[TREG_SYSCALL_NR];
 }
 
 void do_syscall_trace_exit(struct pt_regs *regs)
 {
-	tracehook_report_syscall_exit(regs, 0);
+	if (test_thread_flag(TIF_SYSCALL_TRACE))
+		tracehook_report_syscall_exit(regs, 0);
+
+	if (test_thread_flag(TIF_SYSCALL_TRACEPOINT))
+		trace_sys_exit(regs, regs->regs[TREG_SYSCALL_NR]);
 }
 
 void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code)
Signature · 1 line
1.7.1
#6 lore raw

PATCH 4/4 tile: select HAVE_SYSCALL_TRACEPOINTS

In reply to Simon Marchi
---
 arch/tile/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/tile/Kconfig +1 -0
index 8cab409..1adb853 100644
@@ -22,6 +22,7 @@ config TILE
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
 	select HAVE_ARCH_TRACEHOOK
+	select HAVE_SYSCALL_TRACEPOINTS
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
Signature · 1 line
1.7.1
#7 lore raw

PATCH 4/4 tile: select HAVE_SYSCALL_TRACEPOINTS

In reply to Simon Marchi
---
 arch/tile/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
arch/tile/Kconfig +1 -0
index 8cab409..1adb853 100644
@@ -22,6 +22,7 @@ config TILE
 	select GENERIC_CLOCKEVENTS
 	select MODULES_USE_ELF_RELA
 	select HAVE_ARCH_TRACEHOOK
+	select HAVE_SYSCALL_TRACEPOINTS
 
 # FIXME: investigate whether we need/want these options.
 #	select HAVE_IOREMAP_PROT
Signature · 1 line
1.7.1
#8 lore raw

Re: [PATCH 4/4] tile: select HAVE_SYSCALL_TRACEPOINTS

Quoted 4 lines · Simon Marchi
---
 arch/tile/Kconfig |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

Thanks!

I took the series of four patches into the tile tree for 3.9 (removing the parentheses around the definition of NR_syscalls).

Signature · 2 lines
Chris Metcalf, Tilera Corp.
http://www.tilera.com