From: khilman@linaro.org (Kevin Hilman)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 2/4] ARM: context tracking: instrument system calls
Date: Wed, 20 Mar 2013 17:01:59 -0700 [thread overview]
Message-ID: <1363824121-26169-3-git-send-email-khilman@linaro.org> (raw)
In-Reply-To: <1363824121-26169-1-git-send-email-khilman@linaro.org>
When context tracking (TIF_NOHZ), force the syscall slow path by
adding _TIF_NOHZ to _TIF_SYSCALL_WORK. Use the syscall trace
enter/exit paths to do the context tracking. This corresponds to
commit bf5a3c13 (x86: Syscall hooks for userspace RCU extended QS.)
Also cover the special case in syscall_trace_exit() based on commit
2c5594df (rcu: Fix unrecovered RCU user mode in syscall_trace_leave())
for x86.
Special thanks to Mats Liljegren for collaboration and additional
testing.
Cc: Mats Liljegren <mats.liljegren@enea.com>
Signed-off-by: Kevin Hilman <khilman@linaro.org>
---
arch/arm/include/asm/thread_info.h | 4 +++-
arch/arm/kernel/ptrace.c | 11 +++++++++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index cddda1f..e4c7e21 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -152,6 +152,7 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
#define TIF_SYSCALL_AUDIT 9
#define TIF_SYSCALL_TRACEPOINT 10
#define TIF_SECCOMP 11 /* seccomp syscall filtering active */
+#define TIF_NOHZ 12 /* in adaptive nohz mode */
#define TIF_USING_IWMMXT 17
#define TIF_MEMDIE 18 /* is terminating due to OOM killer */
#define TIF_RESTORE_SIGMASK 20
@@ -165,10 +166,11 @@ extern int vfp_restore_user_hwstate(struct user_vfp __user *,
#define _TIF_SYSCALL_TRACEPOINT (1 << TIF_SYSCALL_TRACEPOINT)
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
#define _TIF_USING_IWMMXT (1 << TIF_USING_IWMMXT)
+#define _TIF_NOHZ (1 << TIF_NOHZ)
/* Checks for any syscall work in entry-common.S */
#define _TIF_SYSCALL_WORK (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | \
- _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP)
+ _TIF_SYSCALL_TRACEPOINT | _TIF_SECCOMP | _TIF_NOHZ)
/*
* Change these and you break ASM code in entry-common.S
diff --git a/arch/arm/kernel/ptrace.c b/arch/arm/kernel/ptrace.c
index 03deeff..3ab329a 100644
--- a/arch/arm/kernel/ptrace.c
+++ b/arch/arm/kernel/ptrace.c
@@ -26,6 +26,7 @@
#include <linux/audit.h>
#include <linux/tracehook.h>
#include <linux/unistd.h>
+#include <linux/context_tracking.h>
#include <asm/pgtable.h>
#include <asm/traps.h>
@@ -941,6 +942,8 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
{
current_thread_info()->syscall = scno;
+ user_exit();
+
/* Do the secure computing check first; failures should be fast. */
if (secure_computing(scno) == -1)
return -1;
@@ -960,6 +963,12 @@ asmlinkage int syscall_trace_enter(struct pt_regs *regs, int scno)
asmlinkage void syscall_trace_exit(struct pt_regs *regs)
{
/*
+ * We may come here right after calling do_work_pending() in
+ * which case we can be in context_tracking user mode.
+ */
+ user_exit();
+
+ /*
* Audit the syscall before anything else, as a debugger may
* come in and change the current registers.
*/
@@ -976,4 +985,6 @@ asmlinkage void syscall_trace_exit(struct pt_regs *regs)
if (test_thread_flag(TIF_SYSCALL_TRACE))
tracehook_report_syscall(regs, PTRACE_SYSCALL_EXIT);
+
+ user_enter();
}
--
1.8.2
next prev parent reply other threads:[~2013-03-21 0:01 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-03-21 0:01 [PATCH 0/4] ARM: add support for context tracking subsystem Kevin Hilman
2013-03-21 0:01 ` [PATCH 1/4] ARM: context tracking: add exception support Kevin Hilman
2013-03-21 21:49 ` Russell King - ARM Linux
2013-03-22 0:33 ` Kevin Hilman
2013-03-26 0:28 ` Kevin Hilman
2013-03-21 0:01 ` Kevin Hilman [this message]
2013-03-21 0:02 ` [PATCH 3/4] ARM: context tracking: handle post exception/syscall/IRQ work Kevin Hilman
2013-03-21 0:02 ` [PATCH 4/4] ARM: Kconfig: allow context tracking Kevin Hilman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1363824121-26169-3-git-send-email-khilman@linaro.org \
--to=khilman@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).