Skip to content

Commit 7daef8f

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: consistently clear MSA flags when starting & copying threads
The TIF_MSA_CTX_LIVE flag (indicating that a task has MSA context which needs to be preserved) was being cleared in start_thread, but the TIF_USEDMSA flag (indicating that a task has used MSA in this timeslice) was not. In copy_thread neither flag was cleared, but both need to be. Without clearing these flags the kernel will proceed to attempt to save MSA context when the task is context switched out, and if the task had not used MSA in the meantime then it will fail because MSA or the FPU are disabled. The end result is typically: do_cpu invoked from kernel context![#1]: CPU: 0 PID: 99 Comm: sh Not tainted 3.16.0-rc4-00025-g6dc9476-dirty #88 task: 8f23dc60 ti: 8f1d8000 task.ti: 8f1d8000 ... Call Trace: [<8010edbc>] resume+0x5c/0x280 [<80481e0c>] __schedule+0x370/0x800 [<80104838>] work_resched+0x8/0x2c Fix by consistently clearing both flags in both functions. Signed-off-by: Paul Burton <[email protected]> Cc: [email protected] Patchwork: https://patchwork.linux-mips.org/patch/7309/ Signed-off-by: Ralf Baechle <[email protected]>
1 parent 37cddff commit 7daef8f

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

arch/mips/kernel/process.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ void start_thread(struct pt_regs * regs, unsigned long pc, unsigned long sp)
6666
clear_used_math();
6767
clear_fpu_owner();
6868
init_dsp();
69+
clear_thread_flag(TIF_USEDMSA);
6970
clear_thread_flag(TIF_MSA_CTX_LIVE);
7071
disable_msa();
7172
regs->cp0_epc = pc;
@@ -141,6 +142,8 @@ int copy_thread(unsigned long clone_flags, unsigned long usp,
141142
childregs->cp0_status &= ~(ST0_CU2|ST0_CU1);
142143

143144
clear_tsk_thread_flag(p, TIF_USEDFPU);
145+
clear_tsk_thread_flag(p, TIF_USEDMSA);
146+
clear_tsk_thread_flag(p, TIF_MSA_CTX_LIVE);
144147

145148
#ifdef CONFIG_MIPS_MT_FPAFF
146149
clear_tsk_thread_flag(p, TIF_FPUBOUND);

0 commit comments

Comments
 (0)