* [PATCH 3.18] MIPS: Factor out NT_PRFPREG regset access helpers
@ 2018-01-11 0:25 Maciej W. Rozycki
2018-01-11 10:17 ` Greg KH
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-01-11 0:25 UTC (permalink / raw)
To: stable; +Cc: Ralf Baechle
In preparation to fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit
FP registers for FP regset") FCSR access regression factor out
NT_PRFPREG regset access helpers for the non-MSA and the MSA variants
respectively, to avoid having to deal with excessive indentation in the
actual fix.
No functional change, however use `target->thread.fpu.fpr[0]' rather
than `target->thread.fpu.fpr[i]' for FGR holding type size determination
as there's no `i' variable to refer to anymore, and for the factored out
`i' variable declaration use `unsigned int' rather than `unsigned' as
its type, following the common style.
Signed-off-by: Maciej W. Rozycki <macro@mips.com>
Fixes: 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset")
Cc: James Hogan <james.hogan@mips.com>
Cc: Paul Burton <Paul.Burton@mips.com>
Cc: Alex Smith <alex@alex-smith.me.uk>
Cc: Dave Martin <Dave.Martin@arm.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org # v3.15+
Patchwork: https://patchwork.linux-mips.org/patch/17925/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
---
Hi,
This is a (mechanically regenerated) version of commit a03fe72572c1 for
3.18-stable and before. No functional changes. Please apply.
Maciej
---
arch/mips/kernel/ptrace.c | 106 +++++++++++++++++++++++++++++++++++-----------
1 file changed, 82 insertions(+), 24 deletions(-)
linux-mips-nt-prfpreg-factor-out.diff
Index: linux-stable-el/arch/mips/kernel/ptrace.c
===================================================================
--- linux-stable-el.orig/arch/mips/kernel/ptrace.c 2018-01-10 18:16:16.000000000 +0000
+++ linux-stable-el/arch/mips/kernel/ptrace.c 2018-01-10 20:00:49.092601000 +0000
@@ -400,25 +400,36 @@ static int gpr64_set(struct task_struct
#endif /* CONFIG_64BIT */
-static int fpr_get(struct task_struct *target,
- const struct user_regset *regset,
- unsigned int pos, unsigned int count,
- void *kbuf, void __user *ubuf)
+/*
+ * 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.
+ */
+static int fpr_get_fpa(struct task_struct *target,
+ unsigned int *pos, unsigned int *count,
+ void **kbuf, void __user **ubuf)
{
- unsigned i;
- int err;
- u64 fpr_val;
-
- /* XXX fcr31 */
+ return user_regset_copyout(pos, count, kbuf, ubuf,
+ &target->thread.fpu,
+ 0, sizeof(elf_fpregset_t));
+}
- if (sizeof(target->thread.fpu.fpr[i]) == sizeof(elf_fpreg_t))
- return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
- &target->thread.fpu,
- 0, sizeof(elf_fpregset_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.
+ */
+static int fpr_get_msa(struct task_struct *target,
+ unsigned int *pos, unsigned int *count,
+ void **kbuf, void __user **ubuf)
+{
+ unsigned int i;
+ u64 fpr_val;
+ int err;
for (i = 0; i < NUM_FPU_REGS; i++) {
fpr_val = get_fpr64(&target->thread.fpu.fpr[i], 0);
- err = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+ err = user_regset_copyout(pos, count, kbuf, ubuf,
&fpr_val, i * sizeof(elf_fpreg_t),
(i + 1) * sizeof(elf_fpreg_t));
if (err)
@@ -428,25 +439,54 @@ static int fpr_get(struct task_struct *t
return 0;
}
-static int fpr_set(struct task_struct *target,
+/* Copy the floating-point context to the supplied NT_PRFPREG buffer. */
+static int fpr_get(struct task_struct *target,
const struct user_regset *regset,
unsigned int pos, unsigned int count,
- const void *kbuf, const void __user *ubuf)
+ void *kbuf, void __user *ubuf)
{
- unsigned i;
int err;
- u64 fpr_val;
/* XXX fcr31 */
- if (sizeof(target->thread.fpu.fpr[i]) == sizeof(elf_fpreg_t))
- return user_regset_copyin(&pos, &count, &kbuf, &ubuf,
- &target->thread.fpu,
- 0, sizeof(elf_fpregset_t));
+ 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);
+
+ return err;
+}
+
+/*
+ * 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.
+ */
+static int fpr_set_fpa(struct task_struct *target,
+ unsigned int *pos, unsigned int *count,
+ const void **kbuf, const void __user **ubuf)
+{
+ return user_regset_copyin(pos, count, kbuf, ubuf,
+ &target->thread.fpu,
+ 0, sizeof(elf_fpregset_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.
+ */
+static int fpr_set_msa(struct task_struct *target,
+ unsigned int *pos, unsigned int *count,
+ const void **kbuf, const void __user **ubuf)
+{
+ unsigned int i;
+ u64 fpr_val;
+ int err;
BUILD_BUG_ON(sizeof(fpr_val) != sizeof(elf_fpreg_t));
- for (i = 0; i < NUM_FPU_REGS && count >= sizeof(elf_fpreg_t); i++) {
- err = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+ for (i = 0; i < NUM_FPU_REGS && *count >= sizeof(elf_fpreg_t); i++) {
+ err = user_regset_copyin(pos, count, kbuf, ubuf,
&fpr_val, i * sizeof(elf_fpreg_t),
(i + 1) * sizeof(elf_fpreg_t));
if (err)
@@ -457,6 +497,24 @@ static int fpr_set(struct task_struct *t
return 0;
}
+/* Copy the supplied NT_PRFPREG buffer to the floating-point context. */
+static int fpr_set(struct task_struct *target,
+ const struct user_regset *regset,
+ unsigned int pos, unsigned int count,
+ const void *kbuf, const void __user *ubuf)
+{
+ int err;
+
+ /* XXX fcr31 */
+
+ 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);
+
+ return err;
+}
+
enum mips_regset {
REGSET_GPR,
REGSET_FPR,
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3.18] MIPS: Factor out NT_PRFPREG regset access helpers
2018-01-11 0:25 [PATCH 3.18] MIPS: Factor out NT_PRFPREG regset access helpers Maciej W. Rozycki
@ 2018-01-11 10:17 ` Greg KH
2018-01-11 15:18 ` Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Greg KH @ 2018-01-11 10:17 UTC (permalink / raw)
To: Maciej W. Rozycki; +Cc: stable, Ralf Baechle
On Thu, Jan 11, 2018 at 12:25:31AM +0000, Maciej W. Rozycki wrote:
> In preparation to fix a commit 72b22bbad1e7 ("MIPS: Don't assume 64-bit
> FP registers for FP regset") FCSR access regression factor out
> NT_PRFPREG regset access helpers for the non-MSA and the MSA variants
> respectively, to avoid having to deal with excessive indentation in the
> actual fix.
>
> No functional change, however use `target->thread.fpu.fpr[0]' rather
> than `target->thread.fpu.fpr[i]' for FGR holding type size determination
> as there's no `i' variable to refer to anymore, and for the factored out
> `i' variable declaration use `unsigned int' rather than `unsigned' as
> its type, following the common style.
>
> Signed-off-by: Maciej W. Rozycki <macro@mips.com>
> Fixes: 72b22bbad1e7 ("MIPS: Don't assume 64-bit FP registers for FP regset")
> Cc: James Hogan <james.hogan@mips.com>
> Cc: Paul Burton <Paul.Burton@mips.com>
> Cc: Alex Smith <alex@alex-smith.me.uk>
> Cc: Dave Martin <Dave.Martin@arm.com>
> Cc: linux-mips@linux-mips.org
> Cc: linux-kernel@vger.kernel.org
> Cc: stable@vger.kernel.org # v3.15+
> Patchwork: https://patchwork.linux-mips.org/patch/17925/
> Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
> ---
> Hi,
>
> This is a (mechanically regenerated) version of commit a03fe72572c1 for
> 3.18-stable and before. No functional changes. Please apply.
Can you send all of these as a patch series, as I have no idea what
order to apply these in and my first guess was all wrong, and nothing
applied at all :(
thanks,
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 3.18] MIPS: Factor out NT_PRFPREG regset access helpers
2018-01-11 10:17 ` Greg KH
@ 2018-01-11 15:18 ` Maciej W. Rozycki
0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-01-11 15:18 UTC (permalink / raw)
To: Greg KH; +Cc: stable, Ralf Baechle
On Thu, 11 Jan 2018, Greg KH wrote:
> Can you send all of these as a patch series, as I have no idea what
> order to apply these in and my first guess was all wrong, and nothing
> applied at all :(
OK, will do, with a dummy introduction. Apologies for the complication.
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-01-11 15:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-11 0:25 [PATCH 3.18] MIPS: Factor out NT_PRFPREG regset access helpers Maciej W. Rozycki
2018-01-11 10:17 ` Greg KH
2018-01-11 15:18 ` Maciej W. Rozycki
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).