]> git.karo-electronics.de Git - linux-beck.git/commitdiff
MIPS: Disable preemption during prctl(PR_SET_FP_MODE, ...)
authorPaul Burton <paul.burton@imgtec.com>
Thu, 21 Apr 2016 11:43:57 +0000 (12:43 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Fri, 13 May 2016 13:30:25 +0000 (15:30 +0200)
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: 9791554b45a2 ("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>
arch/mips/kernel/process.c

index f57891616357a1e940104a0ef9f577c6480206e0..dcccc6dc68e64d20347eb8e345f9feac4bb78276 100644 (file)
@@ -597,6 +597,9 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
        if (!(value & PR_FP_MODE_FR) && cpu_has_fpu && cpu_has_mips_r6)
                return -EOPNOTSUPP;
 
+       /* Proceed with the mode switch */
+       preempt_disable();
+
        /* Save FP & vector context, then disable FPU & MSA */
        if (task->signal == current->signal)
                lose_fpu(1);
@@ -655,6 +658,7 @@ int mips_set_process_fp_mode(struct task_struct *task, unsigned int value)
 
        /* Allow threads to use FP again */
        atomic_set(&task->mm->context.fp_mode_switching, 0);
+       preempt_enable();
 
        return 0;
 }