LoongArch: Remove unused kernel stack padding
authorJinyang He <hejinyang@loongson.cn>
Sat, 29 Oct 2022 08:29:31 +0000 (16:29 +0800)
committerHuacai Chen <chenhuacai@loongson.cn>
Sat, 29 Oct 2022 08:29:31 +0000 (16:29 +0800)
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 <git@xen0n.name>
Signed-off-by: Jinyang He <hejinyang@loongson.cn>
Signed-off-by: Huacai Chen <chenhuacai@loongson.cn>
arch/loongarch/include/asm/processor.h
arch/loongarch/include/asm/ptrace.h
arch/loongarch/kernel/head.S
arch/loongarch/kernel/process.c
arch/loongarch/kernel/switch.S

index 6954dc5d24e9df599b184f63487cd8a1b05a250f..7184f1dc61f2784b399b254c6618f7bde54ddb15 100644 (file)
@@ -191,7 +191,7 @@ static inline void flush_thread(void)
 unsigned long __get_wchan(struct task_struct *p);
 
 #define __KSTK_TOS(tsk) ((unsigned long)task_stack_page(tsk) + \
-                        THREAD_SIZE - 32 - sizeof(struct pt_regs))
+                        THREAD_SIZE - sizeof(struct pt_regs))
 #define task_pt_regs(tsk) ((struct pt_regs *)__KSTK_TOS(tsk))
 #define KSTK_EIP(tsk) (task_pt_regs(tsk)->csr_era)
 #define KSTK_ESP(tsk) (task_pt_regs(tsk)->regs[3])
index 17838c6b7ccd5193c2f673e7453311b2be4c4d86..82649a78fec1af2237ec5dd72a7f3f2d866a5db5 100644 (file)
@@ -133,7 +133,7 @@ static inline void die_if_kernel(const char *str, struct pt_regs *regs)
 #define current_pt_regs()                                              \
 ({                                                                     \
        unsigned long sp = (unsigned long)__builtin_frame_address(0);   \
-       (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1 - 32) - 1;      \
+       (struct pt_regs *)((sp | (THREAD_SIZE - 1)) + 1) - 1;           \
 })
 
 /* Helpers for working with the user stack pointer */
index 97425779ce9f3499ec27a8ef68b739cc002cc8a6..84970e2666588963719e377228d0f44e76ff0e1b 100644 (file)
@@ -84,10 +84,9 @@ SYM_CODE_START(kernel_entry)                 # kernel entry point
 
        la.pcrel        tp, init_thread_union
        /* Set the SP after an empty pt_regs.  */
-       PTR_LI          sp, (_THREAD_SIZE - 32 - PT_SIZE)
+       PTR_LI          sp, (_THREAD_SIZE - PT_SIZE)
        PTR_ADD         sp, sp, tp
        set_saved_sp    sp, t0, t1
-       PTR_ADDI        sp, sp, -4 * SZREG      # init stack pointer
 
        bl              start_kernel
        ASM_BUG()
index 1256e3582475fbc06f4f7b712252ddaf2eeb84e0..2526b68f1c0f0257071b5fe28ba0bc6670be0ba2 100644 (file)
@@ -129,7 +129,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args)
        unsigned long clone_flags = args->flags;
        struct pt_regs *childregs, *regs = current_pt_regs();
 
-       childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE - 32;
+       childksp = (unsigned long)task_stack_page(p) + THREAD_SIZE;
 
        /* set up new TSS. */
        childregs = (struct pt_regs *) childksp - 1;
@@ -236,7 +236,7 @@ bool in_task_stack(unsigned long stack, struct task_struct *task,
                        struct stack_info *info)
 {
        unsigned long begin = (unsigned long)task_stack_page(task);
-       unsigned long end = begin + THREAD_SIZE - 32;
+       unsigned long end = begin + THREAD_SIZE;
 
        if (stack < begin || stack >= end)
                return false;
index 43ebbc3990f73afd5fc05a357ec5882a0f63d48c..202a163cb32f6c1a0a8db030f28410aa526912fb 100644 (file)
@@ -26,7 +26,7 @@ SYM_FUNC_START(__switch_to)
        move    tp, a2
        cpu_restore_nonscratch a1
 
-       li.w            t0, _THREAD_SIZE - 32
+       li.w            t0, _THREAD_SIZE
        PTR_ADD         t0, t0, tp
        set_saved_sp    t0, t1, t2