m68knommu: implement minimal regset support
authorGreg Ungerer <gerg@linux-m68k.org>
Wed, 27 Apr 2022 13:09:37 +0000 (23:09 +1000)
committerGreg Ungerer <gerg@linux-m68k.org>
Mon, 16 May 2022 03:18:30 +0000 (13:18 +1000)
Add code support to the m68k architecture for regsets.

Currently the only thing that will need to use regsets for m68k will be
coredump support of the elf_fdpic loader. So the changes are conditional
on that. The added support is the minimum definitions required to support
just that.

Signed-off-by: Greg Ungerer <gerg@linux-m68k.org>
arch/m68k/kernel/ptrace.c

index 6342ff4d2073f58e5d82959ae075c1379013e3b9..4349b9c4dd680e46f8c51acfe6d985ced3b8b097 100644 (file)
@@ -19,6 +19,8 @@
 #include <linux/ptrace.h>
 #include <linux/user.h>
 #include <linux/signal.h>
+#include <linux/regset.h>
+#include <linux/elf.h>
 
 #include <linux/uaccess.h>
 #include <asm/page.h>
@@ -291,3 +293,59 @@ asmlinkage void syscall_trace_leave(void)
                ptrace_report_syscall_exit(task_pt_regs(current), 0);
 }
 #endif /* CONFIG_COLDFIRE */
+
+#if defined(CONFIG_BINFMT_ELF_FDPIC) && defined(CONFIG_ELF_CORE)
+/*
+ * Currently the only thing that needs to use regsets for m68k is the
+ * coredump support of the elf_fdpic loader. Implement the minimum
+ * definitions required for that.
+ */
+static int m68k_regset_get(struct task_struct *target,
+                          const struct user_regset *regset,
+                          struct membuf to)
+{
+       struct pt_regs *ptregs = task_pt_regs(target);
+       u32 uregs[ELF_NGREG];
+
+       ELF_CORE_COPY_REGS(uregs, ptregs);
+       return membuf_write(&to, uregs, sizeof(uregs));
+}
+
+enum m68k_regset {
+       REGSET_GPR,
+#ifdef CONFIG_FPU
+       REGSET_FPU,
+#endif
+};
+
+static const struct user_regset m68k_user_regsets[] = {
+       [REGSET_GPR] = {
+               .core_note_type = NT_PRSTATUS,
+               .n = ELF_NGREG,
+               .size = sizeof(u32),
+               .align = sizeof(u16),
+               .regset_get = m68k_regset_get,
+       },
+#ifdef CONFIG_FPU
+       [REGSET_FPU] = {
+               .core_note_type = NT_PRFPREG,
+               .n = sizeof(struct user_m68kfp_struct) / sizeof(u32),
+               .size = sizeof(u32),
+               .align = sizeof(u32),
+       }
+#endif /* CONFIG_FPU */
+};
+
+static const struct user_regset_view user_m68k_view = {
+       .name = "m68k",
+       .e_machine = EM_68K,
+       .ei_osabi = ELF_OSABI,
+       .regsets = m68k_user_regsets,
+       .n = ARRAY_SIZE(m68k_user_regsets)
+};
+
+const struct user_regset_view *task_user_regset_view(struct task_struct *task)
+{
+       return &user_m68k_view;
+}
+#endif /* CONFIG_BINFMT_ELF_FDPIC && CONFIG_ELF_CORE */