mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs
@ 2015-07-23 18:56 Andy Lutomirski
  2015-07-23 19:03 ` Brian Gerst
  0 siblings, 1 reply; 3+ messages in thread
From: Andy Lutomirski @ 2015-07-23 18:56 UTC (permalink / raw)
  To: X86 ML, linux-kernel
  Cc: Brian Gerst, Steven Rostedt, Willy Tarreau, Borislav Petkov,
	Thomas Gleixner, Peter Zijlstra, Linus Torvalds, Andy Lutomirski

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs
  2015-07-23 18:56 [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs Andy Lutomirski
@ 2015-07-23 19:03 ` Brian Gerst
  2015-07-23 19:12   ` Andy Lutomirski
  0 siblings, 1 reply; 3+ messages in thread
From: Brian Gerst @ 2015-07-23 19:03 UTC (permalink / raw)
  To: Andy Lutomirski
  Cc: X86 ML, Linux Kernel Mailing List, Steven Rostedt, Willy Tarreau,
	Borislav Petkov, Thomas Gleixner, Peter Zijlstra, Linus Torvalds

On Thu, Jul 23, 2015 at 2:56 PM, Andy Lutomirski <luto@kernel.org> wrote:
> 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.

It's already statically initialized in cpu_tss.

--
Brian Gerst

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs
  2015-07-23 19:03 ` Brian Gerst
@ 2015-07-23 19:12   ` Andy Lutomirski
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Lutomirski @ 2015-07-23 19:12 UTC (permalink / raw)
  To: Brian Gerst
  Cc: Andy Lutomirski, X86 ML, Linux Kernel Mailing List,
	Steven Rostedt, Willy Tarreau, Borislav Petkov, Thomas Gleixner,
	Peter Zijlstra, Linus Torvalds

On Thu, Jul 23, 2015 at 12:03 PM, Brian Gerst <brgerst@gmail.com> wrote:
> On Thu, Jul 23, 2015 at 2:56 PM, Andy Lutomirski <luto@kernel.org> wrote:
>> 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.
>
> It's already statically initialized in cpu_tss.

Indeed.  I'll just delete it, then.

>
> --
> Brian Gerst



-- 
Andy Lutomirski
AMA Capital Management, LLC

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-07-23 19:12 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-23 18:56 [PATCH] x86/entry/32: Initialize ss1 (SYSENTER_CS shadow) even on non-SEP CPUs Andy Lutomirski
2015-07-23 19:03 ` Brian Gerst
2015-07-23 19:12   ` Andy Lutomirski

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®