From patchwork Fri Feb 28 05:18:42 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 25508 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ve0-f199.google.com (mail-ve0-f199.google.com [209.85.128.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id D2B4A2055D for ; Fri, 28 Feb 2014 05:20:22 +0000 (UTC) Received: by mail-ve0-f199.google.com with SMTP id jy13sf521080veb.2 for ; Thu, 27 Feb 2014 21:20:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=r6Ytj4LauZ9ENh6O6XO6HIA31uxR7KriNOYJY0arZyg=; b=mfaV2SV/x+hslTeGPuuXaWzTVWuMSgzPA1nOt+HGM5cObxaMKm6gKpRBXRUttRDDa1 2LuKVHOgZQPkknoEG3WxsWmIyJP1H8CWQpQGBsH5E1F8cCbN6JUmIkv+8R7dQNX91mAm pYsnlzNduU8Hj53GpK96eaoxLbUIwONewNYMir9xqsWaBhcYsSVjJItbUfRreNQCmBEA oBe3tuGF2LQs+jzXChdC19Wtq3DIs19gvxBGNGluSR2HU/b+tQaiUmB0uqMVhqOBU5Dz EgutzNyr2r2Co2WNBvSs4k4uBg38RYzfHwYFh9aXVPkRC5lKtjVJT20fXnJHeedYsDxB ddCw== X-Gm-Message-State: ALoCoQlSXLUeg6G2l1O16C2kniaZry0LLEuxRGIAxpLCZBl/KZFsKwjN3gaCGiU9Fgp+AzpAR5/Y X-Received: by 10.236.94.166 with SMTP id n26mr280935yhf.25.1393564822626; Thu, 27 Feb 2014 21:20:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.18.166 with SMTP id 35ls954555qgf.3.gmail; Thu, 27 Feb 2014 21:20:22 -0800 (PST) X-Received: by 10.52.68.106 with SMTP id v10mr267873vdt.59.1393564822458; Thu, 27 Feb 2014 21:20:22 -0800 (PST) Received: from mail-vc0-f179.google.com (mail-vc0-f179.google.com [209.85.220.179]) by mx.google.com with ESMTPS id e10si1233671vcq.2.2014.02.27.21.20.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Feb 2014 21:20:22 -0800 (PST) Received-SPF: neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.179; Received: by mail-vc0-f179.google.com with SMTP id lh14so232589vcb.24 for ; Thu, 27 Feb 2014 21:20:22 -0800 (PST) X-Received: by 10.52.27.132 with SMTP id t4mr11868265vdg.11.1393564822341; Thu, 27 Feb 2014 21:20:22 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.130.193 with SMTP id u1csp28937vcs; Thu, 27 Feb 2014 21:20:21 -0800 (PST) X-Received: by 10.66.146.229 with SMTP id tf5mr1296111pab.50.1393564821318; Thu, 27 Feb 2014 21:20:21 -0800 (PST) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id tt8si592312pbc.340.2014.02.27.21.20.20; Thu, 27 Feb 2014 21:20:20 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752103AbaB1FUL (ORCPT + 26 others); Fri, 28 Feb 2014 00:20:11 -0500 Received: from mail-pb0-f43.google.com ([209.85.160.43]:54398 "EHLO mail-pb0-f43.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750835AbaB1FUG (ORCPT ); Fri, 28 Feb 2014 00:20:06 -0500 Received: by mail-pb0-f43.google.com with SMTP id um1so272723pbc.2 for ; Thu, 27 Feb 2014 21:20:06 -0800 (PST) X-Received: by 10.68.237.228 with SMTP id vf4mr1108414pbc.131.1393564806446; Thu, 27 Feb 2014 21:20:06 -0800 (PST) Received: from localhost.localdomain (KD182249084248.au-net.ne.jp. [182.249.84.248]) by mx.google.com with ESMTPSA id vn10sm1790978pbc.21.2014.02.27.21.20.00 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 27 Feb 2014 21:20:05 -0800 (PST) From: AKASHI Takahiro To: rostedt@goodmis.org, fweisbec@gmail.com, mingo@redhat.com, catalin.marinas@arm.com, will.deacon@arm.com, tim.bird@sonymobile.com Cc: gkulkarni@caviumnetworks.com, dsaxena@linaro.org, arndb@arndb.de, linux-arm-kernel@lists.infradead.org, linaro-kernel@lists.linaro.org, linux-kernel@vger.kernel.org, AKASHI Takahiro Subject: [PATCH v5 5/7] arm64: ftrace: Add system call tracepoint Date: Fri, 28 Feb 2014 14:18:42 +0900 Message-Id: <1393564724-3966-6-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393564724-3966-1-git-send-email-takahiro.akashi@linaro.org> References: <1393320196-2942-1-git-send-email-takahiro.akashi@linaro.org> <1393564724-3966-1-git-send-email-takahiro.akashi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: takahiro.akashi@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.179 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This patch allows system call entry or exit to be traced as ftrace events, ie. sys_enter_*/sys_exit_*, if CONFIG_FTRACE_SYSCALLS is enabled. Those events appear and can be controlled under ${sysfs}/tracing/events/syscalls/ Signed-off-by: AKASHI Takahiro --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 1 + arch/arm64/include/asm/unistd.h | 2 ++ arch/arm64/kernel/ptrace.c | 52 ++++++++++++++++++++++---------------- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 6954959..b1dcdb4 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -43,6 +43,7 @@ config ARM64 select HAVE_MEMBLOCK select HAVE_PATA_PLATFORM select HAVE_PERF_EVENTS + select HAVE_SYSCALL_TRACEPOINTS select IRQ_DOMAIN select MODULES_USE_ELF_RELA select NO_BOOTMEM diff --git a/arch/arm64/include/asm/syscall.h b/arch/arm64/include/asm/syscall.h index 70ba9d4..383771e 100644 --- a/arch/arm64/include/asm/syscall.h +++ b/arch/arm64/include/asm/syscall.h @@ -18,6 +18,7 @@ #include +extern const void *sys_call_table[]; static inline int syscall_get_nr(struct task_struct *task, struct pt_regs *regs) diff --git a/arch/arm64/include/asm/unistd.h b/arch/arm64/include/asm/unistd.h index 82ce217..c335479 100644 --- a/arch/arm64/include/asm/unistd.h +++ b/arch/arm64/include/asm/unistd.h @@ -28,3 +28,5 @@ #endif #define __ARCH_WANT_SYS_CLONE #include + +#define NR_syscalls (__NR_syscalls) diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 6a8928b..dc90f9f 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -41,6 +41,9 @@ #include #include +#define CREATE_TRACE_POINTS +#include + /* * TODO: does not yet catch signals sent when the child dies. * in exit.c or in signal.c. @@ -1062,31 +1065,36 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) { unsigned long saved_reg; - if (!test_thread_flag(TIF_SYSCALL_TRACE)) - return regs->syscallno; + if (dir && unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) + trace_sys_exit(regs, regs_return_value(regs)); + + if (test_thread_flag(TIF_SYSCALL_TRACE)) { + if (is_compat_task()) { + /* AArch32 uses ip (r12) for scratch */ + saved_reg = regs->regs[12]; + regs->regs[12] = dir; + } else { + /* + * Save X7. X7 is used to denote syscall entry/exit: + * X7 = 0 -> entry, = 1 -> exit + */ + saved_reg = regs->regs[7]; + regs->regs[7] = dir; + } - if (is_compat_task()) { - /* AArch32 uses ip (r12) for scratch */ - saved_reg = regs->regs[12]; - regs->regs[12] = dir; - } else { - /* - * Save X7. X7 is used to denote syscall entry/exit: - * X7 = 0 -> entry, = 1 -> exit - */ - saved_reg = regs->regs[7]; - regs->regs[7] = dir; - } + if (dir) + tracehook_report_syscall_exit(regs, 0); + else if (tracehook_report_syscall_entry(regs)) + regs->syscallno = ~0UL; - if (dir) - tracehook_report_syscall_exit(regs, 0); - else if (tracehook_report_syscall_entry(regs)) - regs->syscallno = ~0UL; + if (is_compat_task()) + regs->regs[12] = saved_reg; + else + regs->regs[7] = saved_reg; + } - if (is_compat_task()) - regs->regs[12] = saved_reg; - else - regs->regs[7] = saved_reg; + if (!dir && unlikely(test_thread_flag(TIF_SYSCALL_TRACEPOINT))) + trace_sys_enter(regs, regs->syscallno); return regs->syscallno; }