Patchwork arm: LLVMLinux: Calculate current_thread_info from fp

login
register
mail settings
Submitter Behan Webster
Date Sept. 6, 2013, 9:47 p.m.
Message ID <1378504062-9117-2-git-send-email-behanw@converseincode.com>
Download mbox | patch
Permalink /patch/273344/
State New
Headers show

Comments

Behan Webster - Sept. 6, 2013, 9:47 p.m.
From: Behan Webster <behanw@converseincode.com>

Use the frame pointer to calculate the start of the stack for current_thread_info()
The existing code uses the stack pointer to do this calculation.
Using the frame pointer yeilds the same value in a portable way.
This change supports being able to compile the kernel with gcc and Clang.

Signed-off-by: Mark Charlebois <charlebm@gmail.com>
Signed-off-by: Behan Webster <behanw@converseincode.com>
Reviewed-by: Jan-Simon Möller <dl9pf@gmx.de>
---
 arch/arm/include/asm/thread_info.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch

diff --git a/arch/arm/include/asm/thread_info.h b/arch/arm/include/asm/thread_info.h
index df5e13d..cb50933 100644
--- a/arch/arm/include/asm/thread_info.h
+++ b/arch/arm/include/asm/thread_info.h
@@ -106,8 +106,9 @@  static inline struct thread_info *current_thread_info(void) __attribute_const__;
 
 static inline struct thread_info *current_thread_info(void)
 {
-	register unsigned long sp asm ("sp");
-	return (struct thread_info *)(sp & ~(THREAD_SIZE - 1));
+	return (struct thread_info *)
+		((u32)(__builtin_frame_address(0))
+		& ~(THREAD_SIZE - 1));
 }
 
 #define thread_saved_pc(tsk)	\