Skip to content

Commit b40fa75

Browse files
MQ-mengqingchenhuacai
authored andcommitted
LoongArch: Remove unused kernel stack padding
The current LoongArch kernel stack is padded as if obeying the MIPS o32 calling convention (32 bytes), signifying the port's MIPS lineage but no longer making sense. Remove the padding for clarity. Reviewed-by: WANG Xuerui <[email protected]> Signed-off-by: Jinyang He <[email protected]> Signed-off-by: Huacai Chen <[email protected]>
1 parent 247f34f commit b40fa75

File tree

5 files changed

+6
-7
lines changed

5 files changed

+6
-7
lines changed

arch/loongarch/include/asm/processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ static inline void flush_thread(void)
191191
unsigned long __get_wchan(struct task_struct *p);
192192

193193
#define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \
194-
THREAD_SIZE - 32 - sizeof(struct pt_regs))
194+
THREAD_SIZE - sizeof(struct pt_regs))
195195
#define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk))
196196
#define KSTK_EIP(tsk) (task_pt_regs(tsk)->csr_era)
197197
#define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[3])

arch/loongarch/include/asm/ptrace.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs)
133133
#define current_pt_regs() \
134134
({ \
135135
unsigned long sp = (unsigned long)__builtin_frame_address(0); \
136-
(struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1; \
136+
(struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1) - 1; \
137137
})
138138

139139
/* Helpers for working with the user stack pointer */

arch/loongarch/kernel/head.S

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,9 @@ SYM_CODE_START(kernel_entry) # kernel entry point
8484

8585
la.pcrel tp, init_thread_union
8686
/* Set the SP after an empty pt_regs. */
87-
PTR_LI sp, (_THREAD_SIZE - 32 - PT_SIZE)
87+
PTR_LI sp, (_THREAD_SIZE - PT_SIZE)
8888
PTR_ADD sp, sp, tp
8989
set_saved_sp sp, t0, t1
90-
PTR_ADDI sp, sp, -4 * SZREG # init stack pointer
9190

9291
bl start_kernel
9392
ASM_BUG()

arch/loongarch/kernel/process.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
129129
unsigned long clone_flags = args->flags;
130130
struct pt_regs *childregs, *regs = current_pt_regs();
131131

132-
childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
132+
childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
133133

134134
/* set up new TSS. */
135135
childregs = (struct pt_regs *) childksp - 1;
@@ -236,7 +236,7 @@ bool in_task_stack(unsigned long stack, struct task_struct *task,
236236
struct stack_info *info)
237237
{
238238
unsigned long begin = (unsigned long)task_stack_page(task);
239-
unsigned long end = begin + THREAD_SIZE - 32;
239+
unsigned long end = begin + THREAD_SIZE;
240240

241241
if (stack < begin || stack >= end)
242242
return false;

arch/loongarch/kernel/switch.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ SYM_FUNC_START(__switch_to)
2626
move tp, a2
2727
cpu_restore_nonscratch a1
2828

29-
li.w t0, _THREAD_SIZE - 32
29+
li.w t0, _THREAD_SIZE
3030
PTR_ADD t0, t0, tp
3131
set_saved_sp t0, t1, t2
3232

0 commit comments

Comments
 (0)