From patchwork Thu Mar 21 00:01:59 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Hilman X-Patchwork-Id: 2310631 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork2.kernel.org (Postfix) with ESMTP id 6533EDF24C for ; Thu, 21 Mar 2013 00:05:18 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UISxy-0005wf-Ps; Thu, 21 Mar 2013 00:02:46 +0000 Received: from mail-pd0-f174.google.com ([209.85.192.174]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UISxQ-0005pC-LA for linux-arm-kernel@lists.infradead.org; Thu, 21 Mar 2013 00:02:14 +0000 Received: by mail-pd0-f174.google.com with SMTP id 10so820198pdi.33 for ; Wed, 20 Mar 2013 17:02:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references:x-gm-message-state; bh=vfnyhGTaUuvYAX0k6eWGged3KdrI4lIz0AkJNIq0PL4=; b=B5A/hOYd8rBYXImpyS+XZlEkf1qv9hjA7rzshLogkZ5hlus6JTYHDwZyRbZbEwjgKB KyIfChdKg5EMELdQB0B3fq+LcULLhRJC/smUkwGFCGrPc98xuPNopNC7iH+RGfugFLzD BDSEPiQS42ASVCid+d55OlzBYjEEp4T1ztXtartP7Z6I1l+WGXZRtxy1RbpxyAoPnTlz qyZlnXMLkJKcoAotV5VB5e3pNozYaiXnXhLCFcl/p0HDyJjTHNDjrSbqnP8ajkaRNQ0h IOJd/oVmyOm9eAYFmTxhtHb/mVNWgdCNcOOibdq9mtlB1MkVkyYIb0UdePbiqMx8N4Y+ IatA== X-Received: by 10.68.91.66 with SMTP id cc2mr12144123pbb.51.1363824130993; Wed, 20 Mar 2013 17:02:10 -0700 (PDT) Received: from localhost (c-24-19-7-36.hsd1.wa.comcast.net. [24.19.7.36]) by mx.google.com with ESMTPS id y1sm3753469pbg.10.2013.03.20.17.02.09 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 20 Mar 2013 17:02:10 -0700 (PDT) From: Kevin Hilman To: Frederic Weisbecker , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH 2/4] ARM: context tracking: instrument system calls Date: Wed, 20 Mar 2013 17:01:59 -0700 Message-Id: <1363824121-26169-3-git-send-email-khilman@linaro.org> X-Mailer: git-send-email 1.8.2 In-Reply-To: <1363824121-26169-1-git-send-email-khilman@linaro.org> References: <1363824121-26169-1-git-send-email-khilman@linaro.org> X-Gm-Message-State: ALoCoQkdp9HmwGXSHtG/E0FICrfs8My32Z8qHLacj3nPsQjEhBONl36wrzR0gsEUGZvtxhmGiQ6R X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130320_200212_910887_435462B1 X-CRM114-Status: GOOD ( 14.79 ) X-Spam-Score: -1.9 (-) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-1.9 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [209.85.192.174 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Mats Liljegren , Paul McKenney , linaro-kernel@lists.linaro.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.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 Signed-off-by: Kevin Hilman --- 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 #include #include +#include #include #include @@ -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(); }