Skip to content

Commit b203c67

Browse files
Tong Tiangenguoren83
authored andcommitted
csky: add arch support current_stack_pointer
To follow the existing per-arch conventions, using "current_stack_pointer" to set sp. This will let it be used in non-arch places(like HARDENED_USERCOPY). Refer to the implementation of riscv commit fdecfea ("riscv: Rename "sp_in_global" to "current_stack_pointer""). Link: https://lore.kernel.org/lkml/[email protected]/ Signed-off-by: Tong Tiangen <[email protected]> Signed-off-by: Guo Ren <[email protected]>
1 parent 9abf231 commit b203c67

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

arch/csky/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ config CSKY
99
select ARCH_USE_BUILTIN_BSWAP
1010
select ARCH_USE_QUEUED_RWLOCKS
1111
select ARCH_USE_QUEUED_SPINLOCKS
12+
select ARCH_HAS_CURRENT_STACK_POINTER
1213
select ARCH_INLINE_READ_LOCK if !PREEMPTION
1314
select ARCH_INLINE_READ_LOCK_BH if !PREEMPTION
1415
select ARCH_INLINE_READ_LOCK_IRQ if !PREEMPTION

arch/csky/include/asm/processor.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,4 +84,6 @@ unsigned long __get_wchan(struct task_struct *p);
8484

8585
#define cpu_relax() barrier()
8686

87+
register unsigned long current_stack_pointer __asm__("sp");
88+
8789
#endif /* __ASM_CSKY_PROCESSOR_H */

arch/csky/kernel/stacktrace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,9 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
2323
sp = user_stack_pointer(regs);
2424
pc = instruction_pointer(regs);
2525
} else if (task == NULL || task == current) {
26-
const register unsigned long current_sp __asm__ ("sp");
2726
const register unsigned long current_fp __asm__ ("r8");
2827
fp = current_fp;
29-
sp = current_sp;
28+
sp = current_stack_pointer;
3029
pc = (unsigned long)walk_stackframe;
3130
} else {
3231
/* task blocked in __switch_to */
@@ -68,8 +67,7 @@ static void notrace walk_stackframe(struct task_struct *task,
6867
sp = user_stack_pointer(regs);
6968
pc = instruction_pointer(regs);
7069
} else if (task == NULL || task == current) {
71-
const register unsigned long current_sp __asm__ ("sp");
72-
sp = current_sp;
70+
sp = current_stack_pointer;
7371
pc = (unsigned long)walk_stackframe;
7472
} else {
7573
/* task blocked in __switch_to */

0 commit comments

Comments
 (0)