[PATCH 1/2] MIPS: ptrace: Also initialize the FP context on individual FCSR writes

From: Maciej W. Rozycki
Date: Fri Oct 28 2016 - 03:20:24 EST


Complement commit ac9ad83bc318 ("MIPS: prevent FP context set via ptrace
being discarded") and also initialize the FP context whenever FCSR alone
is written with a PTRACE_POKEUSR request addressing FPC_CSR, rather than
along with the full FPU register set in the case of the PTRACE_SETFPREGS
request.

Signed-off-by: Maciej W. Rozycki <macro@xxxxxxxxxx>
---
Hi,

This is tricky to verify with modern user software as these days it all
uses PTRACE_SETFPREGS. I suppose I could tweak and rebuild `gdbserver' to
disable modern code and let it use fallback legacy support still present
there, but frankly I think the change is obviously correct.

Please apply.

Maciej

linux-mips-ptrace-fcsr-init-fp-ctx.diff
Index: linux-sfr-test/arch/mips/kernel/ptrace.c
===================================================================
--- linux-sfr-test.orig/arch/mips/kernel/ptrace.c 2016-10-22 01:29:44.000000000 +0100
+++ linux-sfr-test/arch/mips/kernel/ptrace.c 2016-10-22 01:44:38.740202000 +0100
@@ -817,6 +818,7 @@ long arch_ptrace(struct task_struct *chi
break;
#endif
case FPC_CSR:
+ init_fp_ctx(child);
ptrace_setfcr31(child, data);
break;
case DSP_BASE ... DSP_BASE + 5: {