From: Andy Lutomirski <luto@kernel.org>
To: X86 ML <x86@kernel.org>, linux-kernel@vger.kernel.org
Cc: Brian Gerst <brgerst@gmail.com>,
Steven Rostedt <rostedt@goodmis.org>, Willy Tarreau <w@1wt.eu>,
Borislav Petkov <bp@alien8.de>,
Thomas Gleixner <tglx@linutronix.de>,
Peter Zijlstra <peterz@infradead.org>,
Linus Torvalds <torvalds@linux-foundation.org>,
Andy Lutomirski <luto@kernel.org>
Subject: [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs
Date: Thu, 23 Jul 2015 11:56:24 -0700 [thread overview]
Message-ID: <e9c9840880a77775db676dfb425181ecd24c9377.1437677615.git.luto@kernel.org> (raw)
native_load_sp0 relies on this. I'm not sure why we haven't seen
reports of crashes. Maybe no one tests new kernels on non-SEP CPUs.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
---
Of course, I haven't tested on a non-SEP CPU either. Where would I
find one?
arch/x86/kernel/cpu/common.c | 19 +++++++++++--------
1 file changed, 11 insertions(+), 8 deletions(-)
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index d27ab6e5e671..2181692c1eb3 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -993,6 +993,17 @@ void enable_sep_cpu(void)
cpu = get_cpu();
tss = &per_cpu(cpu_tss, cpu);
+#ifdef CONFIG_X86_32
+ /*
+ * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1
+ * field -- see the big comment in struct x86_hw_tss's
+ * definition. We need to initialize this even on non-SEP
+ * CPUs so that comparing ss1 to thread->sysenter_cs is
+ * always valid.
+ */
+ tss->x86_tss.ss1 = __KERNEL_CS;
+#endif
+
/*
* On 64-bit CPUs, enable SEP unconditionally. On Intel CPUs,
* it works and we use it. On AMD CPUs, the MSRs exist but EIP
@@ -1005,14 +1016,6 @@ void enable_sep_cpu(void)
if (IS_ENABLED(CONFIG_X86_32) && !boot_cpu_has(X86_FEATURE_SEP))
goto out;
-#ifdef CONFIG_X86_32
- /*
- * We cache MSR_IA32_SYSENTER_CS's value in the TSS's ss1 field --
- * see the big comment in struct x86_hw_tss's definition.
- */
- tss->x86_tss.ss1 = __KERNEL_CS;
-#endif
-
wrmsrl_safe(MSR_IA32_SYSENTER_CS, __KERNEL_CS);
wrmsrl_safe(MSR_IA32_SYSENTER_ESP,
(unsigned long)tss +
--
2.4.3
next reply other threads:[~2015-07-23 18:56 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-23 18:56 Andy Lutomirski [this message]
2015-07-23 19:03 ` Brian Gerst
2015-07-23 19:12 ` 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=e9c9840880a77775db676dfb425181ecd24c9377.1437677615.git.luto@kernel.org \
--to=luto@kernel.org \
--cc=bp@alien8.de \
--cc=brgerst@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=tglx@linutronix.de \
--cc=torvalds@linux-foundation.org \
--cc=w@1wt.eu \
--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
all inboxes | Powered by JetHome®