aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/entry/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/entry/common.c')
-rw-r--r--arch/x86/entry/common.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c
index 1433f6b4607d..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
34static 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()))
@@ -209,7 +201,7 @@ __visible inline void prepare_exit_to_usermode(struct pt_regs *regs)
209 * special case only applies after poking regs and before the 201 * special case only applies after poking regs and before the
210 * very next return to user mode. 202 * very next return to user mode.
211 */ 203 */
212 ti->status &= ~(TS_COMPAT|TS_I386_REGS_POKED); 204 current->thread.status &= ~(TS_COMPAT|TS_I386_REGS_POKED);
213#endif 205#endif
214 206
215 user_enter_irqoff(); 207 user_enter_irqoff();
@@ -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,11 +295,11 @@ __visible void do_syscall_64(struct pt_regs *regs)
303 */ 295 */
304static __always_inline void do_syscall_32_irqs_on(struct pt_regs *regs) 296static __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
310 ti->status |= TS_COMPAT; 302 current->thread.status |= TS_COMPAT;
311#endif 303#endif
312 304
313 if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) { 305 if (READ_ONCE(ti->flags) & _TIF_WORK_SYSCALL_ENTRY) {