From ef18272453c97238fc9a89211d4c609ef9c760dc Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Sat, 22 Dec 2012 00:21:10 -0500 Subject: arch/tile: Call tracehook_report_syscall_{entry,exit} in syscall trace 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 Signed-off-by: Chris Metcalf [with ptrace.h fixup] --- arch/tile/include/asm/ptrace.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'arch/tile/include') diff --git a/arch/tile/include/asm/ptrace.h b/arch/tile/include/asm/ptrace.h index 2e83fc1b946..fd412260aff 100644 --- a/arch/tile/include/asm/ptrace.h +++ b/arch/tile/include/asm/ptrace.h @@ -44,7 +44,8 @@ typedef unsigned long pt_reg_t; struct pt_regs *get_pt_regs(struct pt_regs *); /* Trace the current syscall. */ -extern void do_syscall_trace(void); +extern int do_syscall_trace_enter(struct pt_regs *regs); +extern void do_syscall_trace_exit(struct pt_regs *regs); #define arch_has_single_step() (1) -- cgit v1.2.3-70-g09d2 From e2ed522aaad79db339cecbbc4ae2a0d422ee4c4f Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 21 Jan 2013 19:54:55 -0500 Subject: tile: move declaration of sys_call_table to When activating syscall tracing, kernel/trace/trace_syscalls.c doesn't find sys_call_table because it includes , not . Also, looking at the other architectures, that is probably where it should be. Signed-off-by: Simon Marchi Signed-off-by: Chris Metcalf --- arch/tile/include/asm/syscall.h | 6 ++++++ arch/tile/include/asm/syscalls.h | 6 ------ 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'arch/tile/include') diff --git a/arch/tile/include/asm/syscall.h b/arch/tile/include/asm/syscall.h index d35e0dcb67b..9644b88f133 100644 --- a/arch/tile/include/asm/syscall.h +++ b/arch/tile/include/asm/syscall.h @@ -22,6 +22,12 @@ #include #include +/* 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 diff --git a/arch/tile/include/asm/syscalls.h b/arch/tile/include/asm/syscalls.h index 78886e2417a..07b298450ef 100644 --- a/arch/tile/include/asm/syscalls.h +++ b/arch/tile/include/asm/syscalls.h @@ -24,12 +24,6 @@ #include #include -/* 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 -- cgit v1.2.3-70-g09d2 From 6e4a2f7f94cbac4e1f111f604ccf57dcbdef0a81 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 21 Jan 2013 19:54:56 -0500 Subject: tile: Add definition of NR_syscalls It is required by the syscall tracepoint mechanism. Signed-off-by: Simon Marchi Signed-off-by: Chris Metcalf --- arch/tile/include/uapi/asm/unistd.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'arch/tile/include') diff --git a/arch/tile/include/uapi/asm/unistd.h b/arch/tile/include/uapi/asm/unistd.h index cd7b6dd9d47..3866397aaf5 100644 --- a/arch/tile/include/uapi/asm/unistd.h +++ b/arch/tile/include/uapi/asm/unistd.h @@ -20,6 +20,8 @@ /* Use the standard ABI for syscalls. */ #include +#define NR_syscalls __NR_syscalls + /* Additional Tilera-specific syscalls. */ #define __NR_cacheflush (__NR_arch_specific_syscall + 1) __SYSCALL(__NR_cacheflush, sys_cacheflush) -- cgit v1.2.3-70-g09d2 From ef567f25d5d9d803b89bc2aec6bb71fe8b4bebd9 Mon Sep 17 00:00:00 2001 From: Simon Marchi Date: Mon, 21 Jan 2013 19:54:57 -0500 Subject: tile: support TIF_SYSCALL_TRACEPOINT; select HAVE_SYSCALL_TRACEPOINTS This patch adds support for the TIF_SYSCALL_TRACEPOINT on the tile architecture. Basically, it calls the appropriate tracepoints on syscall entry and exit. Signed-off-by: Simon Marchi Signed-off-by: Chris Metcalf --- arch/tile/Kconfig | 1 + arch/tile/include/asm/thread_info.h | 8 ++++++++ arch/tile/kernel/intvec_64.S | 14 ++++++++++---- arch/tile/kernel/ptrace.c | 17 ++++++++++++++--- 4 files changed, 33 insertions(+), 7 deletions(-) (limited to 'arch/tile/include') diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index e911ef638b7..0e500d90c2a 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -23,6 +23,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 diff --git a/arch/tile/include/asm/thread_info.h b/arch/tile/include/asm/thread_info.h index e9c670d7a7f..c96331eb577 100644 --- a/arch/tile/include/asm/thread_info.h +++ b/arch/tile/include/asm/thread_info.h @@ -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< #include +#define CREATE_TRACE_POINTS +#include + 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) -- cgit v1.2.3-70-g09d2 From adf6d9b30f089c52e674e84ca2960581e504e5e3 Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Fri, 1 Feb 2013 12:37:48 -0500 Subject: tile: support atomic64_dec_if_positive() Use the normal cmpxchg() idiom to implement this functionality. Signed-off-by: Chris Metcalf --- arch/tile/Kconfig | 1 + arch/tile/include/asm/atomic.h | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) (limited to 'arch/tile/include') diff --git a/arch/tile/Kconfig b/arch/tile/Kconfig index 0e500d90c2a..9a9d08637ab 100644 --- a/arch/tile/Kconfig +++ b/arch/tile/Kconfig @@ -24,6 +24,7 @@ config TILE select MODULES_USE_ELF_RELA select HAVE_ARCH_TRACEHOOK select HAVE_SYSCALL_TRACEPOINTS + select ARCH_HAS_ATOMIC64_DEC_IF_POSITIVE # FIXME: investigate whether we need/want these options. # select HAVE_IOREMAP_PROT diff --git a/arch/tile/include/asm/atomic.h b/arch/tile/include/asm/atomic.h index f2461429a4a..e71387ab20c 100644 --- a/arch/tile/include/asm/atomic.h +++ b/arch/tile/include/asm/atomic.h @@ -131,4 +131,25 @@ static inline int atomic_read(const atomic_t *v) #include #endif +#ifndef __ASSEMBLY__ + +static inline long long atomic64_dec_if_positive(atomic64_t *v) +{ + long long c, old, dec; + + c = atomic64_read(v); + for (;;) { + dec = c - 1; + if (unlikely(dec < 0)) + break; + old = atomic64_cmpxchg((v), c, dec); + if (likely(old == c)) + break; + c = old; + } + return dec; +} + +#endif /* __ASSEMBLY__ */ + #endif /* _ASM_TILE_ATOMIC_H */ -- cgit v1.2.3-70-g09d2 From ffae3d0e3606b2e274c9ec1b969342d630b2ecae Mon Sep 17 00:00:00 2001 From: Chris Metcalf Date: Tue, 9 Apr 2013 12:33:07 -0400 Subject: tile: comment assumption about __insn_mtspr for The arch_local_irq_save(), etc., routines are required to function as compiler barriers. They do, but it's subtle and requires knowing that the gcc builtin __insn_mtspr() is marked as a memory clobber. Provide a comment explaining the assumption. Signed-off-by: Chris Metcalf --- arch/tile/include/asm/irqflags.h | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'arch/tile/include') diff --git a/arch/tile/include/asm/irqflags.h b/arch/tile/include/asm/irqflags.h index 241c0bb60b1..c96f9bbb760 100644 --- a/arch/tile/include/asm/irqflags.h +++ b/arch/tile/include/asm/irqflags.h @@ -40,7 +40,15 @@ #include #include -/* Set and clear kernel interrupt masks. */ +/* + * Set and clear kernel interrupt masks. + * + * NOTE: __insn_mtspr() is a compiler builtin marked as a memory + * clobber. We rely on it being equivalent to a compiler barrier in + * this code since arch_local_irq_save() and friends must act as + * compiler barriers. This compiler semantic is baked into enough + * places that the compiler will maintain it going forward. + */ #if CHIP_HAS_SPLIT_INTR_MASK() #if INT_PERF_COUNT < 32 || INT_AUX_PERF_COUNT < 32 || INT_MEM_ERROR >= 32 # error Fix assumptions about which word various interrupts are in -- cgit v1.2.3-70-g09d2