* [PATCH] MIPS: Add FP_MODE regset support
@ 2018-05-15 22:40 Maciej W. Rozycki
2018-07-19 21:00 ` Paul Burton
0 siblings, 1 reply; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-05-15 22:40 UTC (permalink / raw)
To: James Hogan; +Cc: Ralf Baechle, Paul Burton, linux-mips, linux-kernel
Define an NT_MIPS_FP_MODE core file note and implement a corresponding
regset holding the state handled by PR_SET_FP_MODE and PR_GET_FP_MODE
prctl(2) requests. This lets debug software correctly interpret the
contents of floating-point general registers both in live debugging and
in core files, and also switch floating-point modes of a live process.
Signed-off-by: Maciej W. Rozycki <macro@mips.com>
---
NB due to patch conflicts this change relies on the DSP ASE regset series
<https://patchwork.kernel.org/patch/10402171/> to be applied first.
---
arch/mips/kernel/ptrace.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
include/uapi/linux/elf.h | 1
2 files changed, 64 insertions(+)
linux-mips-nt-fp-mode.diff
Index: linux-jhogan-test/arch/mips/kernel/ptrace.c
===================================================================
--- linux-jhogan-test.orig/arch/mips/kernel/ptrace.c 2018-05-09 23:53:34.999776000 +0100
+++ linux-jhogan-test/arch/mips/kernel/ptrace.c 2018-05-09 23:54:22.778128000 +0100
@@ -759,10 +759,57 @@ static int dsp_active(struct task_struct
return cpu_has_dsp ? NUM_DSP_REGS + 1 : -ENODEV;
}
+/* Copy the FP mode setting to the supplied NT_MIPS_FP_MODE buffer. */
+static int fp_mode_get(struct task_struct *target,
+ const struct user_regset *regset,
+ unsigned int pos, unsigned int count,
+ void *kbuf, void __user *ubuf)
+{
+ int fp_mode;
+
+ fp_mode = mips_get_process_fp_mode(target);
+ return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &fp_mode, 0,
+ sizeof(fp_mode));
+}
+
+/*
+ * Copy the supplied NT_MIPS_FP_MODE buffer to the FP mode setting.
+ *
+ * We optimize for the case where `count % sizeof(int) == 0', which
+ * is supposed to have been guaranteed by the kernel before calling
+ * us, e.g. in `ptrace_regset'. We enforce that requirement, so
+ * that we can safely avoid preinitializing temporaries for partial
+ * mode writes.
+ */
+static int fp_mode_set(struct task_struct *target,
+ const struct user_regset *regset,
+ unsigned int pos, unsigned int count,
+ const void *kbuf, const void __user *ubuf)
+{
+ int fp_mode;
+ int err;
+
+ BUG_ON(count % sizeof(int));
+
+ if (pos + count > sizeof(fp_mode))
+ return -EIO;
+
+ err = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &fp_mode, 0,
+ sizeof(fp_mode));
+ if (err)
+ return err;
+
+ if (count > 0)
+ err = mips_set_process_fp_mode(target, fp_mode);
+
+ return err;
+}
+
enum mips_regset {
REGSET_GPR,
REGSET_FPR,
REGSET_DSP,
+ REGSET_FP_MODE,
};
struct pt_regs_offset {
@@ -877,6 +924,14 @@ static const struct user_regset mips_reg
.set = dsp32_set,
.active = dsp_active,
},
+ [REGSET_FP_MODE] = {
+ .core_note_type = NT_MIPS_FP_MODE,
+ .n = 1,
+ .size = sizeof(int),
+ .align = sizeof(int),
+ .get = fp_mode_get,
+ .set = fp_mode_set,
+ },
};
static const struct user_regset_view user_mips_view = {
@@ -917,6 +972,14 @@ static const struct user_regset mips64_r
.set = dsp64_set,
.active = dsp_active,
},
+ [REGSET_FP_MODE] = {
+ .core_note_type = NT_MIPS_FP_MODE,
+ .n = 1,
+ .size = sizeof(int),
+ .align = sizeof(int),
+ .get = fp_mode_get,
+ .set = fp_mode_set,
+ },
};
static const struct user_regset_view user_mips64_view = {
Index: linux-jhogan-test/include/uapi/linux/elf.h
===================================================================
--- linux-jhogan-test.orig/include/uapi/linux/elf.h 2018-05-09 23:53:35.003775000 +0100
+++ linux-jhogan-test/include/uapi/linux/elf.h 2018-05-09 23:54:22.787132000 +0100
@@ -425,6 +425,7 @@ typedef struct elf64_shdr {
#define NT_METAG_TLS 0x502 /* Metag TLS pointer */
#define NT_ARC_V2 0x600 /* ARCv2 accumulator/extra registers */
#define NT_MIPS_DSP 0x700 /* MIPS DSP ASE registers */
+#define NT_MIPS_FP_MODE 0x701 /* MIPS floating-point mode */
/* Note header in a PT_NOTE section */
typedef struct elf32_note {
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Add FP_MODE regset support
2018-05-15 22:40 [PATCH] MIPS: Add FP_MODE regset support Maciej W. Rozycki
@ 2018-07-19 21:00 ` Paul Burton
2018-07-19 21:26 ` Maciej W. Rozycki
0 siblings, 1 reply; 3+ messages in thread
From: Paul Burton @ 2018-07-19 21:00 UTC (permalink / raw)
To: Maciej Rozycki; +Cc: James Hogan, Ralf Baechle, linux-mips, linux-kernel
Hi Maciej,
On Tue, May 15, 2018 at 03:40:18PM -0700, Maciej Rozycki wrote:
> Define an NT_MIPS_FP_MODE core file note and implement a corresponding
> regset holding the state handled by PR_SET_FP_MODE and PR_GET_FP_MODE
> prctl(2) requests. This lets debug software correctly interpret the
> contents of floating-point general registers both in live debugging and
> in core files, and also switch floating-point modes of a live process.
>
> Signed-off-by: Maciej W. Rozycki <macro@mips.com>
> ---
> NB due to patch conflicts this change relies on the DSP ASE regset series
> <https://patchwork.kernel.org/patch/10402171/> to be applied first.
> ---
> arch/mips/kernel/ptrace.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++
> include/uapi/linux/elf.h | 1
> 2 files changed, 64 insertions(+)
Thanks - applied to mips-next for 4.19, though with NT_MIPS_FP_MODE
changed to 0x801.
Paul
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] MIPS: Add FP_MODE regset support
2018-07-19 21:00 ` Paul Burton
@ 2018-07-19 21:26 ` Maciej W. Rozycki
0 siblings, 0 replies; 3+ messages in thread
From: Maciej W. Rozycki @ 2018-07-19 21:26 UTC (permalink / raw)
To: Paul Burton; +Cc: James Hogan, Ralf Baechle, linux-mips, linux-kernel
Hi Paul,
> Thanks - applied to mips-next for 4.19, though with NT_MIPS_FP_MODE
> changed to 0x801.
Great, thanks! And like with the DSP regset, nothing has started using
this code yet, so no problem with the ABI change.
Maciej
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-19 21:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-15 22:40 [PATCH] MIPS: Add FP_MODE regset support Maciej W. Rozycki
2018-07-19 21:00 ` Paul Burton
2018-07-19 21:26 ` 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).