Skip to content

Commit 6cce16f

Browse files
minipliH. Peter Anvin
authored andcommitted
x86, threadinfo: Redo "x86: Use inline assembler to get sp"
This patch restores the changes of commit dff38e3 "x86: Use inline assembler instead of global register variable to get sp". They got lost in commit 198d208 "x86: Keep thread_info on thread stack in x86_32" while moving the code to arch/x86/kernel/irq_32.c. Quoting Andi from commit dff38e3: """ LTO in gcc 4.6/47. has trouble with global register variables. They were used to read the stack pointer. Use a simple inline assembler statement with a mov instead. This also helps LLVM/clang, which does not support global register variables. """ Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Brian Gerst <brgerst@gmail.com> Cc: Andi Kleen <ak@linux.intel.com> Signed-off-by: Mathias Krause <minipli@googlemail.com> Link: http://lkml.kernel.org/r/1394178752-18047-1-git-send-email-minipli@googlemail.com Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
1 parent 2223f6f commit 6cce16f

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

‎arch/x86/kernel/irq_32.c‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ static void call_on_stack(void *func, void *stack)
7070
}
7171

7272
/* how to get the current stack pointer from C */
73-
register unsigned long current_stack_pointer asm("esp") __used;
73+
#define current_stack_pointer ({ \
74+
unsigned long sp; \
75+
asm("mov %%esp,%0" : "=g" (sp)); \
76+
sp; \
77+
})
7478

7579
static inline void *current_stack(void)
7680
{

0 commit comments

Comments
 (0)