x86/entry/64: Remove all remaining direct thread_struct::sp0 reads
authorAndy Lutomirski <luto@kernel.org>
Thu, 2 Nov 2017 07:59:14 +0000 (00:59 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 25 Dec 2017 13:26:18 +0000 (14:26 +0100)
commit 46f5a10a721ce8dce8cc8fe55279b49e1c6b3288 upstream.

The only remaining readers in context switch code or vm86(), and
they all just want to update TSS.sp0 to match the current task.
Replace them all with a new helper update_sp0().

Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Borislav Petkov <bp@suse.de>
Cc: Borislav Petkov <bpetkov@suse.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Dave Hansen <dave.hansen@intel.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/2d231687f4ff288c9d9e98d7861b7df374246ac3.1509609304.git.luto@kernel.org
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/include/asm/switch_to.h
arch/x86/kernel/process_32.c
arch/x86/kernel/process_64.c
arch/x86/kernel/vm86_32.c

index 0fe929d1ff70a44344c1af81e003bcd97e4c53b1..92dca86a39e3a78b83de42fed3c24a54a6e6534a 100644 (file)
@@ -85,4 +85,10 @@ static inline void refresh_sysenter_cs(struct thread_struct *thread)
 }
 #endif
 
+/* This is used when switching tasks or entering/exiting vm86 mode. */
+static inline void update_sp0(struct task_struct *task)
+{
+       load_sp0(task->thread.sp0);
+}
+
 #endif /* _ASM_X86_SWITCH_TO_H */
index 40b85870e42932ebe37d96b925eca7b337a7c0bd..45bf0c5f93e15103060d67d5245756ab72ce8fe5 100644 (file)
@@ -287,7 +287,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
         * current_thread_info().  Refresh the SYSENTER configuration in
         * case prev or next is vm86.
         */
-       load_sp0(next->sp0);
+       update_sp0(next_p);
        refresh_sysenter_cs(next);
        this_cpu_write(cpu_current_top_of_stack,
                       (unsigned long)task_stack_page(next_p) +
index 2124304fb77abc16aaf2609fab1c9b81957c8fcc..45e3809583926c90b2db758d9cc4486ea5a8c4b5 100644 (file)
@@ -465,7 +465,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
        this_cpu_write(current_task, next_p);
 
        /* Reload sp0. */
-       load_sp0(next->sp0);
+       update_sp0(next_p);
 
        /*
         * Now maybe reload the debug registers and handle I/O bitmaps
index f75e305a9b63af0979b5cd975c92814eed77a5d5..5edb27f1a2c407ff8173161fb87cbd9130b76e8e 100644 (file)
@@ -149,7 +149,7 @@ void save_v86_state(struct kernel_vm86_regs *regs, int retval)
        preempt_disable();
        tsk->thread.sp0 = vm86->saved_sp0;
        tsk->thread.sysenter_cs = __KERNEL_CS;
-       load_sp0(tsk->thread.sp0);
+       update_sp0(tsk);
        refresh_sysenter_cs(&tsk->thread);
        vm86->saved_sp0 = 0;
        preempt_enable();
@@ -374,7 +374,7 @@ static long do_sys_vm86(struct vm86plus_struct __user *user_vm86, bool plus)
                refresh_sysenter_cs(&tsk->thread);
        }
 
-       load_sp0(tsk->thread.sp0);
+       update_sp0(tsk);
        preempt_enable();
 
        if (vm86->flags & VM86_SCREEN_BITMAP)