diff options
author | Vineet Gupta <vgupta@kernel.org> | 2020-05-12 22:18:08 -0700 |
---|---|---|
committer | Vineet Gupta <vgupta@kernel.org> | 2023-08-17 20:31:59 -0700 |
commit | cfca4b5abe0cc13f9d9f45f760efd8260e31200f (patch) | |
tree | bac7d51b9a322dbb17a9428c87aeae26aa5678ef /arch/arc/kernel | |
parent | fad84e39f116035ae8d550c6020107b8ac113b45 (diff) |
ARC: entry: use gp to cache task pointer (vs. r25)
The motivation is eventual ABI considerations for ARCv3 but even without
it this change us worthwhile as diffstat reduces 100 net lines
r25 is a callee saved register, normally not saved by entry code in
pt_regs. However because of its usage in CONFIG_ARC_CURR_IN_REG it needs
to be. This in turn requires a whole bunch of special casing when we
need to access r25. Then there is distinction between user mode r25 vs.
kernel mode r25 - hence distinct SAVE_CALLEE_SAVED_{USER,KERNEL}
Instead use gp which is a scratch register and thus saved already in entry
code. This cleans things up significantly and much nocer on eyes:
- SAVE_CALLEE_SAVED_{USER,KERNEL} are now exactly same
- no special user_r25 slot in pt_reggs
Note that typical global asm registers are callee-saved (r25), but gp is
not callee-saved thus needs additional -ffixed-<reg> toggle
Signed-off-by: Vineet Gupta <vgupta@kernel.org>
Diffstat (limited to 'arch/arc/kernel')
-rw-r--r-- | arch/arc/kernel/asm-offsets.c | 2 | ||||
-rw-r--r-- | arch/arc/kernel/ctx_sw.c | 13 | ||||
-rw-r--r-- | arch/arc/kernel/ctx_sw_asm.S | 2 | ||||
-rw-r--r-- | arch/arc/kernel/entry.S | 3 | ||||
-rw-r--r-- | arch/arc/kernel/process.c | 11 | ||||
-rw-r--r-- | arch/arc/kernel/ptrace.c | 2 |
6 files changed, 4 insertions, 29 deletions
diff --git a/arch/arc/kernel/asm-offsets.c b/arch/arc/kernel/asm-offsets.c index 0e884036ab74..37324fd9a72f 100644 --- a/arch/arc/kernel/asm-offsets.c +++ b/arch/arc/kernel/asm-offsets.c @@ -63,8 +63,6 @@ int main(void) DEFINE(PT_blink, offsetof(struct pt_regs, blink)); DEFINE(PT_lpe, offsetof(struct pt_regs, lp_end)); DEFINE(PT_lpc, offsetof(struct pt_regs, lp_count)); - DEFINE(PT_user_r25, offsetof(struct pt_regs, user_r25)); - DEFINE(SZ_CALLEE_REGS, sizeof(struct callee_regs)); DEFINE(SZ_PT_REGS, sizeof(struct pt_regs)); diff --git a/arch/arc/kernel/ctx_sw.c b/arch/arc/kernel/ctx_sw.c index bf16f777a0bc..40d89440b7e4 100644 --- a/arch/arc/kernel/ctx_sw.c +++ b/arch/arc/kernel/ctx_sw.c @@ -38,11 +38,7 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) "st.a r22, [sp, -4] \n\t" "st.a r23, [sp, -4] \n\t" "st.a r24, [sp, -4] \n\t" -#ifndef CONFIG_ARC_CURR_IN_REG "st.a r25, [sp, -4] \n\t" -#else - "sub sp, sp, 4 \n\t" /* usual r25 placeholder */ -#endif /* set ksp of outgoing task in tsk->thread.ksp */ #if KSP_WORD_OFF <= 255 @@ -58,7 +54,7 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) /* * setup _current_task with incoming tsk. - * optionally, set r25 to that as well + * optionally, set caching reg to that as well * For SMP extra work to get to &_current_task[cpu] * (open coded SET_CURR_TASK_ON_CPU) */ @@ -72,19 +68,14 @@ __switch_to(struct task_struct *prev_task, struct task_struct *next_task) "st %2, [r24] \n\t" #endif #ifdef CONFIG_ARC_CURR_IN_REG - "mov r25, %2 \n\t" + "mov gp, %2 \n\t" #endif /* get ksp of incoming task from tsk->thread.ksp */ "ld.as sp, [%2, %1] \n\t" /* start loading it's CALLEE reg file */ - -#ifndef CONFIG_ARC_CURR_IN_REG "ld.ab r25, [sp, 4] \n\t" -#else - "add sp, sp, 4 \n\t" -#endif "ld.ab r24, [sp, 4] \n\t" "ld.ab r23, [sp, 4] \n\t" "ld.ab r22, [sp, 4] \n\t" diff --git a/arch/arc/kernel/ctx_sw_asm.S b/arch/arc/kernel/ctx_sw_asm.S index 02c461484761..95cba6265e2b 100644 --- a/arch/arc/kernel/ctx_sw_asm.S +++ b/arch/arc/kernel/ctx_sw_asm.S @@ -49,7 +49,7 @@ __switch_to: SET_CURR_TASK_ON_CPU r1, r3 /* reload SP with kernel mode stack pointer in task->thread.ksp */ - ld.as sp, [r1, (TASK_THREAD + THREAD_KSP)/4] + ld.as sp, [r1, KSP_WORD_OFF] /* restore the registers */ RESTORE_CALLEE_SAVED_KERNEL diff --git a/arch/arc/kernel/entry.S b/arch/arc/kernel/entry.S index 54e91df678dd..cd26e0fa5044 100644 --- a/arch/arc/kernel/entry.S +++ b/arch/arc/kernel/entry.S @@ -210,7 +210,6 @@ trap_with_param: ; Save callee regs in case gdb wants to have a look ; SP will grow up by size of CALLEE Reg-File - ; NOTE: clobbers r12 SAVE_CALLEE_SAVED_USER ; save location of saved Callee Regs @ thread_struct->pc @@ -318,7 +317,7 @@ resume_user_mode_begin: ; tracer might call PEEKUSR(CALLEE reg) ; ; NOTE: SP will grow up by size of CALLEE Reg-File - SAVE_CALLEE_SAVED_USER ; clobbers r12 + SAVE_CALLEE_SAVED_USER ; save location of saved Callee Regs @ thread_struct->callee GET_CURR_TASK_FIELD_PTR TASK_THREAD, r10 diff --git a/arch/arc/kernel/process.c b/arch/arc/kernel/process.c index 980b71da2f61..96f591508142 100644 --- a/arch/arc/kernel/process.c +++ b/arch/arc/kernel/process.c @@ -162,7 +162,6 @@ asmlinkage void ret_from_fork(void); * | SP | * | orig_r0 | * | event/ECR | - * | user_r25 | * ------------------ <===== END of PAGE */ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) @@ -243,16 +242,6 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) */ c_callee->r25 = task_thread_info(p)->thr_ptr; -#ifdef CONFIG_ARC_CURR_IN_REG - /* - * setup usermode thread pointer #2: - * however for this special use of r25 in kernel, __switch_to() sets - * r25 for kernel needs and only in the final return path is usermode - * r25 setup, from pt_regs->user_r25. So set that up as well - */ - c_regs->user_r25 = c_callee->r25; -#endif - return 0; } diff --git a/arch/arc/kernel/ptrace.c b/arch/arc/kernel/ptrace.c index 2abdcd9b09e8..8226df3163fe 100644 --- a/arch/arc/kernel/ptrace.c +++ b/arch/arc/kernel/ptrace.c @@ -47,7 +47,6 @@ static const struct pt_regs_offset regoffset_table[] = { REG_OFFSET_NAME(sp), REG_OFFSET_NAME(orig_r0), REG_OFFSET_NAME(event), - REG_OFFSET_NAME(user_r25), REG_OFFSET_END, }; @@ -57,7 +56,6 @@ static const struct pt_regs_offset regoffset_table[] = { REG_OFFSET_NAME(orig_r0), REG_OFFSET_NAME(event), REG_OFFSET_NAME(bta), - REG_OFFSET_NAME(user_r25), REG_OFFSET_NAME(r26), REG_OFFSET_NAME(fp), REG_OFFSET_NAME(sp), |