Skip to content

Commit bd239f1

Browse files
paulburtonralfbaechle
authored andcommitted
MIPS: Disable preemption during prctl(PR_SET_FP_MODE, ...)
Whilst a PR_SET_FP_MODE prctl is performed there are decisions made based upon whether the task is executing on the current CPU. This may change if we're preempted, so disable preemption to avoid such changes for the lifetime of the mode switch. Signed-off-by: Paul Burton <paul.burton@imgtec.com> Fixes: 9791554 ("MIPS,prctl: add PR_[GS]ET_FP_MODE prctl options for MIPS") Reviewed-by: Maciej W. Rozycki <macro@imgtec.com> Tested-by: Aurelien Jarno <aurelien@aurel32.net> Cc: Adam Buchbinder <adam.buchbinder@gmail.com> Cc: James Hogan <james.hogan@imgtec.com> Cc: stable <stable@vger.kernel.org> # v4.0+ Cc: linux-mips@linux-mips.org Cc: linux-kernel@vger.kernel.org Patchwork: https://patchwork.linux-mips.org/patch/13144/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
1 parent e70ac02 commit bd239f1

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

arch/mips/kernel/process.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,9 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
597597
if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
598598
return -EOPNOTSUPP;
599599

600+
/* Proceed with the mode switch */
601+
preempt_disable();
602+
600603
/* Save FP & vector context, then disable FPU & MSA */
601604
if (task->signal == current->signal)
602605
lose_fpu(1);
@@ -655,6 +658,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
655658

656659
/* Allow threads to use FP again */
657660
atomic_set(&task->mm->context.fp_mode_switching, 0);
661+
preempt_enable();
658662

659663
return 0;
660664
}

0 commit comments

Comments
 (0)