diff options
author | Maciej W. Rozycki <macro@linux-mips.org> | 2015-05-12 10:20:57 -0400 |
---|---|---|
committer | Ralf Baechle <ralf@linux-mips.org> | 2015-05-12 17:15:49 -0400 |
commit | 03dce595270f22d59a6f37e9170287c1afd94bc2 (patch) | |
tree | 68e8ae5e92d6dda9b32be45d72025b095913671d | |
parent | 620b155034570f577470cf5309f741bac6a6e32b (diff) |
MIPS: Fix a preemption issue with thread's FPU defaults
Fix "BUG: using smp_processor_id() in preemptible" reported in accesses
to thread's FPU defaults: the value to initialise FSCR to at program
startup, the FCSR r/w mask and the contents of FIR in full FPU
emulation, removing a regression introduced with 9b26616c [MIPS: Respect
the ISA level in FCSR handling] and f6843626 [MIPS: math-emu: Set FIR
feature flags for full emulation].
Use `boot_cpu_data' to obtain the data from, following the approach that
`cpu_has_*' macros take and avoiding the call to `smp_processor_id' made
in the reference to `current_cpu_data'. The contents of FSCR have to be
consistent across processors in an SMP system, the settings there must
not change as a thread is migrated across processors. And the contents
of FIR are guaranteed to be consistent in FPU emulation, by definition.
Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org>
Tested-by: Ezequiel Garcia <ezequiel.garcia@imgtec.com>
Tested-by: Paul Martin <paul.martin@codethink.co.uk>
Cc: Markos Chandras <Markos.Chandras@imgtec.com>
Cc: James Hogan <james.hogan@imgtec.com>
Cc: linux-mips@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/10030/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
-rw-r--r-- | arch/mips/include/asm/elf.h | 4 | ||||
-rw-r--r-- | arch/mips/kernel/ptrace.c | 2 | ||||
-rw-r--r-- | arch/mips/math-emu/cp1emu.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/arch/mips/include/asm/elf.h b/arch/mips/include/asm/elf.h index a594d8ed9698..f19e890b99d2 100644 --- a/arch/mips/include/asm/elf.h +++ b/arch/mips/include/asm/elf.h | |||
@@ -304,7 +304,7 @@ do { \ | |||
304 | \ | 304 | \ |
305 | current->thread.abi = &mips_abi; \ | 305 | current->thread.abi = &mips_abi; \ |
306 | \ | 306 | \ |
307 | current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ | 307 | current->thread.fpu.fcr31 = boot_cpu_data.fpu_csr31; \ |
308 | } while (0) | 308 | } while (0) |
309 | 309 | ||
310 | #endif /* CONFIG_32BIT */ | 310 | #endif /* CONFIG_32BIT */ |
@@ -366,7 +366,7 @@ do { \ | |||
366 | else \ | 366 | else \ |
367 | current->thread.abi = &mips_abi; \ | 367 | current->thread.abi = &mips_abi; \ |
368 | \ | 368 | \ |
369 | current->thread.fpu.fcr31 = current_cpu_data.fpu_csr31; \ | 369 | current->thread.fpu.fcr31 = boot_cpu_data.fpu_csr31; \ |
370 | \ | 370 | \ |
371 | p = personality(current->personality); \ | 371 | p = personality(current->personality); \ |
372 | if (p != PER_LINUX32 && p != PER_LINUX) \ | 372 | if (p != PER_LINUX32 && p != PER_LINUX) \ |
diff --git a/arch/mips/kernel/ptrace.c b/arch/mips/kernel/ptrace.c index d544e774eea6..e933a309f2ea 100644 --- a/arch/mips/kernel/ptrace.c +++ b/arch/mips/kernel/ptrace.c | |||
@@ -176,7 +176,7 @@ int ptrace_setfpregs(struct task_struct *child, __u32 __user *data) | |||
176 | 176 | ||
177 | __get_user(value, data + 64); | 177 | __get_user(value, data + 64); |
178 | fcr31 = child->thread.fpu.fcr31; | 178 | fcr31 = child->thread.fpu.fcr31; |
179 | mask = current_cpu_data.fpu_msk31; | 179 | mask = boot_cpu_data.fpu_msk31; |
180 | child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); | 180 | child->thread.fpu.fcr31 = (value & ~mask) | (fcr31 & mask); |
181 | 181 | ||
182 | /* FIR may not be written. */ | 182 | /* FIR may not be written. */ |
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c index d31c537ace1d..22b9b2cb9219 100644 --- a/arch/mips/math-emu/cp1emu.c +++ b/arch/mips/math-emu/cp1emu.c | |||
@@ -889,7 +889,7 @@ static inline void cop1_cfc(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
889 | break; | 889 | break; |
890 | 890 | ||
891 | case FPCREG_RID: | 891 | case FPCREG_RID: |
892 | value = current_cpu_data.fpu_id; | 892 | value = boot_cpu_data.fpu_id; |
893 | break; | 893 | break; |
894 | 894 | ||
895 | default: | 895 | default: |
@@ -921,7 +921,7 @@ static inline void cop1_ctc(struct pt_regs *xcp, struct mips_fpu_struct *ctx, | |||
921 | (void *)xcp->cp0_epc, MIPSInst_RT(ir), value); | 921 | (void *)xcp->cp0_epc, MIPSInst_RT(ir), value); |
922 | 922 | ||
923 | /* Preserve read-only bits. */ | 923 | /* Preserve read-only bits. */ |
924 | mask = current_cpu_data.fpu_msk31; | 924 | mask = boot_cpu_data.fpu_msk31; |
925 | fcr31 = (value & ~mask) | (fcr31 & mask); | 925 | fcr31 = (value & ~mask) | (fcr31 & mask); |
926 | break; | 926 | break; |
927 | 927 | ||