linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Andy Lutomirski <luto@kernel.org>
To: X86 ML <x86@kernel.org>
Cc: Borislav Petkov <bpetkov@suse.de>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Brian Gerst <brgerst@gmail.com>,
	Dave Hansen <dave.hansen@intel.com>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Andy Lutomirski <luto@kernel.org>
Subject: [PATCH 15/18] x86/asm/64: Remove all remaining direct thread_struct::sp0 reads
Date: Thu, 26 Oct 2017 01:26:47 -0700	[thread overview]
Message-ID: <c250f670ccdd25a8ec15c4195f0158da4fa25918.1509006199.git.luto@kernel.org> (raw)
In-Reply-To: <cover.1509006199.git.luto@kernel.org>
In-Reply-To: <cover.1509006199.git.luto@kernel.org>

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>
---
 arch/x86/include/asm/switch_to.h | 6 ++++++
 arch/x86/kernel/process_32.c     | 2 +-
 arch/x86/kernel/process_64.c     | 2 +-
 arch/x86/kernel/vm86_32.c        | 4 ++--
 4 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/switch_to.h b/arch/x86/include/asm/switch_to.h
index f3fa19925ae1..d9bb491ba45c 100644
--- a/arch/x86/include/asm/switch_to.h
+++ b/arch/x86/include/asm/switch_to.h
@@ -83,4 +83,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 */
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index 8bdf9aaa92a0..070bdaaa7c86 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -286,7 +286,7 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
 	 * Reload esp0 and cpu_current_top_of_stack.  This changes
 	 * current_thread_info().
 	 */
-	load_sp0(next->sp0);
+	update_sp0(next_p);
 	refresh_sysenter_cs(next);  /* in case prev or next is vm86 */
 	this_cpu_write(cpu_current_top_of_stack,
 		       (unsigned long)task_stack_page(next_p) +
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 2124304fb77a..45e380958392 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -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
diff --git a/arch/x86/kernel/vm86_32.c b/arch/x86/kernel/vm86_32.c
index 0f1d92cd20ad..a7b44c75c642 100644
--- a/arch/x86/kernel/vm86_32.c
+++ b/arch/x86/kernel/vm86_32.c
@@ -148,7 +148,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();
@@ -373,7 +373,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)
-- 
2.13.6

  parent reply	other threads:[~2017-10-26  8:29 UTC|newest]

Thread overview: 57+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-10-26  8:26 [PATCH 00/18] Pile o' entry/exit/sp0 changes Andy Lutomirski
2017-10-26  8:26 ` [PATCH 01/18] x86/asm/64: Remove the restore_c_regs_and_iret label Andy Lutomirski
2017-10-26 15:07   ` Borislav Petkov
2017-11-10  6:08   ` [01/18] " kemi
2017-10-26  8:26 ` [PATCH 02/18] x86/asm/64: Split the iret-to-user and iret-to-kernel paths Andy Lutomirski
2017-10-27 18:05   ` Dave Hansen
2017-11-01 11:34     ` Andy Lutomirski
2017-10-27 20:04   ` Borislav Petkov
2017-11-01 11:32     ` Andy Lutomirski
2017-10-26  8:26 ` [PATCH 03/18] x86/asm/64: Move SWAPGS into the common iret-to-usermode path Andy Lutomirski
2017-10-26 13:52   ` Brian Gerst
2017-10-26 14:13     ` Dave Hansen
2017-10-26 14:28       ` Borislav Petkov
2017-10-27 15:44         ` Andy Lutomirski
2017-10-27 18:08   ` Dave Hansen
2017-10-26  8:26 ` [PATCH 04/18] x86/asm/64: Simplify reg restore code in the standard IRET paths Andy Lutomirski
2017-10-26  8:26 ` [PATCH 05/18] x86/asm/64: Shrink paranoid_exit_restore and make labels local Andy Lutomirski
2017-10-27 20:07   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 06/18] x86/asm/64: Use pop instead of movq in syscall_return_via_sysret Andy Lutomirski
2017-10-27 20:11   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 07/18] x86/asm/64: Merge the fast and slow SYSRET paths Andy Lutomirski
2017-10-27 20:11   ` Borislav Petkov
2017-11-01 11:29     ` Andy Lutomirski
2017-11-01 12:35       ` Borislav Petkov
2017-11-01 17:26         ` Thomas Gleixner
2017-11-01 17:25   ` Brian Gerst
2017-11-01 20:35     ` Andy Lutomirski
2017-10-26  8:26 ` [PATCH 08/18] xen: add xen nmi trap entry Andy Lutomirski
2017-10-26  8:26 ` [PATCH 09/18] x86/asm/64: De-Xen-ify our NMI code Andy Lutomirski
2017-10-26  8:41   ` Juergen Gross
2017-10-27 20:11   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 10/18] x86/asm/32: Pull MSR_IA32_SYSENTER_CS update code out of native_load_sp0() Andy Lutomirski
2017-10-26 18:00   ` Brian Gerst
2017-10-27 13:51   ` Thomas Gleixner
2017-10-27 15:50     ` Andy Lutomirski
2017-10-27 20:11   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 11/18] x86/asm/64: Pass sp0 directly to load_sp0() Andy Lutomirski
2017-10-27 20:12   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 12/18] x86/asm: Add task_top_of_stack() to find the top of a task's stack Andy Lutomirski
2017-10-26  8:26 ` [PATCH 13/18] x86/xen/64: Clean up SP code in cpu_initialize_context() Andy Lutomirski
2017-10-26  8:43   ` Juergen Gross
2017-10-26  8:26 ` [PATCH 14/18] x86/boot/64: Stop initializing TSS.sp0 at boot Andy Lutomirski
2017-10-27 18:21   ` Dave Hansen
2017-10-28  8:10     ` Andy Lutomirski
2017-10-26  8:26 ` Andy Lutomirski [this message]
2017-11-01 10:08   ` [PATCH 15/18] x86/asm/64: Remove all remaining direct thread_struct::sp0 reads Borislav Petkov
2017-10-26  8:26 ` [PATCH 16/18] x86/boot/32: Fix cpu_current_top_of_stack initialization at boot Andy Lutomirski
2017-11-01 10:18   ` Borislav Petkov
2017-10-26  8:26 ` [PATCH 17/18] x86/asm/64: Remove thread_struct::sp0 Andy Lutomirski
2017-10-28  0:52   ` Brian Gerst
2017-11-01 10:23   ` Borislav Petkov
2017-11-01 10:40     ` Andy Lutomirski
2017-10-26  8:26 ` [PATCH 18/18] x86/traps: Use a new on_thread_stack() helper to clean up an assertion Andy Lutomirski
2017-11-01 10:31   ` Borislav Petkov
2017-11-01 10:45     ` Andy Lutomirski
2017-10-26 15:55 ` [PATCH 00/18] Pile o' entry/exit/sp0 changes Linus Torvalds
2017-10-28  7:31   ` Andy Lutomirski

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=c250f670ccdd25a8ec15c4195f0158da4fa25918.1509006199.git.luto@kernel.org \
    --to=luto@kernel.org \
    --cc=bpetkov@suse.de \
    --cc=brgerst@gmail.com \
    --cc=dave.hansen@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    --cc=x86@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).