diff options
author | Andy Lutomirski <luto@amacapital.net> | 2014-11-13 18:57:07 -0500 |
---|---|---|
committer | Andy Lutomirski <luto@amacapital.net> | 2015-01-02 13:22:46 -0500 |
commit | 83653c16da91112236292871b820cb8b367220e3 (patch) | |
tree | 1b4155808ca58628d39283073da627529bd4ad9f /arch | |
parent | 959274753857efe9c5f1ba35fe727f51e9aa128d (diff) |
x86: Clean up current_stack_pointer
There's no good reason for it to be a macro, and x86_64 will want to
use it, so it should be in a header.
Acked-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Andy Lutomirski <luto@amacapital.net>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/x86/include/asm/thread_info.h | 11 | ||||
-rw-r--r-- | arch/x86/kernel/irq_32.c | 13 |
2 files changed, 14 insertions, 10 deletions
diff --git a/arch/x86/include/asm/thread_info.h b/arch/x86/include/asm/thread_info.h index 547e344a6dc6..8b13b0fbda8e 100644 --- a/arch/x86/include/asm/thread_info.h +++ b/arch/x86/include/asm/thread_info.h | |||
@@ -170,6 +170,17 @@ static inline struct thread_info *current_thread_info(void) | |||
170 | return ti; | 170 | return ti; |
171 | } | 171 | } |
172 | 172 | ||
173 | static inline unsigned long current_stack_pointer(void) | ||
174 | { | ||
175 | unsigned long sp; | ||
176 | #ifdef CONFIG_X86_64 | ||
177 | asm("mov %%rsp,%0" : "=g" (sp)); | ||
178 | #else | ||
179 | asm("mov %%esp,%0" : "=g" (sp)); | ||
180 | #endif | ||
181 | return sp; | ||
182 | } | ||
183 | |||
173 | #else /* !__ASSEMBLY__ */ | 184 | #else /* !__ASSEMBLY__ */ |
174 | 185 | ||
175 | /* how to get the thread information struct from ASM */ | 186 | /* how to get the thread information struct from ASM */ |
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c index 63ce838e5a54..28d28f5eb8f4 100644 --- a/arch/x86/kernel/irq_32.c +++ b/arch/x86/kernel/irq_32.c | |||
@@ -69,16 +69,9 @@ static void call_on_stack(void *func, void *stack) | |||
69 | : "memory", "cc", "edx", "ecx", "eax"); | 69 | : "memory", "cc", "edx", "ecx", "eax"); |
70 | } | 70 | } |
71 | 71 | ||
72 | /* how to get the current stack pointer from C */ | ||
73 | #define current_stack_pointer ({ \ | ||
74 | unsigned long sp; \ | ||
75 | asm("mov %%esp,%0" : "=g" (sp)); \ | ||
76 | sp; \ | ||
77 | }) | ||
78 | |||
79 | static inline void *current_stack(void) | 72 | static inline void *current_stack(void) |
80 | { | 73 | { |
81 | return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1)); | 74 | return (void *)(current_stack_pointer() & ~(THREAD_SIZE - 1)); |
82 | } | 75 | } |
83 | 76 | ||
84 | static inline int | 77 | static inline int |
@@ -103,7 +96,7 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) | |||
103 | 96 | ||
104 | /* Save the next esp at the bottom of the stack */ | 97 | /* Save the next esp at the bottom of the stack */ |
105 | prev_esp = (u32 *)irqstk; | 98 | prev_esp = (u32 *)irqstk; |
106 | *prev_esp = current_stack_pointer; | 99 | *prev_esp = current_stack_pointer(); |
107 | 100 | ||
108 | if (unlikely(overflow)) | 101 | if (unlikely(overflow)) |
109 | call_on_stack(print_stack_overflow, isp); | 102 | call_on_stack(print_stack_overflow, isp); |
@@ -156,7 +149,7 @@ void do_softirq_own_stack(void) | |||
156 | 149 | ||
157 | /* Push the previous esp onto the stack */ | 150 | /* Push the previous esp onto the stack */ |
158 | prev_esp = (u32 *)irqstk; | 151 | prev_esp = (u32 *)irqstk; |
159 | *prev_esp = current_stack_pointer; | 152 | *prev_esp = current_stack_pointer(); |
160 | 153 | ||
161 | call_on_stack(__do_softirq, isp); | 154 | call_on_stack(__do_softirq, isp); |
162 | } | 155 | } |