|
@@ -422,7 +422,7 @@ static int gpr64_set(struct task_struct *target,
|
|
|
/*
|
|
|
* Copy the floating-point context to the supplied NT_PRFPREG buffer,
|
|
|
* !CONFIG_CPU_HAS_MSA variant. FP context's general register slots
|
|
|
- * correspond 1:1 to buffer slots.
|
|
|
+ * correspond 1:1 to buffer slots. Only general registers are copied.
|
|
|
*/
|
|
|
static int fpr_get_fpa(struct task_struct *target,
|
|
|
unsigned int *pos, unsigned int *count,
|
|
@@ -430,13 +430,14 @@ static int fpr_get_fpa(struct task_struct *target,
|
|
|
{
|
|
|
return user_regset_copyout(pos, count, kbuf, ubuf,
|
|
|
&target->thread.fpu,
|
|
|
- 0, sizeof(elf_fpregset_t));
|
|
|
+ 0, NUM_FPU_REGS * sizeof(elf_fpreg_t));
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Copy the floating-point context to the supplied NT_PRFPREG buffer,
|
|
|
* CONFIG_CPU_HAS_MSA variant. Only lower 64 bits of FP context's
|
|
|
- * general register slots are copied to buffer slots.
|
|
|
+ * general register slots are copied to buffer slots. Only general
|
|
|
+ * registers are copied.
|
|
|
*/
|
|
|
static int fpr_get_msa(struct task_struct *target,
|
|
|
unsigned int *pos, unsigned int *count,
|
|
@@ -458,20 +459,29 @@ static int fpr_get_msa(struct task_struct *target,
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
|
-/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */
|
|
|
+/*
|
|
|
+ * Copy the floating-point context to the supplied NT_PRFPREG buffer.
|
|
|
+ * Choose the appropriate helper for general registers, and then copy
|
|
|
+ * the FCSR register separately.
|
|
|
+ */
|
|
|
static int fpr_get(struct task_struct *target,
|
|
|
const struct user_regset *regset,
|
|
|
unsigned int pos, unsigned int count,
|
|
|
void *kbuf, void __user *ubuf)
|
|
|
{
|
|
|
+ const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t);
|
|
|
int err;
|
|
|
|
|
|
- /* XXX fcr31 */
|
|
|
-
|
|
|
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
|
|
|
err = fpr_get_fpa(target, &pos, &count, &kbuf, &ubuf);
|
|
|
else
|
|
|
err = fpr_get_msa(target, &pos, &count, &kbuf, &ubuf);
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ err = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
|
|
|
+ &target->thread.fpu.fcr31,
|
|
|
+ fcr31_pos, fcr31_pos + sizeof(u32));
|
|
|
|
|
|
return err;
|
|
|
}
|
|
@@ -479,7 +489,7 @@ static int fpr_get(struct task_struct *target,
|
|
|
/*
|
|
|
* Copy the supplied NT_PRFPREG buffer to the floating-point context,
|
|
|
* !CONFIG_CPU_HAS_MSA variant. Buffer slots correspond 1:1 to FP
|
|
|
- * context's general register slots.
|
|
|
+ * context's general register slots. Only general registers are copied.
|
|
|
*/
|
|
|
static int fpr_set_fpa(struct task_struct *target,
|
|
|
unsigned int *pos, unsigned int *count,
|
|
@@ -487,13 +497,14 @@ static int fpr_set_fpa(struct task_struct *target,
|
|
|
{
|
|
|
return user_regset_copyin(pos, count, kbuf, ubuf,
|
|
|
&target->thread.fpu,
|
|
|
- 0, sizeof(elf_fpregset_t));
|
|
|
+ 0, NUM_FPU_REGS * sizeof(elf_fpreg_t));
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* Copy the supplied NT_PRFPREG buffer to the floating-point context,
|
|
|
* CONFIG_CPU_HAS_MSA variant. Buffer slots are copied to lower 64
|
|
|
- * bits only of FP context's general register slots.
|
|
|
+ * bits only of FP context's general register slots. Only general
|
|
|
+ * registers are copied.
|
|
|
*/
|
|
|
static int fpr_set_msa(struct task_struct *target,
|
|
|
unsigned int *pos, unsigned int *count,
|
|
@@ -518,6 +529,8 @@ static int fpr_set_msa(struct task_struct *target,
|
|
|
|
|
|
/*
|
|
|
* Copy the supplied NT_PRFPREG buffer to the floating-point context.
|
|
|
+ * Choose the appropriate helper for general registers, and then copy
|
|
|
+ * the FCSR register separately.
|
|
|
*
|
|
|
* We optimize for the case where `count % sizeof(elf_fpreg_t) == 0',
|
|
|
* which is supposed to have been guaranteed by the kernel before
|
|
@@ -530,18 +543,30 @@ static int fpr_set(struct task_struct *target,
|
|
|
unsigned int pos, unsigned int count,
|
|
|
const void *kbuf, const void __user *ubuf)
|
|
|
{
|
|
|
+ const int fcr31_pos = NUM_FPU_REGS * sizeof(elf_fpreg_t);
|
|
|
+ u32 fcr31;
|
|
|
int err;
|
|
|
|
|
|
BUG_ON(count % sizeof(elf_fpreg_t));
|
|
|
|
|
|
- /* XXX fcr31 */
|
|
|
-
|
|
|
init_fp_ctx(target);
|
|
|
|
|
|
if (sizeof(target->thread.fpu.fpr[0]) == sizeof(elf_fpreg_t))
|
|
|
err = fpr_set_fpa(target, &pos, &count, &kbuf, &ubuf);
|
|
|
else
|
|
|
err = fpr_set_msa(target, &pos, &count, &kbuf, &ubuf);
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ if (count > 0) {
|
|
|
+ err = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
|
|
|
+ &fcr31,
|
|
|
+ fcr31_pos, fcr31_pos + sizeof(u32));
|
|
|
+ if (err)
|
|
|
+ return err;
|
|
|
+
|
|
|
+ ptrace_setfcr31(target, fcr31);
|
|
|
+ }
|
|
|
|
|
|
return err;
|
|
|
}
|