From: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
To: Ingo Molnar <mingo@elte.hu>,
akpm@linux-foundation.org,
Frederic Weisbecker <fweisbec@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>,
LKML <linux-kernel@vger.kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>,
Andi Kleen <ak@muc.de>, Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, "H. Peter Anvin" <hpa@zytor.com>
Subject: [RFC patch 19/21] LTTng Linux Kernel Trace Thread Flag x86
Date: Sun, 15 Mar 2009 15:03:59 -0400 [thread overview]
Message-ID: <20090315191105.269978012@polymtl.ca> (raw)
In-Reply-To: 20090315190340.229569867@polymtl.ca
[-- Attachment #1: lttng-kernel-trace-thread-flag-x86.patch --]
[-- Type: text/plain, Size: 3626 bytes --]
Add a thread flag to activate system-wide syscall tracing.
Make x86_64 support TIF_SYSCALL_TRACE async flag set in entry.S
When the flag is inactive upon syscall entry and concurrently activated before
exit, we seem to reach a state where the top of stack is incorrect upon return
to user space.
Fix this by fixing the top of stack and jumping to int_ret_from_sys_call if we
detect that thread flags has been modified.
We make sure that the thread flag read is coherent between our new test and the ALLWORK_MASK test by first saving it in a register used for both comparisons.
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@polymtl.ca>
CC: Andi Kleen <ak@muc.de>
CC: Thomas Gleixner <tglx@linutronix.de>
CC: Ingo Molnar <mingo@redhat.com>
CC: H. Peter Anvin <hpa@zytor.com>
---
arch/x86/include/asm/thread_info.h | 9 ++++++---
arch/x86/kernel/entry_32.S | 3 ++-
2 files changed, 8 insertions(+), 4 deletions(-)
Index: linux-2.6-lttng/arch/x86/include/asm/thread_info.h
===================================================================
--- linux-2.6-lttng.orig/arch/x86/include/asm/thread_info.h 2009-01-14 22:10:38.000000000 -0500
+++ linux-2.6-lttng/arch/x86/include/asm/thread_info.h 2009-01-14 22:25:08.000000000 -0500
@@ -79,6 +79,7 @@ struct thread_info {
#define TIF_SYSCALL_EMU 6 /* syscall emulation active */
#define TIF_SYSCALL_AUDIT 7 /* syscall auditing active */
#define TIF_SECCOMP 8 /* secure computing */
+#define TIF_KERNEL_TRACE 9 /* kernel trace active */
#define TIF_MCE_NOTIFY 10 /* notify userspace of an MCE */
#define TIF_NOTSC 16 /* TSC is not accessible in userland */
#define TIF_IA32 17 /* 32bit process */
@@ -102,6 +103,7 @@ struct thread_info {
#define _TIF_SYSCALL_EMU (1 << TIF_SYSCALL_EMU)
#define _TIF_SYSCALL_AUDIT (1 << TIF_SYSCALL_AUDIT)
#define _TIF_SECCOMP (1 << TIF_SECCOMP)
+#define _TIF_KERNEL_TRACE (1 << TIF_KERNEL_TRACE)
#define _TIF_MCE_NOTIFY (1 << TIF_MCE_NOTIFY)
#define _TIF_NOTSC (1 << TIF_NOTSC)
#define _TIF_IA32 (1 << TIF_IA32)
@@ -117,17 +119,18 @@ struct thread_info {
/* work to do in syscall_trace_enter() */
#define _TIF_WORK_SYSCALL_ENTRY \
- (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_EMU | \
+ (_TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE | _TIF_SYSCALL_EMU | \
_TIF_SYSCALL_AUDIT | _TIF_SECCOMP | _TIF_SINGLESTEP)
/* work to do in syscall_trace_leave() */
#define _TIF_WORK_SYSCALL_EXIT \
- (_TIF_SYSCALL_TRACE | _TIF_SYSCALL_AUDIT | _TIF_SINGLESTEP)
+ (_TIF_SYSCALL_TRACE | _TIF_KERNEL_TRACE | _TIF_SYSCALL_AUDIT | \
+ _TIF_SINGLESTEP)
/* work to do on interrupt/exception return */
#define _TIF_WORK_MASK \
(0x0000FFFF & \
- ~(_TIF_SYSCALL_TRACE|_TIF_SYSCALL_AUDIT| \
+ ~(_TIF_SYSCALL_TRACE|_TIF_KERNEL_TRACE|_TIF_SYSCALL_AUDIT| \
_TIF_SINGLESTEP|_TIF_SECCOMP|_TIF_SYSCALL_EMU))
/* work to do on any return to user space */
Index: linux-2.6-lttng/arch/x86/kernel/entry_32.S
===================================================================
--- linux-2.6-lttng.orig/arch/x86/kernel/entry_32.S 2009-01-14 22:22:40.000000000 -0500
+++ linux-2.6-lttng/arch/x86/kernel/entry_32.S 2009-01-14 22:25:44.000000000 -0500
@@ -571,7 +571,8 @@ END(syscall_trace_entry)
# perform syscall exit tracing
ALIGN
syscall_exit_work:
- testb $_TIF_WORK_SYSCALL_EXIT, %cl
+ /* Note, _TIF_KERNEL_TRACE is bit number 9, and so it needs testw and not testb */
+ testw $_TIF_WORK_SYSCALL_EXIT, %cx
jz work_pending
TRACE_IRQS_ON
ENABLE_INTERRUPTS(CLBR_ANY) # could let syscall_trace_leave() call
--
Mathieu Desnoyers
OpenPGP key fingerprint: 8CD5 52C3 8E3C 4140 715F BA06 3F25 A8FE 3BAE 9A68
next prev parent reply other threads:[~2009-03-15 19:38 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-03-15 19:03 [RFC patch 00/21] TIF_KERNEL_TRACE thread flags Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 01/21] LTTng Kernel Trace Thread Flag Alpha Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 02/21] LTTng Kernel Trace Thread Flag ARM Mathieu Desnoyers
2009-03-15 19:35 ` [RFC patch 02/21] LTTng Kernel Trace Thread Flag ARM fix syscall exit Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 03/21] LTTng Kernel Trace Thread Flag AVR32 Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 04/21] LTTng Kernel Trace Thread Flag Blackfin Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 05/21] LTTng Kernel Trace Thread Flag Cris Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 06/21] LTTng Kernel Trace Thread Flag Frv Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 07/21] LTTng Kernel Trace Thread Flag H8300 Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 08/21] LTTng Kernel Trace Thread Flag ia64 Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 09/21] LTTng Kernel Trace Thread Flag m32r Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 10/21] LTTng Kernel Trace Thread Flag m68k Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 11/21] LTTng Kernel Trace Thread Flag MIPS Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 12/21] LTTng Kernel Trace Thread Flag parisc Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 13/21] LTTng Kernel Trace Thread Flag powerpc Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 14/21] LTTng Kernel Trace Thread Flag s390 Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 15/21] LTTng Kernel Trace Thread Flag SH Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 16/21] LTTng Kernel Trace Thread Flag sparc Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 17/21] LTTng Kernel Trace Thread Flag sparc64 Mathieu Desnoyers
2009-03-15 19:03 ` [RFC patch 18/21] LTTng Kernel Trace Thread Flag UML Mathieu Desnoyers
2009-03-15 19:03 ` Mathieu Desnoyers [this message]
2009-03-15 19:56 ` [RFC patch 19/21] LTTng Linux Kernel Trace Thread Flag x86 Frederic Weisbecker
2009-03-15 20:08 ` Mathieu Desnoyers
2009-03-15 19:04 ` [RFC patch 20/21] LTTng Kernel Trace Thread Flag xtensa Mathieu Desnoyers
2009-03-15 19:04 ` [RFC patch 21/21] LTTng Kernel Trace Thread Flag API Mathieu Desnoyers
2009-03-15 20:03 ` Mathieu Desnoyers
2009-03-15 20:50 ` Frederic Weisbecker
2009-03-15 21:42 ` Mathieu Desnoyers
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=20090315191105.269978012@polymtl.ca \
--to=mathieu.desnoyers@polymtl.ca \
--cc=ak@muc.de \
--cc=akpm@linux-foundation.org \
--cc=fweisbec@gmail.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=mingo@redhat.com \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
/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