@@ -17,14 +17,18 @@ int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data)
#ifdef CONFIG_PPC_FPU_REGS
flush_fp_to_thread(child);
- if (fpidx < (PT_FPSCR - PT_FPR0)) {
- if (IS_ENABLED(CONFIG_PPC32))
+ if (IS_ENABLED(CONFIG_PPC32)) {
+ if ((fpidx >> 1) < (PT_FPSCR - PT_FPR0) >> 1)
// On 32-bit the index we are passed refers to 32-bit words
*data = ((u32 *)child->thread.fp_state.fpr)[fpidx];
else
+ *data = ((u32 *)&child->thread.fp_state.fpscr)[fpidx & 1];
+ } else {
+ if (fpidx < (PT_FPSCR - PT_FPR0))
memcpy(data, &child->thread.TS_FPR(fpidx), sizeof(long));
- } else
- *data = child->thread.fp_state.fpscr;
+ else
+ *data = child->thread.fp_state.fpscr;
+ }
#else
*data = 0;
#endif
@@ -43,14 +47,18 @@ int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data)
#ifdef CONFIG_PPC_FPU_REGS
flush_fp_to_thread(child);
- if (fpidx < (PT_FPSCR - PT_FPR0)) {
- if (IS_ENABLED(CONFIG_PPC32))
+ if (IS_ENABLED(CONFIG_PPC32)) {
+ if ((fpidx >> 1) < (PT_FPSCR - PT_FPR0) >> 1)
// On 32-bit the index we are passed refers to 32-bit words
((u32 *)child->thread.fp_state.fpr)[fpidx] = data;
else
+ ((u32 *)&child->thread.fp_state.fpscr)[fpidx & 1] = data;
+ } else {
+ if (fpidx < (PT_FPSCR - PT_FPR0))
memcpy(&child->thread.TS_FPR(fpidx), &data, sizeof(long));
- } else
- child->thread.fp_state.fpscr = data;
+ else
+ child->thread.fp_state.fpscr = data;
+ }
#endif
return 0;