From patchwork Thu Oct 24 07:08:07 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: AKASHI Takahiro X-Patchwork-Id: 21242 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f200.google.com (mail-vc0-f200.google.com [209.85.220.200]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F1AC20F5A for ; Thu, 24 Oct 2013 07:09:37 +0000 (UTC) Received: by mail-vc0-f200.google.com with SMTP id ht10sf4040460vcb.7 for ; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=mime-version:x-gm-message-state:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-unsubscribe; bh=0x7Q3dwKXnbQHXVw05Ye6lbUJBN+5U6hlesySkpVsDI=; b=asgZwT6MzA20UnOKnYYqFo4oMdouHQSfzPDG3W96C95n2i8ZSXNQzUvM3OuHxcFY4v KTLI4BQLwh6SUTh3kKn+uZuW+Uaheb/jNF7FXvWZ3ZMQyuBPeLlRVKfriEgjU98Jcpol la6PdFG/ISRyMJtX/o4KPczYa/SedYUa7HHX6CetXHZFXG63bXNsN7x3QeRxna7b0qhE uFExkg5IYRwmjurf2cfuwXOTlXQz5IVW+7l5fZpSq3ACN31ogZ5P7p2kG1BpxVxB5Kzp 5siODzNWAl2TCHaC79UALlbL4K/mcGnur7d4Gf8SzyUtBBSNP3qkzupJEubI59KOHOdb oh/A== X-Received: by 10.58.201.36 with SMTP id jx4mr422807vec.35.1382598576928; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.63.229 with SMTP id j5ls803821qes.25.gmail; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) X-Received: by 10.52.119.198 with SMTP id kw6mr373989vdb.47.1382598576817; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) Received: from mail-vb0-f50.google.com (mail-vb0-f50.google.com [209.85.212.50]) by mx.google.com with ESMTPS id st7si42467vdc.3.2013.10.24.00.09.36 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Oct 2013 00:09:36 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.212.50 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.212.50; Received: by mail-vb0-f50.google.com with SMTP id x14so1183479vbb.23 for ; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) X-Gm-Message-State: ALoCoQkpslI3qCHTLXZNKxymnqhrkSK7XrRfN3fPXBcUCPfgds+eUO8W8Ud0aaIGRVcNDNp9YYje X-Received: by 10.58.108.196 with SMTP id hm4mr621546veb.28.1382598576717; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.220.174.196 with SMTP id u4csp368369vcz; Thu, 24 Oct 2013 00:09:36 -0700 (PDT) X-Received: by 10.66.121.234 with SMTP id ln10mr1819857pab.20.1382598575814; Thu, 24 Oct 2013 00:09:35 -0700 (PDT) Received: from mail-pb0-f46.google.com (mail-pb0-f46.google.com [209.85.160.46]) by mx.google.com with ESMTPS id f10si1074176pac.133.2013.10.24.00.09.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Oct 2013 00:09:35 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.160.46 is neither permitted nor denied by best guess record for domain of takahiro.akashi@linaro.org) client-ip=209.85.160.46; Received: by mail-pb0-f46.google.com with SMTP id un1so2168648pbc.33 for ; Thu, 24 Oct 2013 00:09:35 -0700 (PDT) X-Received: by 10.66.66.42 with SMTP id c10mr1789645pat.98.1382598575351; Thu, 24 Oct 2013 00:09:35 -0700 (PDT) Received: from localhost.localdomain (KD182249089040.au-net.ne.jp. [182.249.89.40]) by mx.google.com with ESMTPSA id go4sm374799pbb.15.2013.10.24.00.09.32 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 24 Oct 2013 00:09:34 -0700 (PDT) From: AKASHI Takahiro To: catalin.marinas@arm.com, will.deacon@arm.com Cc: linaro-kernel@lists.linaro.org, patches@linaro.org, linux-arm-kernel@lists.infradead.org, gkulkarni@caviumnetworks.com, AKASHI Takahiro Subject: [PATCH v2 5/6] arm64: ftrace: Add system call tracepoint Date: Thu, 24 Oct 2013 16:08:07 +0900 Message-Id: <1382598488-13511-6-git-send-email-takahiro.akashi@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1382598488-13511-1-git-send-email-takahiro.akashi@linaro.org> References: <1382598488-13511-1-git-send-email-takahiro.akashi@linaro.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.212.50 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 Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This enables FTRACE_SYSCALLS configuration. Entry and/or exit to any system call can be traced as a ftrace event. Signed-off-by: AKASHI Takahiro --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/syscall.h | 1 + arch/arm64/include/asm/thread_info.h | 1 + arch/arm64/include/asm/unistd.h | 2 ++ arch/arm64/kernel/entry.S | 1 + arch/arm64/kernel/ptrace.c | 10 ++++++++++ 6 files changed, 16 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index 4f4a0dc..f01d84e 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -32,6 +32,7 @@ config ARM64 select HAVE_HW_BREAKPOINT if PERF_EVENTS select HAVE_MEMBLOCK 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/thread_info.h b/arch/arm64/include/asm/thread_info.h index 23a3c47..6f5d977 100644 --- a/arch/arm64/include/asm/thread_info.h +++ b/arch/arm64/include/asm/thread_info.h @@ -107,6 +107,7 @@ static inline struct thread_info *current_thread_info(void) #define TIF_NEED_RESCHED 1 #define TIF_NOTIFY_RESUME 2 /* callback before returning to user */ #define TIF_SYSCALL_TRACE 8 +#define TIF_SYSCALL_TRACEPOINT 10 #define TIF_POLLING_NRFLAG 16 #define TIF_MEMDIE 18 /* is terminating due to OOM killer */ #define TIF_FREEZE 19 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/entry.S b/arch/arm64/kernel/entry.S index 3881fd1..7f81bfe 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S @@ -646,6 +646,7 @@ el0_svc_naked: // compat entry point get_thread_info tsk ldr x16, [tsk, #TI_FLAGS] // check for syscall tracing tbnz x16, #TIF_SYSCALL_TRACE, __sys_trace // are we tracing syscalls? + tbnz x16, #TIF_SYSCALL_TRACEPOINT, __sys_trace adr lr, ret_fast_syscall // return address cmp scno, sc_nr // check upper syscall limit b.hs ni_sys diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index fecdbf7..548baa3 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. @@ -1066,6 +1069,13 @@ asmlinkage int syscall_trace(int dir, struct pt_regs *regs) { unsigned long saved_reg; + if (test_thread_flag(TIF_SYSCALL_TRACEPOINT)) { + if (dir) + trace_sys_exit(regs, regs->syscallno); + else + trace_sys_enter(regs, regs->syscallno); + } + if (!test_thread_flag(TIF_SYSCALL_TRACE)) return regs->syscallno;