Skip to contentSkip to conversation

LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

PATCH Superseded [email protected] 4 participants 22 messages Jul 30, 2014 – Aug 27, 2014

Subsystems (2)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

 arch/arm64/include/asm/thread_info.h | 9 +++++++--
 arch/arm64/kernel/stacktrace.c       | 3 +--
 arch/arm64/kernel/traps.c            | 3 +--
 3 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/4 arm64: LLVMLinux: Add current_stack_pointer() for arm64

From: Behan Webster <[email protected]>

Define a global named register for current_stack_pointer. The use of this new variable guarantees that both gcc and clang can access this register in C code.

---
 arch/arm64/include/asm/thread_info.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/include/asm/thread_info.h +5 -0
index e40b6d0..e6b6094 100644
@@ -69,6 +69,11 @@ struct thread_info {
 #define init_stack		(init_thread_union.stack)
 
 /*
+ * how to get the current stack pointer from C
+ */
+register unsigned long current_stack_pointer asm ("sp");
+
+/*
  * how to get the thread information struct from C
  */
 static inline struct thread_info *current_thread_info(void) __attribute_const__;
Signature · 1 line
1.9.1
#2 lore raw

PATCH 2/4 arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/kernel/stacktrace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/stacktrace.c +1 -2
index 55437ba..407991b 100644
@@ -111,10 +111,9 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 		frame.sp = thread_saved_sp(tsk);
 		frame.pc = thread_saved_pc(tsk);
 	} else {
-		register unsigned long current_sp asm("sp");
 		data.no_sched_functions = 0;
 		frame.fp = (unsigned long)__builtin_frame_address(0);
-		frame.sp = current_sp;
+		frame.sp = current_stack_pointer;
 		frame.pc = (unsigned long)save_stack_trace_tsk;
 	}
 
Signature · 1 line
1.9.1
#3 lore raw

PATCH 3/4 arm64: LLVMLinux: Calculate current_thread_info from current_stack_pointer

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/include/asm/thread_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +2 -2
index e6b6094..c2432d2 100644
@@ -80,8 +80,8 @@ 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 *) \
+		(current_stack_pointer & ~(THREAD_SIZE - 1));
 }
 
 #define thread_saved_pc(tsk)	\
Signature · 1 line
1.9.1
#4 lore raw

Re: [PATCH 3/4] arm64: LLVMLinux: Calculate current_thread_info from current_stack_pointer

Hi,

Am 31.07.2014 01:57, schrieb behanw at converseincode.com:

Quoted 8 lines

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

Something went wrong with ? encoding here and in 2/4.

Quoted 9 lines
---
 arch/arm64/include/asm/thread_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +0 -0
index e6b6094..c2432d2 100644

arch/arm64/include/asm/thread_info.h static inline struct thread_info *current_thread_info(void) __attribute_const__; · line 83

Quoted 6 lines
arch/arm64/include/asm/thread_info.h +1 -2
@@ -80,8 +80,8 @@ 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 *) \

This is not a macro, so \ seems superfluous.

Looks okay otherwise.

Regards,
Andreas

Quoted 4 lines
arch/arm64/include/asm/thread_info.h +1 -0
+		(current_stack_pointer & ~(THREAD_SIZE - 1));
 }
 
 #define thread_saved_pc(tsk)	\
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 N?rnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imend?rffer; HRB 16746 AG N?rnberg
#5 lore raw

Re: [PATCH 3/4] arm64: LLVMLinux: Calculate current_thread_info from current_stack_pointer

Quoted 5 lines · Andreas F?rber

Hi,

Am 31.07.2014 01:57, schrieb behanw at converseincode.com:

Quoted 2 lines

From: Behan Webster <[email protected]>

Quoted 7 lines
Quoted 6 lines

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

Something went wrong with ? encoding here and in 2/4.

Yeah. That keeps happening. :(

Thanks.

Quoted 10 lines
Quoted 10 lines
---
  arch/arm64/include/asm/thread_info.h | 4 ++--
  1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +0 -0
index e6b6094..c2432d2 100644
@@ -80,8 +80,8 @@ static inline struct thread_info *current_thread_info(void) __attribute_const__;
 
Quoted 6 lines

arch/arm64/include/asm/thread_info.h static inline struct thread_info *current_thread_info(void) __attribute_const__; · line 83

Quoted 5 lines
arch/arm64/include/asm/thread_info.h +1 -2
  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 *) \

This is not a macro, so \ seems superfluous.

Doh. Indeed. Will fix.

Behan

Signature · 2 lines
Behan Webster
behanw at converseincode.com
#6 lore raw

PATCH 4/4 arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/kernel/traps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/traps.c +1 -2
index c43cfa9..0aeb316 100644
@@ -132,7 +132,6 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
 static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 {
 	struct stackframe frame;
-	const register unsigned long current_sp asm ("sp");
 
 	pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
 
@@ -145,7 +144,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 		frame.pc = regs->pc;
 	} else if (tsk == current) {
 		frame.fp = (unsigned long)__builtin_frame_address(0);
-		frame.sp = current_sp;
+		frame.sp = current_stack_pointer;
 		frame.pc = (unsigned long)dump_backtrace;
 	} else {
 		/*
Signature · 1 line
1.9.1
Reviewed-by on the v1 series
#7 lore raw
In reply to [email protected]
Quoted 9 lines · On Wed, Jul 30, 2014 at 4:57 PM, <[email protected]> wrote:

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Series:

Acked-by on the v1 series
#8 lore raw
In reply to [email protected]
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Once Andreas's comments have been addressed:

Please can you send a new series after the merge window?

Cheers,

Will

#9 lore raw
Quoted 17 lines · Will Deacon
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Quoted 5 lines

Once Andreas's comments have been addressed:

Please can you send a new series after the merge window?

Given that the ARM64 KVM guys are still actively breaking -next, and this is considerably smaller and lower risk than that, I think you can take it for 3.17?

-Olof

#10 lore raw
Quoted 20 lines · Olof Johansson
Quoted 19 lines · Will Deacon
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Once Andreas's comments have been addressed:

Quoted 7 lines
Quoted 3 lines

Please can you send a new series after the merge window?

Given that the ARM64 KVM guys are still actively breaking -next, and this is considerably smaller and lower risk than that, I think you can take it for 3.17?

Hey, those breakages are in the kvm tree not the arm64 tree! I'd really rather wait on these as I don't see the rush to get them in for 3.17 and it's not beyond the realms of possibility that they could cause problems for a particular version of GCC (at the very least, I'd need to re-run all the testing I've been doing).

Will

#11 lore raw
Quoted 29 lines · Will Deacon
Quoted 20 lines · Olof Johansson
Quoted 19 lines · Will Deacon
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Once Andreas's comments have been addressed:

Quoted 7 lines
Quoted 3 lines

Please can you send a new series after the merge window?

Given that the ARM64 KVM guys are still actively breaking -next, and this is considerably smaller and lower risk than that, I think you can take it for 3.17?

Quoted 5 lines

Hey, those breakages are in the kvm tree not the arm64 tree! I'd really rather wait on these as I don't see the rush to get them in for 3.17 and it's not beyond the realms of possibility that they could cause problems for a particular version of GCC (at the very least, I'd need to re-run all the testing I've been doing).

Yeah, it was somewhat tongue in cheek that made not have made it across the wire.

3.18 is fine with me too even though I find the concerns to be quite unlikely.

-Olof

#12 lore raw
In reply to Will Deacon
Quoted 16 lines · Will Deacon
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Quoted 5 lines

Once Andreas's comments have been addressed:

Please can you send a new series after the merge window?

Pity. I was hoping to get it in this merge window.

However, will resubmit for 3.18.

Thanks,

Behan

Signature · 2 lines
Behan Webster
behanw at converseincode.com
#13 lore raw

Hi Behan,

Quoted 17 lines · Behan Webster
Quoted 16 lines · Will Deacon
Quoted 15 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Quoted 8 lines
Quoted 5 lines

Once Andreas's comments have been addressed:

Please can you send a new series after the merge window?

Pity. I was hoping to get it in this merge window.

However, will resubmit for 3.18.

Any chance of a v2 for this series, please? If you address the comments pending for v1, I think it's good to merge.

Will

#14 lore raw
Quoted 22 lines · Will Deacon

Hi Behan,

Quoted 19 lines · Behan Webster
Quoted 18 lines · Will Deacon
Quoted 9 lines · behanw at converseincode.com

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Quoted 6 lines

Behan Webster (4):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

Once Andreas's comments have been addressed:

Quoted 8 lines
Quoted 6 lines
Quoted 3 lines

Please can you send a new series after the merge window?

Pity. I was hoping to get it in this merge window.

However, will resubmit for 3.18.

Any chance of a v2 for this series, please? If you address the comments pending for v1, I think it's good to merge.

Sure thing. 2 more named register patches added. Look for them at the end of the new patch series.

I kept missing you in Chicago. I was hoping to say "hi".

Behan

Signature · 2 lines
Behan Webster
behanw at converseincode.com
#15 lore raw

v2 cover LLVMLinux: Patches to enable the kernel to be compiled with clang/LLVM

In reply to Will Deacon

From: Behan Webster <[email protected]>

This patch set moves from using locally defined named registers to access the stack pointer to using a globally defined named register. This allows the code to work both with gcc and clang.

The LLVMLinux project aims to fully build the Linux kernel using both gcc and clang (the C front end for the LLVM compiler infrastructure project).

Behan Webster (5):
arm64: LLVMLinux: Add current_stack_pointer() for arm64
arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk
arm64: LLVMLinux: Calculate current_thread_info from
current_stack_pointer
arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c
arm64: LLVMLinux: Use global stack pointer in return_address()

Mark Charlebois (1):
arm64: LLVMLinux: Use global stack register variable for aarch64

 arch/arm64/include/asm/percpu.h      | 4 ++--
 arch/arm64/include/asm/thread_info.h | 9 +++++++--
 arch/arm64/kernel/return_address.c   | 3 +--
 arch/arm64/kernel/stacktrace.c       | 3 +--
 arch/arm64/kernel/traps.c            | 3 +--
 5 files changed, 12 insertions(+), 10 deletions(-)
Signature · 1 line
1.9.1
#16 lore raw

PATCH v2 1/6 arm64: LLVMLinux: Add current_stack_pointer() for arm64

From: Behan Webster <[email protected]>

Define a global named register for current_stack_pointer. The use of this new variable guarantees that both gcc and clang can access this register in C code.

---
 arch/arm64/include/asm/thread_info.h | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/include/asm/thread_info.h +5 -0
index 45108d8..356e037 100644
@@ -69,6 +69,11 @@ struct thread_info {
 #define init_stack		(init_thread_union.stack)
 
 /*
+ * how to get the current stack pointer from C
+ */
+register unsigned long current_stack_pointer asm ("sp");
+
+/*
  * how to get the thread information struct from C
  */
 static inline struct thread_info *current_thread_info(void) __attribute_const__;
Signature · 1 line
1.9.1
#17 lore raw

PATCH v2 2/6 arm64: LLVMLinux: Use current_stack_pointer in save_stack_trace_tsk

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/kernel/stacktrace.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/stacktrace.c +1 -2
index 55437ba..407991b 100644
@@ -111,10 +111,9 @@ void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace)
 		frame.sp = thread_saved_sp(tsk);
 		frame.pc = thread_saved_pc(tsk);
 	} else {
-		register unsigned long current_sp asm("sp");
 		data.no_sched_functions = 0;
 		frame.fp = (unsigned long)__builtin_frame_address(0);
-		frame.sp = current_sp;
+		frame.sp = current_stack_pointer;
 		frame.pc = (unsigned long)save_stack_trace_tsk;
 	}
 
