diff options
author | Andy Lutomirski <luto@amacapital.net> | 2015-03-06 20:50:19 -0500 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-07 03:34:03 -0500 |
commit | a7fcf28d431ef70afaa91496e64e16dc51dccec4 (patch) | |
tree | 3de032435c43db84cdfc4f7e46df4d118b86fe82 /arch/x86/include | |
parent | b27559a433bb6080d95c2593d4a2b81401197911 (diff) |
x86/asm/entry: Replace this_cpu_sp0() with current_top_of_stack() and fix it on x86_32
I broke 32-bit kernels. The implementation of sp0 was correct
as far as I can tell, but sp0 was much weirder on x86_32 than I
realized. It has the following issues:
- Init's sp0 is inconsistent with everything else's: non-init tasks
are offset by 8 bytes. (I have no idea why, and the comment is unhelpful.)
- vm86 does crazy things to sp0.
Fix it up by replacing this_cpu_sp0() with
current_top_of_stack() and using a new percpu variable to track
the top of the stack on x86_32.
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>
Fixes: 75182b1632a8 ("x86/asm/entry: Switch all C consumers of kernel_stack to this_cpu_sp0()")
Link: http://lkml.kernel.org/r/d09dbe270883433776e0cbee3c7079433349e96d.1425692936.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/include')
-rw-r--r-- | arch/x86/include/asm/processor.h | 11 | ||||
-rw-r--r-- | arch/x86/include/asm/thread_info.h | 4 |
2 files changed, 11 insertions, 4 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index f5e3ec63767d..48a61c1c626e 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -284,6 +284,10 @@ struct tss_struct { | |||
284 | 284 | ||
285 | DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss); | 285 | DECLARE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss); |
286 | 286 | ||
287 | #ifdef CONFIG_X86_32 | ||
288 | DECLARE_PER_CPU(unsigned long, cpu_current_top_of_stack); | ||
289 | #endif | ||
290 | |||
287 | /* | 291 | /* |
288 | * Save the original ist values for checking stack pointers during debugging | 292 | * Save the original ist values for checking stack pointers during debugging |
289 | */ | 293 | */ |
@@ -564,9 +568,14 @@ static inline void native_swapgs(void) | |||
564 | #endif | 568 | #endif |
565 | } | 569 | } |
566 | 570 | ||
567 | static inline unsigned long this_cpu_sp0(void) | 571 | static inline unsigned long current_top_of_stack(void) |
568 | { | 572 | { |
573 | #ifdef CONFIG_X86_64 | ||
569 | return this_cpu_read_stable(cpu_tss.x86_tss.sp0); | 574 | return this_cpu_read_stable(cpu_tss.x86_tss.sp0); |
575 | #else | ||
576 | /* sp0 on x86_32 is special in and around vm86 mode. */ | ||
577 | return this_cpu_read_stable(cpu_current_top_of_stack); | ||
578 | #endif | ||
570 | } | 579 | } |
571 | 580 | ||
572 | #ifdef CONFIG_PARAVIRT | 581 | #ifdef CONFIG_PARAVIRT |
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index a2fa1899494e..7740edd56fed 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -158,9 +158,7 @@ DECLARE_PER_CPU(unsigned long, kernel_stack); | |||
158 | 158 | ||
159 | static inline struct thread_info *current_thread_info(void) | 159 | static inline struct thread_info *current_thread_info(void) |
160 | { | 160 | { |
161 | struct thread_info *ti; | 161 | return (struct thread_info *)(current_top_of_stack() - THREAD_SIZE); |
162 | ti = (void *)(this_cpu_sp0() - THREAD_SIZE); | ||
163 | return ti; | ||
164 | } | 162 | } |
165 | 163 | ||
166 | static inline unsigned long current_stack_pointer(void) | 164 | static inline unsigned long current_stack_pointer(void) |