From: tip-bot for Andy Lutomirski <tipbot@zytor.com>
To: linux-tip-commits@vger.kernel.org
Cc: luto@amacapital.net, linux-kernel@vger.kernel.org,
oleg@redhat.com, mingo@kernel.org, tglx@linutronix.de,
torvalds@linux-foundation.org, dvlasenk@redhat.com,
hpa@zytor.com, bp@alien8.de
Subject: [tip:x86/asm] x86/asm/entry: Delay loading sp0 slightly on task switch
Date: Sat, 7 Mar 2015 00:37:25 -0800 [thread overview]
Message-ID: <tip-b27559a433bb6080d95c2593d4a2b81401197911@git.kernel.org> (raw)
In-Reply-To: <9fcaa47dd8487db59eed7a3911b6ae409476763e.1425692936.git.luto@amacapital.net>
Commit-ID: b27559a433bb6080d95c2593d4a2b81401197911
Gitweb: http://git.kernel.org/tip/b27559a433bb6080d95c2593d4a2b81401197911
Author: Andy Lutomirski <luto@amacapital.net>
AuthorDate: Fri, 6 Mar 2015 17:50:18 -0800
Committer: Ingo Molnar <mingo@kernel.org>
CommitDate: Sat, 7 Mar 2015 09:34:03 +0100
x86/asm/entry: Delay loading sp0 slightly on task switch
The change:
75182b1632a8 ("x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0()")
had the unintended side effect of changing the return value of
current_thread_info() during part of the context switch process.
Change it back.
This has no effect as far as I can tell -- it's just for
consistency.
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/9fcaa47dd8487db59eed7a3911b6ae409476763e.1425692936.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
arch/x86/kernel/process_32.c | 10 +++++-----
arch/x86/kernel/process_64.c | 6 +++---
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index d3460af..0405cab 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -256,11 +256,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
fpu = switch_fpu_prepare(prev_p, next_p, cpu);
/*
- * Reload esp0.
- */
- load_sp0(tss, next);
-
- /*
* Save away %gs. No need to save %fs, as it was saved on the
* stack on entry. No need to save %es and %ds, as those are
* always kernel segments while inside the kernel. Doing this
@@ -310,6 +305,11 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
*/
arch_end_context_switch(next_p);
+ /*
+ * Reload esp0. This changes current_thread_info().
+ */
+ load_sp0(tss, next);
+
this_cpu_write(kernel_stack,
(unsigned long)task_stack_page(next_p) +
THREAD_SIZE - KERNEL_STACK_OFFSET);
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 2cd562f..1e393d2 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -283,9 +283,6 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
fpu = switch_fpu_prepare(prev_p, next_p, cpu);
- /* Reload esp0 and ss1. */
- load_sp0(tss, next);
-
/* We must save %fs and %gs before load_TLS() because
* %fs and %gs may be cleared by load_TLS().
*
@@ -413,6 +410,9 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
task_thread_info(prev_p)->saved_preempt_count = this_cpu_read(__preempt_count);
this_cpu_write(__preempt_count, task_thread_info(next_p)->saved_preempt_count);
+ /* Reload esp0 and ss1. This changes current_thread_info(). */
+ load_sp0(tss, next);
+
this_cpu_write(kernel_stack,
(unsigned long)task_stack_page(next_p) +
THREAD_SIZE - KERNEL_STACK_OFFSET);
next prev parent reply other threads:[~2015-03-07 8:38 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-07 1:50 [PATCH 0/2] x86: sp0 fixes Andy Lutomirski
2015-03-07 1:50 ` [PATCH 1/2] x86: Delay loading sp0 slightly on task switch Andy Lutomirski
2015-03-07 8:37 ` tip-bot for Andy Lutomirski [this message]
2015-03-07 1:50 ` [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack and fix it on x86_32 Andy Lutomirski
2015-03-07 8:37 ` [tip:x86/asm] x86/asm/entry: Replace this_cpu_sp0() with current_top_of_stack() " tip-bot for Andy Lutomirski
2015-03-09 13:04 ` Denys Vlasenko
2015-03-09 13:15 ` Andy Lutomirski
2015-03-26 13:30 ` [PATCH 2/2] x86: Replace this_cpu_sp0 with current_top_of_stack " Boris Ostrovsky
2015-03-26 18:33 ` 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=tip-b27559a433bb6080d95c2593d4a2b81401197911@git.kernel.org \
--to=tipbot@zytor.com \
--cc=bp@alien8.de \
--cc=dvlasenk@redhat.com \
--cc=hpa@zytor.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tip-commits@vger.kernel.org \
--cc=luto@amacapital.net \
--cc=mingo@kernel.org \
--cc=oleg@redhat.com \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.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
Powered by JetHome