powerpc/ptrace: split out SPE related functions.
authorChristophe Leroy <christophe.leroy@c-s.fr>
Fri, 28 Feb 2020 00:14:43 +0000 (00:14 +0000)
committerMichael Ellerman <mpe@ellerman.id.au>
Wed, 1 Apr 2020 03:30:48 +0000 (14:30 +1100)
Move CONFIG_SPE functions out of ptrace.c, into
ptrace-spe.c

Signed-off-by: Christophe Leroy <christophe.leroy@c-s.fr>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/0f17a331760310b5562fae3791cdd3cf9c64237b.1582848567.git.christophe.leroy@c-s.fr
arch/powerpc/kernel/ptrace/Makefile
arch/powerpc/kernel/ptrace/ptrace-decl.h
arch/powerpc/kernel/ptrace/ptrace-spe.c [new file with mode: 0644]
arch/powerpc/kernel/ptrace/ptrace.c

index 522e6fd0b5b88c98516e76d08d6bd34ae940f6b8..f87eadf6e072b6ee25886557e3833a86ceba3c91 100644 (file)
@@ -12,3 +12,4 @@ ifneq ($(CONFIG_VSX),y)
 obj-y                          += ptrace-novsx.o
 endif
 obj-$(CONFIG_ALTIVEC)          += ptrace-altivec.o
+obj-$(CONFIG_SPE)              += ptrace-spe.o
index 0f9282cb52fc744185c16de55014d62f95c3025e..8a362f97f1d6971d5d5f99f9805d1e72d25cf301 100644 (file)
@@ -26,6 +26,15 @@ int vr_set(struct task_struct *target, const struct user_regset *regset,
           unsigned int pos, unsigned int count,
           const void *kbuf, const void __user *ubuf);
 
+/* ptrace-spe */
+
+int evr_active(struct task_struct *target, const struct user_regset *regset);
+int evr_get(struct task_struct *target, const struct user_regset *regset,
+           unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
+int evr_set(struct task_struct *target, const struct user_regset *regset,
+           unsigned int pos, unsigned int count,
+           const void *kbuf, const void __user *ubuf);
+
 /* ptrace */
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
diff --git a/arch/powerpc/kernel/ptrace/ptrace-spe.c b/arch/powerpc/kernel/ptrace/ptrace-spe.c
new file mode 100644 (file)
index 0000000..68b86b4
--- /dev/null
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include <linux/regset.h>
+
+#include <asm/switch_to.h>
+
+#include "ptrace-decl.h"
+
+/*
+ * For get_evrregs/set_evrregs functions 'data' has the following layout:
+ *
+ * struct {
+ *   u32 evr[32];
+ *   u64 acc;
+ *   u32 spefscr;
+ * }
+ */
+
+int evr_active(struct task_struct *target, const struct user_regset *regset)
+{
+       flush_spe_to_thread(target);
+       return target->thread.used_spe ? regset->n : 0;
+}
+
+int evr_get(struct task_struct *target, const struct user_regset *regset,
+           unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
+{
+       int ret;
+
+       flush_spe_to_thread(target);
+
+       ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+                                 &target->thread.evr,
+                                 0, sizeof(target->thread.evr));
+
+       BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
+                    offsetof(struct thread_struct, spefscr));
+
+       if (!ret)
+               ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+                                         &target->thread.acc,
+                                         sizeof(target->thread.evr), -1);
+
+       return ret;
+}
+
+int evr_set(struct task_struct *target, const struct user_regset *regset,
+           unsigned int pos, unsigned int count,
+           const void *kbuf, const void __user *ubuf)
+{
+       int ret;
+
+       flush_spe_to_thread(target);
+
+       ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+                                &target->thread.evr,
+                                0, sizeof(target->thread.evr));
+
+       BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
+                    offsetof(struct thread_struct, spefscr));
+
+       if (!ret)
+               ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+                                        &target->thread.acc,
+                                        sizeof(target->thread.evr), -1);
+
+       return ret;
+}
index c383325db4a6d76df2f92c1f4d8ff852fd2e40e9..ca2b4d804992e6c8d97abd770a9c778be9e8f895 100644 (file)
@@ -403,72 +403,6 @@ static int gpr_set(struct task_struct *target, const struct user_regset *regset,
        return ret;
 }
 
-#ifdef CONFIG_SPE
-
-/*
- * For get_evrregs/set_evrregs functions 'data' has the following layout:
- *
- * struct {
- *   u32 evr[32];
- *   u64 acc;
- *   u32 spefscr;
- * }
- */
-
-static int evr_active(struct task_struct *target,
-                     const struct user_regset *regset)
-{
-       flush_spe_to_thread(target);
-       return target->thread.used_spe ? regset->n : 0;
-}
-
-static int evr_get(struct task_struct *target, const struct user_regset *regset,
-                  unsigned int pos, unsigned int count,
-                  void *kbuf, void __user *ubuf)
-{
-       int ret;
-
-       flush_spe_to_thread(target);
-
-       ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                 &target->thread.evr,
-                                 0, sizeof(target->thread.evr));
-
-       BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
-                    offsetof(struct thread_struct, spefscr));
-
-       if (!ret)
-               ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
-                                         &target->thread.acc,
-                                         sizeof(target->thread.evr), -1);
-
-       return ret;
-}
-
-static int evr_set(struct task_struct *target, const struct user_regset *regset,
-                  unsigned int pos, unsigned int count,
-                  const void *kbuf, const void __user *ubuf)
-{
-       int ret;
-
-       flush_spe_to_thread(target);
-
-       ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-                                &target->thread.evr,
-                                0, sizeof(target->thread.evr));
-
-       BUILD_BUG_ON(offsetof(struct thread_struct, acc) + sizeof(u64) !=
-                    offsetof(struct thread_struct, spefscr));
-
-       if (!ret)
-               ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
-                                        &target->thread.acc,
-                                        sizeof(target->thread.evr), -1);
-
-       return ret;
-}
-#endif /* CONFIG_SPE */
-
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
 /**
  * tm_cgpr_active - get active number of registers in CGPR