diff options
author | Denys Vlasenko <dvlasenk@redhat.com> | 2015-04-24 11:31:35 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2015-05-08 07:50:02 -0400 |
commit | 3a23208e69679597e767cf3547b1a30dd845d9b5 (patch) | |
tree | ad8cc3394286ce925eaffc98ff867f0373e262fb | |
parent | fed7c3f0f750f225317828d691e9eb76eec887b3 (diff) |
x86/entry: Define 'cpu_current_top_of_stack' for 64-bit code
32-bit code has PER_CPU_VAR(cpu_current_top_of_stack).
64-bit code uses somewhat more obscure: PER_CPU_VAR(cpu_tss + TSS_sp0).
Define the 'cpu_current_top_of_stack' macro on CONFIG_X86_64
as well so that the PER_CPU_VAR(cpu_current_top_of_stack)
expression can be used in both 32-bit and 64-bit code.
Signed-off-by: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Alexei Starovoitov <ast@plumgrid.com>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Oleg Nesterov <oleg@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Will Drewry <wad@chromium.org>
Link: http://lkml.kernel.org/r/1429889495-27850-3-git-send-email-dvlasenk@redhat.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r-- | arch/x86/ia32/ia32entry.S | 4 | ||||
-rw-r--r-- | arch/x86/include/asm/thread_info.h | 10 | ||||
-rw-r--r-- | arch/x86/kernel/entry_64.S | 2 | ||||
-rw-r--r-- | arch/x86/xen/xen-asm_64.S | 5 |
4 files changed, 10 insertions, 11 deletions
diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S index 1b1330c07971..63450a596800 100644 --- a/arch/x86/ia32/ia32entry.S +++ b/arch/x86/ia32/ia32entry.S | |||
@@ -113,7 +113,7 @@ ENTRY(ia32_sysenter_target) | |||
113 | * it is too small to ever cause noticeable irq latency. | 113 | * it is too small to ever cause noticeable irq latency. |
114 | */ | 114 | */ |
115 | SWAPGS_UNSAFE_STACK | 115 | SWAPGS_UNSAFE_STACK |
116 | movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp | 116 | movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp |
117 | ENABLE_INTERRUPTS(CLBR_NONE) | 117 | ENABLE_INTERRUPTS(CLBR_NONE) |
118 | 118 | ||
119 | /* Zero-extending 32-bit regs, do not remove */ | 119 | /* Zero-extending 32-bit regs, do not remove */ |
@@ -346,7 +346,7 @@ ENTRY(ia32_cstar_target) | |||
346 | SWAPGS_UNSAFE_STACK | 346 | SWAPGS_UNSAFE_STACK |
347 | movl %esp,%r8d | 347 | movl %esp,%r8d |
348 | CFI_REGISTER rsp,r8 | 348 | CFI_REGISTER rsp,r8 |
349 | movq PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp | 349 | movq PER_CPU_VAR(cpu_current_top_of_stack),%rsp |
350 | ENABLE_INTERRUPTS(CLBR_NONE) | 350 | ENABLE_INTERRUPTS(CLBR_NONE) |
351 | 351 | ||
352 | /* Zero-extending 32-bit regs, do not remove */ | 352 | /* Zero-extending 32-bit regs, do not remove */ |
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 472288962c99..225ee545e1a0 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -195,16 +195,14 @@ static inline unsigned long current_stack_pointer(void) | |||
195 | 195 | ||
196 | #else /* !__ASSEMBLY__ */ | 196 | #else /* !__ASSEMBLY__ */ |
197 | 197 | ||
198 | #ifdef CONFIG_X86_64 | ||
199 | # define cpu_current_top_of_stack (cpu_tss + TSS_sp0) | ||
200 | #endif | ||
201 | |||
198 | /* Load thread_info address into "reg" */ | 202 | /* Load thread_info address into "reg" */ |
199 | #ifdef CONFIG_X86_32 | ||
200 | #define GET_THREAD_INFO(reg) \ | 203 | #define GET_THREAD_INFO(reg) \ |
201 | _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \ | 204 | _ASM_MOV PER_CPU_VAR(cpu_current_top_of_stack),reg ; \ |
202 | _ASM_SUB $(THREAD_SIZE),reg ; | 205 | _ASM_SUB $(THREAD_SIZE),reg ; |
203 | #else | ||
204 | #define GET_THREAD_INFO(reg) \ | ||
205 | _ASM_MOV PER_CPU_VAR(cpu_tss + TSS_sp0),reg ; \ | ||
206 | _ASM_SUB $(THREAD_SIZE),reg ; | ||
207 | #endif | ||
208 | 206 | ||
209 | /* | 207 | /* |
210 | * ASM operand which evaluates to a 'thread_info' address of | 208 | * ASM operand which evaluates to a 'thread_info' address of |
diff --git a/arch/x86/kernel/entry_64.S b/arch/x86/kernel/entry_64.S index c13b86b40176..09c3f9e0e07e 100644 --- a/arch/x86/kernel/entry_64.S +++ b/arch/x86/kernel/entry_64.S | |||
@@ -216,7 +216,7 @@ ENTRY(system_call) | |||
216 | GLOBAL(system_call_after_swapgs) | 216 | GLOBAL(system_call_after_swapgs) |
217 | 217 | ||
218 | movq %rsp,PER_CPU_VAR(rsp_scratch) | 218 | movq %rsp,PER_CPU_VAR(rsp_scratch) |
219 | movq PER_CPU_VAR(cpu_tss + TSS_sp0),%rsp | 219 | movq PER_CPU_VAR(cpu_current_top_of_stack),%rsp |
220 | 220 | ||
221 | /* Construct struct pt_regs on stack */ | 221 | /* Construct struct pt_regs on stack */ |
222 | pushq_cfi $__USER_DS /* pt_regs->ss */ | 222 | pushq_cfi $__USER_DS /* pt_regs->ss */ |
diff --git a/arch/x86/xen/xen-asm_64.S b/arch/x86/xen/xen-asm_64.S index 5aa7ec607b9e..04529e620559 100644 --- a/arch/x86/xen/xen-asm_64.S +++ b/arch/x86/xen/xen-asm_64.S | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <asm/processor-flags.h> | 16 | #include <asm/processor-flags.h> |
17 | #include <asm/segment.h> | 17 | #include <asm/segment.h> |
18 | #include <asm/asm-offsets.h> | 18 | #include <asm/asm-offsets.h> |
19 | #include <asm/thread_info.h> | ||
19 | 20 | ||
20 | #include <xen/interface/xen.h> | 21 | #include <xen/interface/xen.h> |
21 | 22 | ||
@@ -54,7 +55,7 @@ ENTRY(xen_sysret64) | |||
54 | * still with the kernel gs, so we can easily switch back | 55 | * still with the kernel gs, so we can easily switch back |
55 | */ | 56 | */ |
56 | movq %rsp, PER_CPU_VAR(rsp_scratch) | 57 | movq %rsp, PER_CPU_VAR(rsp_scratch) |
57 | movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp | 58 | movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp |
58 | 59 | ||
59 | pushq $__USER_DS | 60 | pushq $__USER_DS |
60 | pushq PER_CPU_VAR(rsp_scratch) | 61 | pushq PER_CPU_VAR(rsp_scratch) |
@@ -73,7 +74,7 @@ ENTRY(xen_sysret32) | |||
73 | * still with the kernel gs, so we can easily switch back | 74 | * still with the kernel gs, so we can easily switch back |
74 | */ | 75 | */ |
75 | movq %rsp, PER_CPU_VAR(rsp_scratch) | 76 | movq %rsp, PER_CPU_VAR(rsp_scratch) |
76 | movq PER_CPU_VAR(cpu_tss + TSS_sp0), %rsp | 77 | movq PER_CPU_VAR(cpu_current_top_of_stack), %rsp |
77 | 78 | ||
78 | pushq $__USER32_DS | 79 | pushq $__USER32_DS |
79 | pushq PER_CPU_VAR(rsp_scratch) | 80 | pushq PER_CPU_VAR(rsp_scratch) |