Skip to content

Commit e11124d

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Remove r2_emul_return from struct thread_info
The r2_emul_return field in struct thread_info was used in order to take an alternate codepath when returning to userland, which (besides not implementing certain features) effectively used the eretnc instruction in place of eret. The difference is that eretnc doesn't clear LLBit, and therefore doesn't cause a linked load & store sequence to fail due to emulation like eret would. The reason eret would usually be used to clear LLBit is so that after context switching we ensure that a load performed by one task doesn't influence another task. However commit 7c151d3 ("MIPS: Make use of the ERETNC instruction on MIPS R6") which introduced the r2_emul_return field and conditional use of eretnc also for some reason began explicitly clearing LLBit during context switches - despite retaining the use of eret for everything but returns from the pre-r6 instruction emulation code. As LLBit is cleared upon context switches anyway, simplify this by using eretnc unconditionally for MIPSr6 kernels. This allows us to remove the 4 byte r2_emul_return boolean from struct thread_info, simplify the return to user code in entry.S and avoid the overhead of tracking & checking state which we don't need. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/14408/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent daa1017 commit e11124d

5 files changed

Lines changed: 4 additions & 22 deletions

File tree

‎arch/mips/include/asm/stackframe.h‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,9 +364,13 @@
364364

365365
.macro RESTORE_SP_AND_RET
366366
LONG_L sp, PT_R29(sp)
367+
#ifdef CONFIG_CPU_MIPSR6
368+
eretnc
369+
#else
367370
.set arch=r4000
368371
eret
369372
.set mips0
373+
#endif
370374
.endm
371375

372376
#endif

‎arch/mips/include/asm/thread_info.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ struct thread_info {
2727
unsigned long tp_value; /* thread pointer */
2828
__u32 cpu; /* current CPU */
2929
int preempt_count; /* 0 => preemptable, <0 => BUG */
30-
int r2_emul_return; /* 1 => Returning from R2 emulator */
3130
mm_segment_t addr_limit; /*
3231
* thread address space limit:
3332
* 0x7fffffff for user-thead

‎arch/mips/kernel/asm-offsets.c‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ void output_thread_info_defines(void)
9797
OFFSET(TI_TP_VALUE, thread_info, tp_value);
9898
OFFSET(TI_CPU, thread_info, cpu);
9999
OFFSET(TI_PRE_COUNT, thread_info, preempt_count);
100-
OFFSET(TI_R2_EMUL_RET, thread_info, r2_emul_return);
101100
OFFSET(TI_ADDR_LIMIT, thread_info, addr_limit);
102101
OFFSET(TI_REGS, thread_info, regs);
103102
DEFINE(_THREAD_SIZE, THREAD_SIZE);

‎arch/mips/kernel/entry.S‎

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,6 @@ resume_userspace:
4747
local_irq_disable # make sure we dont miss an
4848
# interrupt setting need_resched
4949
# between sampling and return
50-
#ifdef CONFIG_MIPSR2_TO_R6_EMULATOR
51-
lw k0, TI_R2_EMUL_RET($28)
52-
bnez k0, restore_all_from_r2_emul
53-
#endif
54-
5550
LONG_L a2, TI_FLAGS($28) # current->work
5651
andi t0, a2, _TIF_WORK_MASK # (ignoring syscall_trace)
5752
bnez t0, work_pending
@@ -120,19 +115,6 @@ restore_partial: # restore partial frame
120115
RESTORE_SP_AND_RET
121116
.set at
122117

123-
#ifdef CONFIG_MIPSR2_TO_R6_EMULATOR
124-
restore_all_from_r2_emul: # restore full frame
125-
.set noat
126-
sw zero, TI_R2_EMUL_RET($28) # reset it
127-
RESTORE_TEMP
128-
RESTORE_AT
129-
RESTORE_STATIC
130-
RESTORE_SOME
131-
LONG_L sp, PT_R29(sp)
132-
eretnc
133-
.set at
134-
#endif
135-
136118
work_pending:
137119
andi t0, a2, _TIF_NEED_RESCHED # a2 is preloaded with TI_FLAGS
138120
beqz t0, work_notifysig

‎arch/mips/kernel/traps.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,15 +1108,13 @@ asmlinkage void do_ri(struct pt_regs *regs)
11081108
switch (status) {
11091109
case 0:
11101110
case SIGEMT:
1111-
task_thread_info(current)->r2_emul_return = 1;
11121111
return;
11131112
case SIGILL:
11141113
goto no_r2_instr;
11151114
default:
11161115
process_fpemu_return(status,
11171116
&current->thread.cp0_baduaddr,
11181117
fcr31);
1119-
task_thread_info(current)->r2_emul_return = 1;
11201118
return;
11211119
}
11221120
}

0 commit comments

Comments
 (0)