aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/include/asm/system.h
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2009-01-21 03:26:05 -0500
committerTejun Heo <tj@kernel.org>2009-01-21 03:26:05 -0500
commit67e68bde02fe783efc2ce2ca31bdb992f5235f8d (patch)
tree9dafb5703ff8012920673d448889c6ba4809e871 /arch/x86/include/asm/system.h
parent8f5d36ed5bb6e33024619eaee15b7ce2e3d115b3 (diff)
x86: update canary handling during switch
Impact: cleanup In switch_to(), instead of taking offset to irq_stack_union.stack, make it a proper percpu access using __percpu_arg() and per_cpu_var(). 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.h15
1 files changed, 9 insertions, 6 deletions
diff --git a/arch/x86/include/asm/system.h b/arch/x86/include/asm/system.h
index 52eb748a68af..2fcc70bc85f3 100644
--- a/arch/x86/include/asm/system.h
+++ b/arch/x86/include/asm/system.h
@@ -89,13 +89,15 @@ do { \
89#ifdef CONFIG_CC_STACKPROTECTOR 89#ifdef CONFIG_CC_STACKPROTECTOR
90#define __switch_canary \ 90#define __switch_canary \
91 "movq %P[task_canary](%%rsi),%%r8\n\t" \ 91 "movq %P[task_canary](%%rsi),%%r8\n\t" \
92 "movq %%r8,%%gs:%P[gs_canary]\n\t" 92 "movq %%r8,"__percpu_arg([gs_canary])"\n\t"
93#define __switch_canary_param \ 93#define __switch_canary_oparam \
94 , [task_canary] "i" (offsetof(struct task_struct, stack_canary)) \ 94 , [gs_canary] "=m" (per_cpu_var(irq_stack_union.stack_canary))
95 , [gs_canary] "i" (offsetof(union irq_stack_union, stack_canary)) 95#define __switch_canary_iparam \
96 , [task_canary] "i" (offsetof(struct task_struct, stack_canary))
96#else /* CC_STACKPROTECTOR */ 97#else /* CC_STACKPROTECTOR */
97#define __switch_canary 98#define __switch_canary
98#define __switch_canary_param 99#define __switch_canary_oparam
100#define __switch_canary_iparam
99#endif /* CC_STACKPROTECTOR */ 101#endif /* CC_STACKPROTECTOR */
100 102
101/* Save restore flags to clear handle leaking NT */ 103/* Save restore flags to clear handle leaking NT */
@@ -114,13 +116,14 @@ do { \
114 "jc ret_from_fork\n\t" \ 116 "jc ret_from_fork\n\t" \
115 RESTORE_CONTEXT \ 117 RESTORE_CONTEXT \
116 : "=a" (last) \ 118 : "=a" (last) \
119 __switch_canary_oparam \
117 : [next] "S" (next), [prev] "D" (prev), \ 120 : [next] "S" (next), [prev] "D" (prev), \
118 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \ 121 [threadrsp] "i" (offsetof(struct task_struct, thread.sp)), \
119 [ti_flags] "i" (offsetof(struct thread_info, flags)), \ 122 [ti_flags] "i" (offsetof(struct thread_info, flags)), \
120 [tif_fork] "i" (TIF_FORK), \ 123 [tif_fork] "i" (TIF_FORK), \
121 [thread_info] "i" (offsetof(struct task_struct, stack)), \ 124 [thread_info] "i" (offsetof(struct task_struct, stack)), \
122 [current_task] "m" (per_cpu_var(current_task)) \ 125 [current_task] "m" (per_cpu_var(current_task)) \
123 __switch_canary_param \ 126 __switch_canary_iparam \
124 : "memory", "cc" __EXTRA_CLOBBER) 127 : "memory", "cc" __EXTRA_CLOBBER)
125#endif 128#endif
126 129