Re: [PATCH v4 06/13] powerpc/ptrace: split out ALTIVEC related functions.

2020-02-27 Thread kbuild test robot
Hi Christophe,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on powerpc/next]
[also build test ERROR on v5.6-rc3 next-20200227]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:
https://github.com/0day-ci/linux/commits/Christophe-Leroy/Reduce-ifdef-mess-in-ptrace/20200228-094814
base:   https://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux.git next
config: powerpc-defconfig (attached as .config)
compiler: powerpc64-linux-gcc (GCC) 7.5.0
reproduce:
wget 
https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O 
~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.5.0 make.cross ARCH=powerpc 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot 

All errors (new ones prefixed by >>):

>> arch/powerpc/kernel/ptrace/ptrace-altivec.c:8:10: fatal error: 
>> ptrace_decl.h: No such file or directory
#include "ptrace_decl.h"
 ^~~
   compilation terminated.

vim +8 arch/powerpc/kernel/ptrace/ptrace-altivec.c

 7  
   > 8  #include "ptrace_decl.h"
 9  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-...@lists.01.org


.config.gz
Description: application/gzip


[PATCH v4 06/13] powerpc/ptrace: split out ALTIVEC related functions.

2020-02-27 Thread Christophe Leroy
Move CONFIG_ALTIVEC functions out of ptrace.c, into
ptrace-altivec.c

Signed-off-by: Christophe Leroy 
---
v4: add missing ptrace_decl.h
---
 arch/powerpc/kernel/ptrace/Makefile |   1 +
 arch/powerpc/kernel/ptrace/ptrace-altivec.c | 128 
 arch/powerpc/kernel/ptrace/ptrace-decl.h|   9 ++
 arch/powerpc/kernel/ptrace/ptrace.c | 124 ---
 4 files changed, 138 insertions(+), 124 deletions(-)
 create mode 100644 arch/powerpc/kernel/ptrace/ptrace-altivec.c

diff --git a/arch/powerpc/kernel/ptrace/Makefile 
b/arch/powerpc/kernel/ptrace/Makefile
index 238c27189078..522e6fd0b5b8 100644
--- a/arch/powerpc/kernel/ptrace/Makefile
+++ b/arch/powerpc/kernel/ptrace/Makefile
@@ -11,3 +11,4 @@ obj-$(CONFIG_VSX) += ptrace-vsx.o
 ifneq ($(CONFIG_VSX),y)
 obj-y  += ptrace-novsx.o
 endif
+obj-$(CONFIG_ALTIVEC)  += ptrace-altivec.o
diff --git a/arch/powerpc/kernel/ptrace/ptrace-altivec.c 
b/arch/powerpc/kernel/ptrace/ptrace-altivec.c
new file mode 100644
index ..910d1d7389a6
--- /dev/null
+++ b/arch/powerpc/kernel/ptrace/ptrace-altivec.c
@@ -0,0 +1,128 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+
+#include 
+#include 
+
+#include 
+
+#include "ptrace_decl.h"
+
+/*
+ * Get/set all the altivec registers vr0..vr31, vscr, vrsave, in one go.
+ * The transfer totals 34 quadword.  Quadwords 0-31 contain the
+ * corresponding vector registers.  Quadword 32 contains the vscr as the
+ * last word (offset 12) within that quadword.  Quadword 33 contains the
+ * vrsave as the first word (offset 0) within the quadword.
+ *
+ * This definition of the VMX state is compatible with the current PPC32
+ * ptrace interface.  This allows signal handling and ptrace to use the
+ * same structures.  This also simplifies the implementation of a bi-arch
+ * (combined (32- and 64-bit) gdb.
+ */
+
+int vr_active(struct task_struct *target, const struct user_regset *regset)
+{
+   flush_altivec_to_thread(target);
+   return target->thread.used_vr ? regset->n : 0;
+}
+
+/*
+ * Regardless of transactions, 'vr_state' holds the current running
+ * value of all the VMX registers and 'ckvr_state' holds the last
+ * checkpointed value of all the VMX registers for the current
+ * transaction to fall back on in case it aborts.
+ *
+ * Userspace interface buffer layout:
+ *
+ * struct data {
+ * vector128   vr[32];
+ * vector128   vscr;
+ * vector128   vrsave;
+ * };
+ */
+int vr_get(struct task_struct *target, const struct user_regset *regset,
+  unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf)
+{
+   int ret;
+
+   flush_altivec_to_thread(target);
+
+   BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
+offsetof(struct thread_vr_state, vr[32]));
+
+   ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
+ &target->thread.vr_state, 0,
+ 33 * sizeof(vector128));
+   if (!ret) {
+   /*
+* Copy out only the low-order word of vrsave.
+*/
+   int start, end;
+   union {
+   elf_vrreg_t reg;
+   u32 word;
+   } vrsave;
+   memset(&vrsave, 0, sizeof(vrsave));
+
+   vrsave.word = target->thread.vrsave;
+
+   start = 33 * sizeof(vector128);
+   end = start + sizeof(vrsave);
+   ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, &vrsave,
+ start, end);
+   }
+
+   return ret;
+}
+
+/*
+ * Regardless of transactions, 'vr_state' holds the current running
+ * value of all the VMX registers and 'ckvr_state' holds the last
+ * checkpointed value of all the VMX registers for the current
+ * transaction to fall back on in case it aborts.
+ *
+ * Userspace interface buffer layout:
+ *
+ * struct data {
+ * vector128   vr[32];
+ * vector128   vscr;
+ * vector128   vrsave;
+ * };
+ */
+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)
+{
+   int ret;
+
+   flush_altivec_to_thread(target);
+
+   BUILD_BUG_ON(offsetof(struct thread_vr_state, vscr) !=
+offsetof(struct thread_vr_state, vr[32]));
+
+   ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
+&target->thread.vr_state, 0,
+33 * sizeof(vector128));
+   if (!ret && count > 0) {
+   /*
+* We use only the first word of vrsave.
+*/
+   int start, end;
+   union {
+   elf_vrreg_t reg;
+   u32 word;
+   } vrsave;
+   memset(&vrsave, 0, sizeof(vrsave)