diff options
author | Andy Lutomirski <luto@kernel.org> | 2015-10-05 20:48:22 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-10-09 03:41:12 -0400 |
commit | dd636071c3d8044c802b7a365e9934724a929530 (patch) | |
tree | 66106b8b51760d5bbb51bc0fa7d5b27202aa738b | |
parent | 4aabd140f9cbe0361401a1368bac74df1010abf5 (diff) |
x86/entry: Use pt_regs_to_thread_info() in syscall entry tracing
It generates simpler and faster code than current_thread_info().
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: linux-kernel@vger.kernel.org
Link: http://lkml.kernel.org/r/a3b6633e7dcb9f673c1b619afae602d29d27d2cf.1444091585.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/entry/common.c | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 778ca70c22dd..d0874210d5b5 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c | |||
@@ -30,6 +30,13 @@ | |||
30 | #define CREATE_TRACE_POINTS | 30 | #define CREATE_TRACE_POINTS |
31 | #include <trace/events/syscalls.h> | 31 | #include <trace/events/syscalls.h> |
32 | 32 | ||
33 | static struct thread_info *pt_regs_to_thread_info(struct pt_regs *regs) | ||
34 | { | ||
35 | unsigned long top_of_stack = | ||
36 | (unsigned long)(regs + 1) + TOP_OF_KERNEL_STACK_PADDING; | ||
37 | return (struct thread_info *)(top_of_stack - THREAD_SIZE); | ||
38 | } | ||
39 | |||
33 | #ifdef CONFIG_CONTEXT_TRACKING | 40 | #ifdef CONFIG_CONTEXT_TRACKING |
34 | /* Called on entry from user mode with IRQs off. */ | 41 | /* Called on entry from user mode with IRQs off. */ |
35 | __visible void enter_from_user_mode(void) | 42 | __visible void enter_from_user_mode(void) |
@@ -68,14 +75,14 @@ static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch) | |||
68 | */ | 75 | */ |
69 | unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch) | 76 | unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch) |
70 | { | 77 | { |
78 | struct thread_info *ti = pt_regs_to_thread_info(regs); | ||
71 | unsigned long ret = 0; | 79 | unsigned long ret = 0; |
72 | u32 work; | 80 | u32 work; |
73 | 81 | ||
74 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) | 82 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) |
75 | BUG_ON(regs != task_pt_regs(current)); | 83 | BUG_ON(regs != task_pt_regs(current)); |
76 | 84 | ||
77 | work = ACCESS_ONCE(current_thread_info()->flags) & | 85 | work = ACCESS_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY; |
78 | _TIF_WORK_SYSCALL_ENTRY; | ||
79 | 86 | ||
80 | #ifdef CONFIG_CONTEXT_TRACKING | 87 | #ifdef CONFIG_CONTEXT_TRACKING |
81 | /* | 88 | /* |
@@ -157,9 +164,9 @@ unsigned long syscall_trace_enter_phase1(struct pt_regs *regs, u32 arch) | |||
157 | long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch, | 164 | long syscall_trace_enter_phase2(struct pt_regs *regs, u32 arch, |
158 | unsigned long phase1_result) | 165 | unsigned long phase1_result) |
159 | { | 166 | { |
167 | struct thread_info *ti = pt_regs_to_thread_info(regs); | ||
160 | long ret = 0; | 168 | long ret = 0; |
161 | u32 work = ACCESS_ONCE(current_thread_info()->flags) & | 169 | u32 work = ACCESS_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY; |
162 | _TIF_WORK_SYSCALL_ENTRY; | ||
163 | 170 | ||
164 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) | 171 | if (IS_ENABLED(CONFIG_DEBUG_ENTRY)) |
165 | BUG_ON(regs != task_pt_regs(current)); | 172 | BUG_ON(regs != task_pt_regs(current)); |
@@ -211,13 +218,6 @@ long syscall_trace_enter(struct pt_regs *regs) | |||
211 | return syscall_trace_enter_phase2(regs, arch, phase1_result); | 218 | return syscall_trace_enter_phase2(regs, arch, phase1_result); |
212 | } | 219 | } |
213 | 220 | ||
214 | static struct thread_info *pt_regs_to_thread_info(struct pt_regs *regs) | ||
215 | { | ||
216 | unsigned long top_of_stack = | ||
217 | (unsigned long)(regs + 1) + TOP_OF_KERNEL_STACK_PADDING; | ||
218 | return (struct thread_info *)(top_of_stack - THREAD_SIZE); | ||
219 | } | ||
220 | |||
221 | /* Called with IRQs disabled. */ | 221 | /* Called with IRQs disabled. */ |
222 | __visible void prepare_exit_to_usermode(struct pt_regs *regs) | 222 | __visible void prepare_exit_to_usermode(struct pt_regs *regs) |
223 | { | 223 | { |