diff options
author | Andy Lutomirski <luto@amacapital.net> | 2015-03-10 14:05:59 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-03-17 04:25:27 -0400 |
commit | d9e05cc5a53246e074dc2b84956252e4bbe392cd (patch) | |
tree | 8c65d6e6cfc5587c54934c5ee633277e5d2f6e8b | |
parent | 3ee4298f440c81638cbb5ec06f2497fb7a9a9eb4 (diff) |
x86/asm/entry: Unify and fix initial thread_struct::sp0 values
x86_32 and x86_64 need slightly different thread_struct::sp0 values, and
x86_32's was incorrect for init.
This never mattered -- the init thread never runs user code, so we never
used thread_struct::sp0 for anything.
Fix it and mostly unify them.
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/1b810c1d2e797e27bb4a7708c426101161edd1f6.1426009661.git.luto@amacapital.net
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/include/asm/processor.h | 7 | ||||
-rw-r--r-- | arch/x86/kernel/process.c | 2 |
2 files changed, 6 insertions, 3 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 88d9aa745898..fc6d8d0d8d53 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h | |||
@@ -811,6 +811,9 @@ static inline void spin_lock_prefetch(const void *x) | |||
811 | prefetchw(x); | 811 | prefetchw(x); |
812 | } | 812 | } |
813 | 813 | ||
814 | #define TOP_OF_INIT_STACK ((unsigned long)&init_stack + sizeof(init_stack) - \ | ||
815 | TOP_OF_KERNEL_STACK_PADDING) | ||
816 | |||
814 | #ifdef CONFIG_X86_32 | 817 | #ifdef CONFIG_X86_32 |
815 | /* | 818 | /* |
816 | * User space process size: 3GB (default). | 819 | * User space process size: 3GB (default). |
@@ -821,7 +824,7 @@ static inline void spin_lock_prefetch(const void *x) | |||
821 | #define STACK_TOP_MAX STACK_TOP | 824 | #define STACK_TOP_MAX STACK_TOP |
822 | 825 | ||
823 | #define INIT_THREAD { \ | 826 | #define INIT_THREAD { \ |
824 | .sp0 = sizeof(init_stack) + (long)&init_stack, \ | 827 | .sp0 = TOP_OF_INIT_STACK, \ |
825 | .vm86_info = NULL, \ | 828 | .vm86_info = NULL, \ |
826 | .sysenter_cs = __KERNEL_CS, \ | 829 | .sysenter_cs = __KERNEL_CS, \ |
827 | .io_bitmap_ptr = NULL, \ | 830 | .io_bitmap_ptr = NULL, \ |
@@ -883,7 +886,7 @@ extern unsigned long thread_saved_pc(struct task_struct *tsk); | |||
883 | #define STACK_TOP_MAX TASK_SIZE_MAX | 886 | #define STACK_TOP_MAX TASK_SIZE_MAX |
884 | 887 | ||
885 | #define INIT_THREAD { \ | 888 | #define INIT_THREAD { \ |
886 | .sp0 = (unsigned long)&init_stack + sizeof(init_stack) \ | 889 | .sp0 = TOP_OF_INIT_STACK \ |
887 | } | 890 | } |
888 | 891 | ||
889 | /* | 892 | /* |
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c index f4c0af7fc3a0..12b1cf606ddf 100644 --- a/arch/x86/kernel/process.c +++ b/arch/x86/kernel/process.c | |||
@@ -39,7 +39,7 @@ | |||
39 | */ | 39 | */ |
40 | __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = { | 40 | __visible DEFINE_PER_CPU_SHARED_ALIGNED(struct tss_struct, cpu_tss) = { |
41 | .x86_tss = { | 41 | .x86_tss = { |
42 | .sp0 = (unsigned long)&init_stack + sizeof(init_stack), | 42 | .sp0 = TOP_OF_INIT_STACK, |
43 | #ifdef CONFIG_X86_32 | 43 | #ifdef CONFIG_X86_32 |
44 | .ss0 = __KERNEL_DS, | 44 | .ss0 = __KERNEL_DS, |
45 | .ss1 = __KERNEL_CS, | 45 | .ss1 = __KERNEL_CS, |