Skip to content

Commit fdecfea

Browse files
keespalmer-dabbelt
authored andcommitted
riscv: Rename "sp_in_global" to "current_stack_pointer"
To follow the existing per-arch conventions, rename "sp_in_global" to "current_stack_pointer". This will let it be used in non-arch places (like HARDENED_USERCOPY). Signed-off-by: Kees Cook <keescook@chromium.org> Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
1 parent 60210a3 commit fdecfea

3 files changed

Lines changed: 5 additions & 4 deletions

File tree

arch/riscv/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ config RISCV
1616
select ARCH_ENABLE_HUGEPAGE_MIGRATION if HUGETLB_PAGE && MIGRATION
1717
select ARCH_ENABLE_SPLIT_PMD_PTLOCK if PGTABLE_LEVELS > 2
1818
select ARCH_HAS_BINFMT_FLAT
19+
select ARCH_HAS_CURRENT_STACK_POINTER
1920
select ARCH_HAS_DEBUG_VM_PGTABLE
2021
select ARCH_HAS_DEBUG_VIRTUAL if MMU
2122
select ARCH_HAS_DEBUG_WX

arch/riscv/include/asm/current.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ static __always_inline struct task_struct *get_current(void)
3333

3434
#define current get_current()
3535

36+
register unsigned long current_stack_pointer __asm__("sp");
37+
3638
#endif /* __ASSEMBLY__ */
3739

3840
#endif /* _ASM_RISCV_CURRENT_H */

arch/riscv/kernel/stacktrace.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@
1414

1515
#include <asm/stacktrace.h>
1616

17-
register unsigned long sp_in_global __asm__("sp");
18-
1917
#ifdef CONFIG_FRAME_POINTER
2018

2119
void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
@@ -30,7 +28,7 @@ void notrace walk_stackframe(struct task_struct *task, struct pt_regs *regs,
3028
pc = instruction_pointer(regs);
3129
} else if (task == NULL || task == current) {
3230
fp = (unsigned long)__builtin_frame_address(0);
33-
sp = sp_in_global;
31+
sp = current_stack_pointer;
3432
pc = (unsigned long)walk_stackframe;
3533
} else {
3634
/* task blocked in __switch_to */
@@ -78,7 +76,7 @@ void notrace walk_stackframe(struct task_struct *task,
7876
sp = user_stack_pointer(regs);
7977
pc = instruction_pointer(regs);
8078
} else if (task == NULL || task == current) {
81-
sp = sp_in_global;
79+
sp = current_stack_pointer;
8280
pc = (unsigned long)walk_stackframe;
8381
} else {
8482
/* task blocked in __switch_to */

0 commit comments

Comments
 (0)