aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/system.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-01-19 22:29:19 -0500
committerTejun Heo <tj@kernel.org>2009-01-19 22:29:19 -0500
commitb4a8f7a262e79ecb0b39beb1449af524a78887f8 (patch)
tree57d583acc09285170a7a364e6fb4a42b1fec0a98 /arch/x86/include/asm/system.h
parentc6e50f93db5bd0895ec7c7d1b6f3886c6e1f11b6 (diff)
x86: conditionalize stack canary handling in hot path
Impact: no unnecessary stack canary swapping during context switch There's no point in moving stack_canary around during context switch if it's not enabled. Conditionalize it. Signed-off-by: Tejun Heo <tj@kernel.org>
Diffstat (limited to 'arch/x86/include/asm/system.h')
-rw-r--r--arch/x86/include/asm/system.h22
1 files changed, 16 insertions, 6 deletions
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 8cadfe9b1194..b77bd8bd3cc2 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -86,17 +86,28 @@ do { \
86 , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \ 86 , "rcx", "rbx", "rdx", "r8", "r9", "r10", "r11", \
87 "r12", "r13", "r14", "r15" 87 "r12", "r13", "r14", "r15"
88 88
89#ifdef CONFIG_CC_STACKPROTECTOR
90#define __switch_canary \
91 "movq %P[task_canary](%%rsi),%%r8\n\t" \
92 "movq %%r8,%%gs:%P[pda_canary]\n\t"
93#define __switch_canary_param \
94 , [task_canary] "i" (offsetof(struct task_struct, stack_canary)) \
95 , [pda_canary] "i" (offsetof(struct x8664_pda, stack_canary))
96#else /* CC_STACKPROTECTOR */
97#define __switch_canary
98#define __switch_canary_param
99#endif /* CC_STACKPROTECTOR */
100
89/* Save restore flags to clear handle leaking NT */ 101/* Save restore flags to clear handle leaking NT */
90#define switch_to(prev, next, last) \ 102#define switch_to(prev, next, last) \
91 asm volatile(SAVE_CONTEXT \ 103 asm volatile(SAVE_CONTEXT \
92 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \ 104 "movq %%rsp,%P[threadrsp](%[prev])\n\t" /* save RSP */ \
93 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \ 105 "movq %P[threadrsp](%[next]),%%rsp\n\t" /* restore RSP */ \
94 "call __switch_to\n\t" \ 106 "call __switch_to\n\t" \
95 ".globl thread_return\n" \ 107 ".globl thread_return\n" \
96 "thread_return:\n\t" \ 108 "thread_return:\n\t" \
97 "movq "__percpu_arg([current_task])",%%rsi\n\t" \ 109 "movq "__percpu_arg([current_task])",%%rsi\n\t" \
98 "movq %P[task_canary](%%rsi),%%r8\n\t" \ 110 __switch_canary \
99 "movq %%r8,%%gs:%P[pda_canary]\n\t" \
100 "movq %P[thread_info](%%rsi),%%r8\n\t" \ 111 "movq %P[thread_info](%%rsi),%%r8\n\t" \
101 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \ 112 LOCK_PREFIX "btr %[tif_fork],%P[ti_flags](%%r8)\n\t" \
102 "movq %%rax,%%rdi\n\t" \ 113 "movq %%rax,%%rdi\n\t" \
@@ -108,9 +119,8 @@ do { \
108 [ti_flags] "i" (offsetof(struct thread_info, flags)), \ 119 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
109 [tif_fork] "i" (TIF_FORK), \ 120 [tif_fork] "i" (TIF_FORK), \
110 [thread_info] "i" (offsetof(struct task_struct, stack)), \ 121 [thread_info] "i" (offsetof(struct task_struct, stack)), \
111 [task_canary] "i" (offsetof(struct task_struct, stack_canary)),\ 122 [current_task] "m" (per_cpu_var(current_task)) \
112 [current_task] "m" (per_cpu_var(current_task)), \ 123 __switch_canary_param \
113 [pda_canary] "i" (offsetof(struct x8664_pda, stack_canary))\
114 : "memory", "cc" __EXTRA_CLOBBER) 124 : "memory", "cc" __EXTRA_CLOBBER)
115#endif 125#endif
116 126