Signature · 1 line
1.9.1
#18 lore raw

PATCH v2 3/6 arm64: LLVMLinux: Calculate current_thread_info from current_stack_pointer

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/include/asm/thread_info.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/thread_info.h +2 -2
index 356e037..459bf8e 100644
@@ -80,8 +80,8 @@ 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 *)
+		(current_stack_pointer & ~(THREAD_SIZE - 1));
 }
 
 #define thread_saved_pc(tsk)	\
Signature · 1 line
1.9.1
#19 lore raw

PATCH v2 4/6 arm64: LLVMLinux: Use current_stack_pointer in kernel/traps.c

In reply to [email protected]

From: Behan Webster <[email protected]>

Use the global current_stack_pointer to get the value of the stack pointer. This change supports being able to compile the kernel with both gcc and clang.

---
 arch/arm64/kernel/traps.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/traps.c +1 -2
index 02cd3f0..de1b085 100644
@@ -132,7 +132,6 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
 static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 {
 	struct stackframe frame;
-	const register unsigned long current_sp asm ("sp");
 
 	pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
 
@@ -145,7 +144,7 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
 		frame.pc = regs->pc;
 	} else if (tsk == current) {
 		frame.fp = (unsigned long)__builtin_frame_address(0);
-		frame.sp = current_sp;
+		frame.sp = current_stack_pointer;
 		frame.pc = (unsigned long)dump_backtrace;
 	} else {
 		/*
Signature · 1 line
1.9.1
#20 lore raw

PATCH v2 5/6 arm64: LLVMLinux: Use global stack register variable for aarch64

In reply to [email protected]

From: Mark Charlebois <[email protected]>

To support both Clang and GCC, use the global stack register variable vs a local register variable.

Author: Mark Charlebois <[email protected]>

---
 arch/arm64/include/asm/percpu.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm64/include/asm/percpu.h +2 -2
index 453a179..5279e57 100644
@@ -26,13 +26,13 @@ static inline void set_my_cpu_offset(unsigned long off)
 static inline unsigned long __my_cpu_offset(void)
 {
 	unsigned long off;
-	register unsigned long *sp asm ("sp");
 
 	/*
 	 * We want to allow caching the value, so avoid using volatile and
 	 * instead use a fake stack read to hazard against barrier().
 	 */
-	asm("mrs %0, tpidr_el1" : "=r" (off) : "Q" (*sp));
+	asm("mrs %0, tpidr_el1" : "=r" (off) :
+		"Q" (*(const unsigned long *)current_stack_pointer));
 
 	return off;
 }
Signature · 1 line
1.9.1
#21 lore raw

PATCH v2 6/6 arm64: LLVMLinux: Use global stack pointer in return_address()

In reply to [email protected]

From: Behan Webster <[email protected]>

The global register current_stack_pointer holds the current stack pointer. This change supports being able to compile the kernel with both gcc and clang.

Author: Mark Charlebois <[email protected]>

---
 arch/arm64/kernel/return_address.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
arch/arm64/kernel/return_address.c +1 -2
index 89102a6..6c4fd28 100644
@@ -36,13 +36,12 @@ void *return_address(unsigned int level)
 {
 	struct return_address_data data;
 	struct stackframe frame;
-	register unsigned long current_sp asm ("sp");
 
 	data.level = level + 2;
 	data.addr = NULL;
 
 	frame.fp = (unsigned long)__builtin_frame_address(0);
-	frame.sp = current_sp;
+	frame.sp = current_stack_pointer;
 	frame.pc = (unsigned long)return_address; /* dummy */
 
 	walk_stackframe(&frame, save_return_addr, &data);
Signature · 1 line
1.9.1