diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-09-13 17:29:22 -0400 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2016-09-15 02:25:12 -0400 |
| commit | 97245d00585d82540f4538cf72d92a1e853c7b0e (patch) | |
| tree | 26054c5eba683abdb5163d60e85bf2c90997882c /arch/x86/entry | |
| parent | b9d989c7218ac922185d82ad46f3e58b27a4bea9 (diff) | |
x86/entry: Get rid of pt_regs_to_thread_info()
It was a nice optimization while it lasted, but thread_info is moving
and this optimization will no longer work.
Quoting Linus:
Oh Gods, Andy. That pt_regs_to_thread_info() thing made me want
to do unspeakable acts on a poor innocent wax figure that looked
_exactly_ like you.
[ Changelog written by Andy. ]
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Andy Lutomirski <luto@kernel.org>
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: Jann Horn <jann@thejh.net>
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/6376aa81c68798cc81631673f52bd91a3e078944.1473801993.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/entry')
| -rw-r--r-- | arch/x86/entry/common.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index 871bbf975d4c..bdd9cc59d20f 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c | |||
| @@ -31,13 +31,6 @@ | |||
| 31 | #define CREATE_TRACE_POINTS | 31 | #define CREATE_TRACE_POINTS |
| 32 | #include <trace/events/syscalls.h> | 32 | #include <trace/events/syscalls.h> |
| 33 | 33 | ||
| 34 | static struct thread_info *pt_regs_to_thread_info(struct pt_regs *regs) | ||
| 35 | { | ||
| 36 | unsigned long top_of_stack = | ||
| 37 | (unsigned long)(regs + 1) + TOP_OF_KERNEL_STACK_PADDING; | ||
| 38 | return (struct thread_info *)(top_of_stack - THREAD_SIZE); | ||
| 39 | } | ||
| 40 | |||
| 41 | #ifdef CONFIG_CONTEXT_TRACKING | 34 | #ifdef CONFIG_CONTEXT_TRACKING |
| 42 | /* Called on entry from user mode with IRQs off. */ | 35 | /* Called on entry from user mode with IRQs off. */ |
| 43 | __visible inline void enter_from_user_mode(void) | 36 | __visible inline void enter_from_user_mode(void) |
| @@ -71,7 +64,7 @@ static long syscall_trace_enter(struct pt_regs *regs) | |||
| 71 | { | 64 | { |
| 72 | u32 arch = in_ia32_syscall() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64; | 65 | u32 arch = in_ia32_syscall() ? AUDIT_ARCH_I386 : AUDIT_ARCH_X86_64; |
| 73 | 66 | ||
| 74 | struct thread_info *ti = pt_regs_to_thread_info(regs); | 67 | struct thread_info *ti = current_thread_info(); |
| 75 | unsigned long ret = 0; | 68 | unsigned long ret = 0; |
| 76 | bool emulated = false; | 69 | bool emulated = false; |
| 77 | u32 work; | 70 | u32 work; |
| @@ -173,18 +166,17 @@ static void exit_to_usermode_loop(struct pt_regs *regs, u32 cached_flags) | |||
| 173 | /* Disable IRQs and retry */ | 166 | /* Disable IRQs and retry */ |
| 174 | local_irq_disable(); | 167 | local_irq_disable(); |
| 175 | 168 | ||
| 176 | cached_flags = READ_ONCE(pt_regs_to_thread_info(regs)->flags); | 169 | cached_flags = READ_ONCE(current_thread_info()->flags); |
| 177 | 170 | ||
| 178 | if (!(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS)) | 171 | if (!(cached_flags & EXIT_TO_USERMODE_LOOP_FLAGS)) |
| 179 | break; | 172 | break; |
| 180 | |||
| 181 | } | 173 | } |
| 182 | } | 174 | } |
| 183 | 175 | ||
| 184 | /* Called with IRQs disabled. */ | 176 | /* Called with IRQs disabled. */ |
| 185 | __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) | 177 | __visible inline void prepare_exit_to_usermode(struct pt_regs *regs) |
| 186 | { | 178 | { |
| 187 | struct thread_info *ti = pt_regs_to_thread_info(regs); | 179 | struct thread_info *ti = current_thread_info(); |
| 188 | u32 cached_flags; | 180 | u32 cached_flags; |
| 189 | 181 | ||
| 190 | if (IS_ENABLED(CONFIG_PROVE_LOCKING) && WARN_ON(!irqs_disabled())) | 182 | if (IS_ENABLED(CONFIG_PROVE_LOCKING) && WARN_ON(!irqs_disabled())) |
| @@ -247,7 +239,7 @@ static void syscall_slow_exit_work(struct pt_regs *regs, u32 cached_flags) | |||
| 247 | */ | 239 | */ |
| 248 | __visible inline void syscall_return_slowpath(struct pt_regs *regs) | 240 | __visible inline void syscall_return_slowpath(struct pt_regs *regs) |
| 249 | { | 241 | { |
| 250 | struct thread_info *ti = pt_regs_to_thread_info(regs); | 242 | struct thread_info *ti = current_thread_info(); |
| 251 | u32 cached_flags = READ_ONCE(ti->flags); | 243 | u32 cached_flags = READ_ONCE(ti->flags); |
| 252 | 244 | ||
| 253 | CT_WARN_ON(ct_state() != CONTEXT_KERNEL); | 245 | CT_WARN_ON(ct_state() != CONTEXT_KERNEL); |
| @@ -270,7 +262,7 @@ __visible inline void syscall_return_slowpath(struct pt_regs *regs) | |||
| 270 | #ifdef CONFIG_X86_64 | 262 | #ifdef CONFIG_X86_64 |
| 271 | __visible void do_syscall_64(struct pt_regs *regs) | 263 | __visible void do_syscall_64(struct pt_regs *regs) |
| 272 | { | 264 | { |
| 273 | struct thread_info *ti = pt_regs_to_thread_info(regs); | 265 | struct thread_info *ti = current_thread_info(); |
| 274 | unsigned long nr = regs->orig_ax; | 266 | unsigned long nr = regs->orig_ax; |
| 275 | 267 | ||
| 276 | enter_from_user_mode(); | 268 | enter_from_user_mode(); |
| @@ -303,7 +295,7 @@ __visible void do_syscall_64(struct pt_regs *regs) | |||
| 303 | */ | 295 | */ |
| 304 | static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) | 296 | static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) |
| 305 | { | 297 | { |
| 306 | struct thread_info *ti = pt_regs_to_thread_info(regs); | 298 | struct thread_info *ti = current_thread_info(); |
| 307 | unsigned int nr = (unsigned int)regs->orig_ax; | 299 | unsigned int nr = (unsigned int)regs->orig_ax; |
| 308 | 300 | ||
| 309 | #ifdef CONFIG_IA32_EMULATION | 301 | #ifdef CONFIG_IA32_EMULATION |
