aboutsummaryrefslogtreecommitdiffstats
path: root/arch/mips/math-emu/cp1emu.c
diff options
context:
space:
mode:
authorMaciej W. Rozycki <macro@linux-mips.org>2015-04-03 18:27:48 -0400
committerRalf Baechle <ralf@linux-mips.org>2015-04-07 19:10:37 -0400
commit9b26616c8d9dae53fbac7f7cb2c6dd1308102976 (patch)
treed4249bd953d4fa955cecd1283cc0f518df83f8a2 /arch/mips/math-emu/cp1emu.c
parent232b6ec5df874236166fb0167cd473601a631715 (diff)
MIPS: Respect the ISA level in FCSR handling
Define the central place the default FCSR value is set from, initialised in `cpu_probe'. Determine the FCSR mask applied to values written to the register with CTC1 in the full emulation mode and via ptrace(2), according to the ISA level of processor hardware or the writability of bits 31:18 if actual FPU hardware is used. Software may rely on FCSR bits whose functions our emulator does not implement, so it should not allow them to be set or software may get confused. For ptrace(2) it's just sanity. [ralf@linux-mips.org: Fixed double inclusion of <asm/current.h>.] Signed-off-by: Maciej W. Rozycki <macro@linux-mips.org> Cc: linux-mips@linux-mips.org Patchwork: https://patchwork.linux-mips.org/patch/9711/ Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
Diffstat (limited to 'arch/mips/math-emu/cp1emu.c')
-rw-r--r--arch/mips/math-emu/cp1emu.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/arch/mips/math-emu/cp1emu.c b/arch/mips/math-emu/cp1emu.c
index 3a90170a6277..d31c537ace1d 100644
--- a/arch/mips/math-emu/cp1emu.c
+++ b/arch/mips/math-emu/cp1emu.c
@@ -908,6 +908,7 @@ static inline void cop1_ctc(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
908{ 908{
909 u32 fcr31 = ctx->fcr31; 909 u32 fcr31 = ctx->fcr31;
910 u32 value; 910 u32 value;
911 u32 mask;
911 912
912 if (MIPSInst_RT(ir) == 0) 913 if (MIPSInst_RT(ir) == 0)
913 value = 0; 914 value = 0;
@@ -919,9 +920,9 @@ static inline void cop1_ctc(struct pt_regs *xcp, struct mips_fpu_struct *ctx,
919 pr_debug("%p gpr[%d]->csr=%08x\n", 920 pr_debug("%p gpr[%d]->csr=%08x\n",
920 (void *)xcp->cp0_epc, MIPSInst_RT(ir), value); 921 (void *)xcp->cp0_epc, MIPSInst_RT(ir), value);
921 922
922 /* Don't write unsupported bits. */ 923 /* Preserve read-only bits. */
923 fcr31 = value & 924 mask = current_cpu_data.fpu_msk31;
924 ~(FPU_CSR_RSVD | FPU_CSR_ABS2008 | FPU_CSR_NAN2008); 925 fcr31 = (value & ~mask) | (fcr31 & mask);
925 break; 926 break;
926 927
927 case FPCREG_FENR: 928 case FPCREG_FENR: