Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932407AbcJNIgP (ORCPT ); Fri, 14 Oct 2016 04:36:15 -0400 Received: from mailapp02.imgtec.com ([217.156.133.132]:60087 "EHLO mailapp01.imgtec.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752435AbcJNIfg (ORCPT ); Fri, 14 Oct 2016 04:35:36 -0400 From: Marcin Nowakowski To: CC: , , , Marcin Nowakowski , Ingo Molnar , Thomas Gleixner , "H. Peter Anvin" , Subject: [PATCH v4 06/12] x86/tracing: fix compat syscall handling Date: Fri, 14 Oct 2016 10:35:09 +0200 Message-ID: <1476434115-25428-8-git-send-email-marcin.nowakowski@imgtec.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1476434115-25428-1-git-send-email-marcin.nowakowski@imgtec.com> References: <1476434115-25428-1-git-send-email-marcin.nowakowski@imgtec.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.80.2.5] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 3472 Lines: 104 Adapt the arch-specific code to new syscall tracing interface: arch_trace_is_compat_syscall() now only indicates if a syscall is ia32, as x32 syscalls exist in the same syscall table as native 64 bit ones, so should not be treated as compat ones Add arch_trace_syscall_get_nr that removes the x32 bit from syscall numbers. Signed-off-by: Marcin Nowakowski Cc: Steven Rostedt Cc: Ingo Molnar Cc: Thomas Gleixner Cc: "H. Peter Anvin" Cc: x86@kernel.org --- arch/x86/include/asm/ftrace.h | 14 ++------------ arch/x86/include/asm/syscall.h | 9 +++++++++ arch/x86/kernel/ftrace.c | 23 +++++++++++++++++++++++ 3 files changed, 34 insertions(+), 12 deletions(-) diff --git a/arch/x86/include/asm/ftrace.h b/arch/x86/include/asm/ftrace.h index eccd0ac..69f1674 100644 --- a/arch/x86/include/asm/ftrace.h +++ b/arch/x86/include/asm/ftrace.h @@ -50,20 +50,10 @@ int ftrace_int3_handler(struct pt_regs *regs); #if defined(CONFIG_FTRACE_SYSCALLS) && defined(CONFIG_IA32_EMULATION) #include -/* - * Because ia32 syscalls do not map to x86_64 syscall numbers - * this screws up the trace output when tracing a ia32 task. - * Instead of reporting bogus syscalls, just do not trace them. - * - * If the user really wants these, then they should use the - * raw syscall tracepoints with filtering. - */ -#define ARCH_TRACE_IGNORE_COMPAT_SYSCALLS 1 +#define ARCH_COMPAT_SYSCALL_NUMBERS_OVERLAP 1 static inline bool arch_trace_is_compat_syscall(struct pt_regs *regs) { - if (in_compat_syscall()) - return true; - return false; + return in_ia32_syscall(); } #endif /* CONFIG_FTRACE_SYSCALLS && CONFIG_IA32_EMULATION */ #endif /* !__ASSEMBLY__ && !COMPILE_OFFSETS */ diff --git a/arch/x86/include/asm/syscall.h b/arch/x86/include/asm/syscall.h index e3c95e8..732b5ab 100644 --- a/arch/x86/include/asm/syscall.h +++ b/arch/x86/include/asm/syscall.h @@ -239,4 +239,13 @@ static inline int syscall_get_arch(void) } #endif /* CONFIG_X86_32 */ +#ifdef CONFIG_FTRACE_SYSCALLS +static inline +int arch_trace_syscall_get_nr(struct task_struct *task, struct pt_regs *regs) +{ + return syscall_get_nr(task, regs) & __SYSCALL_MASK; +} +#define arch_trace_syscall_get_nr arch_trace_syscall_get_nr +#endif /* CONFIG_FTRACE_SYSCALLS */ + #endif /* _ASM_X86_SYSCALL_H */ diff --git a/arch/x86/kernel/ftrace.c b/arch/x86/kernel/ftrace.c index 8639bb2..38032fc 100644 --- a/arch/x86/kernel/ftrace.c +++ b/arch/x86/kernel/ftrace.c @@ -28,6 +28,7 @@ #include #include #include +#include #ifdef CONFIG_DYNAMIC_FTRACE @@ -1035,3 +1036,25 @@ void prepare_ftrace_return(unsigned long self_addr, unsigned long *parent, } } #endif /* CONFIG_FUNCTION_GRAPH_TRACER */ + +#ifdef CONFIG_FTRACE_SYSCALLS +#if defined(CONFIG_X86_64) && defined(CONFIG_IA32_EMULATION) +/* + * Because ia32 syscalls do not map to x86_64 syscall numbers + * we need to choose the right syscall table depending on the + * compat flag. + * + * Alternatively, it is also possible to use the raw syscall + * tracepoints with filtering. + */ + +unsigned long __init arch_syscall_addr(int nr, bool compat) +{ + if (compat) + return (unsigned long)ia32_sys_call_table[nr]; + + return (unsigned long)sys_call_table[nr]; +} + +#endif /* CONFIG_X86_64 && CONFIG_IA32_EMULATION */ +#endif /* CONFIG_FTRACE_SYSCALLS */ -- 2.7.4