xref: /openbmc/linux/arch/powerpc/kernel/ptrace/ptrace-decl.h (revision 67e364b3295f9dbf3b820d0edde86fb7c95efc98)
17b99ed4eSChristophe Leroy /* SPDX-License-Identifier: GPL-2.0-or-later */
27b99ed4eSChristophe Leroy 
37c1f8db0SChristophe Leroy /*
47c1f8db0SChristophe Leroy  * Set of msr bits that gdb can change on behalf of a process.
57c1f8db0SChristophe Leroy  */
67c1f8db0SChristophe Leroy #ifdef CONFIG_PPC_ADV_DEBUG_REGS
77c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	0
87c1f8db0SChristophe Leroy #else
97c1f8db0SChristophe Leroy #define MSR_DEBUGCHANGE	(MSR_SE | MSR_BE)
107c1f8db0SChristophe Leroy #endif
117c1f8db0SChristophe Leroy 
127c1f8db0SChristophe Leroy /*
137c1f8db0SChristophe Leroy  * Max register writeable via put_reg
147c1f8db0SChristophe Leroy  */
157c1f8db0SChristophe Leroy #ifdef CONFIG_PPC32
167c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_MQ
177c1f8db0SChristophe Leroy #else
187c1f8db0SChristophe Leroy #define PT_MAX_PUT_REG	PT_CCR
197c1f8db0SChristophe Leroy #endif
207c1f8db0SChristophe Leroy 
217c1f8db0SChristophe Leroy #define TVSO(f)	(offsetof(struct thread_vr_state, f))
227c1f8db0SChristophe Leroy #define TFSO(f)	(offsetof(struct thread_fp_state, f))
237c1f8db0SChristophe Leroy #define TSO(f)	(offsetof(struct thread_struct, f))
247c1f8db0SChristophe Leroy 
256e0b7975SChristophe Leroy /*
266e0b7975SChristophe Leroy  * These are our native regset flavors.
276e0b7975SChristophe Leroy  */
286e0b7975SChristophe Leroy enum powerpc_regset {
296e0b7975SChristophe Leroy 	REGSET_GPR,
306e0b7975SChristophe Leroy 	REGSET_FPR,
316e0b7975SChristophe Leroy #ifdef CONFIG_ALTIVEC
326e0b7975SChristophe Leroy 	REGSET_VMX,
336e0b7975SChristophe Leroy #endif
346e0b7975SChristophe Leroy #ifdef CONFIG_VSX
356e0b7975SChristophe Leroy 	REGSET_VSX,
366e0b7975SChristophe Leroy #endif
376e0b7975SChristophe Leroy #ifdef CONFIG_SPE
386e0b7975SChristophe Leroy 	REGSET_SPE,
396e0b7975SChristophe Leroy #endif
406e0b7975SChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
416e0b7975SChristophe Leroy 	REGSET_TM_CGPR,		/* TM checkpointed GPR registers */
426e0b7975SChristophe Leroy 	REGSET_TM_CFPR,		/* TM checkpointed FPR registers */
436e0b7975SChristophe Leroy 	REGSET_TM_CVMX,		/* TM checkpointed VMX registers */
446e0b7975SChristophe Leroy 	REGSET_TM_CVSX,		/* TM checkpointed VSX registers */
456e0b7975SChristophe Leroy 	REGSET_TM_SPR,		/* TM specific SPR registers */
466e0b7975SChristophe Leroy 	REGSET_TM_CTAR,		/* TM checkpointed TAR register */
476e0b7975SChristophe Leroy 	REGSET_TM_CPPR,		/* TM checkpointed PPR register */
486e0b7975SChristophe Leroy 	REGSET_TM_CDSCR,	/* TM checkpointed DSCR register */
496e0b7975SChristophe Leroy #endif
506e0b7975SChristophe Leroy #ifdef CONFIG_PPC64
516e0b7975SChristophe Leroy 	REGSET_PPR,		/* PPR register */
526e0b7975SChristophe Leroy 	REGSET_DSCR,		/* DSCR register */
536e0b7975SChristophe Leroy #endif
546e0b7975SChristophe Leroy #ifdef CONFIG_PPC_BOOK3S_64
556e0b7975SChristophe Leroy 	REGSET_TAR,		/* TAR register */
566e0b7975SChristophe Leroy 	REGSET_EBB,		/* EBB registers */
576e0b7975SChristophe Leroy 	REGSET_PMR,		/* Performance Monitor Registers */
586e0b7975SChristophe Leroy #endif
596e0b7975SChristophe Leroy #ifdef CONFIG_PPC_MEM_KEYS
606e0b7975SChristophe Leroy 	REGSET_PKEY,		/* AMR register */
616e0b7975SChristophe Leroy #endif
626e0b7975SChristophe Leroy };
636e0b7975SChristophe Leroy 
647b99ed4eSChristophe Leroy /* ptrace-(no)vsx */
657b99ed4eSChristophe Leroy 
6647e12855SAl Viro user_regset_get2_fn fpr_get;
677b99ed4eSChristophe Leroy int fpr_set(struct task_struct *target, const struct user_regset *regset,
687b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count,
697b99ed4eSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
707b99ed4eSChristophe Leroy 
717b99ed4eSChristophe Leroy /* ptrace-vsx */
727b99ed4eSChristophe Leroy 
737b99ed4eSChristophe Leroy int vsr_active(struct task_struct *target, const struct user_regset *regset);
7447e12855SAl Viro user_regset_get2_fn vsr_get;
757b99ed4eSChristophe Leroy int vsr_set(struct task_struct *target, const struct user_regset *regset,
767b99ed4eSChristophe Leroy 	    unsigned int pos, unsigned int count,
777b99ed4eSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
787b99ed4eSChristophe Leroy 
791b20773bSChristophe Leroy /* ptrace-altivec */
801b20773bSChristophe Leroy 
811b20773bSChristophe Leroy int vr_active(struct task_struct *target, const struct user_regset *regset);
8247e12855SAl Viro user_regset_get2_fn vr_get;
831b20773bSChristophe Leroy int vr_set(struct task_struct *target, const struct user_regset *regset,
841b20773bSChristophe Leroy 	   unsigned int pos, unsigned int count,
851b20773bSChristophe Leroy 	   const void *kbuf, const void __user *ubuf);
861b20773bSChristophe Leroy 
8760ef9dbdSChristophe Leroy /* ptrace-spe */
8860ef9dbdSChristophe Leroy 
8960ef9dbdSChristophe Leroy int evr_active(struct task_struct *target, const struct user_regset *regset);
9047e12855SAl Viro user_regset_get2_fn evr_get;
9160ef9dbdSChristophe Leroy int evr_set(struct task_struct *target, const struct user_regset *regset,
9260ef9dbdSChristophe Leroy 	    unsigned int pos, unsigned int count,
9360ef9dbdSChristophe Leroy 	    const void *kbuf, const void __user *ubuf);
9460ef9dbdSChristophe Leroy 
957b99ed4eSChristophe Leroy /* ptrace */
967b99ed4eSChristophe Leroy 
977c1f8db0SChristophe Leroy int gpr32_get_common(struct task_struct *target,
987c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
9947e12855SAl Viro 		     struct membuf to,
1007c1f8db0SChristophe Leroy 		     unsigned long *regs);
1017c1f8db0SChristophe Leroy int gpr32_set_common(struct task_struct *target,
1027c1f8db0SChristophe Leroy 		     const struct user_regset *regset,
1037c1f8db0SChristophe Leroy 		     unsigned int pos, unsigned int count,
1047c1f8db0SChristophe Leroy 		     const void *kbuf, const void __user *ubuf,
1057c1f8db0SChristophe Leroy 		     unsigned long *regs);
1067c1f8db0SChristophe Leroy 
1077c1f8db0SChristophe Leroy /* ptrace-tm */
1087c1f8db0SChristophe Leroy 
1097b99ed4eSChristophe Leroy #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
1107b99ed4eSChristophe Leroy void flush_tmregs_to_thread(struct task_struct *tsk);
1117b99ed4eSChristophe Leroy #else
1127b99ed4eSChristophe Leroy static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
1137b99ed4eSChristophe Leroy #endif
1147c1f8db0SChristophe Leroy 
1157c1f8db0SChristophe Leroy int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
11647e12855SAl Viro user_regset_get2_fn tm_cgpr_get;
1177c1f8db0SChristophe Leroy int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
1187c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1197c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1207c1f8db0SChristophe Leroy int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
12147e12855SAl Viro user_regset_get2_fn tm_cfpr_get;
1227c1f8db0SChristophe Leroy int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
1237c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1247c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1257c1f8db0SChristophe Leroy int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
12647e12855SAl Viro user_regset_get2_fn tm_cvmx_get;
1277c1f8db0SChristophe Leroy int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
1287c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1297c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1307c1f8db0SChristophe Leroy int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
13147e12855SAl Viro user_regset_get2_fn tm_cvsx_get;
1327c1f8db0SChristophe Leroy int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
1337c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1347c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
1357c1f8db0SChristophe Leroy int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
13647e12855SAl Viro user_regset_get2_fn tm_spr_get;
1377c1f8db0SChristophe Leroy int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
1387c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1397c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1407c1f8db0SChristophe Leroy int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
14147e12855SAl Viro user_regset_get2_fn tm_tar_get;
1427c1f8db0SChristophe Leroy int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
1437c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1447c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1457c1f8db0SChristophe Leroy int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
14647e12855SAl Viro user_regset_get2_fn tm_ppr_get;
1477c1f8db0SChristophe Leroy int tm_ppr_set(struct task_struct *target, const struct user_regset *regset,
1487c1f8db0SChristophe Leroy 	       unsigned int pos, unsigned int count,
1497c1f8db0SChristophe Leroy 	       const void *kbuf, const void __user *ubuf);
1507c1f8db0SChristophe Leroy int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
15147e12855SAl Viro user_regset_get2_fn tm_dscr_get;
1527c1f8db0SChristophe Leroy int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
1537c1f8db0SChristophe Leroy 		unsigned int pos, unsigned int count,
1547c1f8db0SChristophe Leroy 		const void *kbuf, const void __user *ubuf);
15547e12855SAl Viro user_regset_get2_fn tm_cgpr32_get;
1567c1f8db0SChristophe Leroy int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
1577c1f8db0SChristophe Leroy 		  unsigned int pos, unsigned int count,
1587c1f8db0SChristophe Leroy 		  const void *kbuf, const void __user *ubuf);
1596e0b7975SChristophe Leroy 
1606e0b7975SChristophe Leroy /* ptrace-view */
1616e0b7975SChristophe Leroy 
162*67e364b3SChristophe Leroy int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data);
163*67e364b3SChristophe Leroy int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
164*67e364b3SChristophe Leroy 
1656e0b7975SChristophe Leroy extern const struct user_regset_view user_ppc_native_view;
166323a780cSChristophe Leroy 
167323a780cSChristophe Leroy /* ptrace-(no)adv */
168da529d47SChristophe Leroy void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
169e08227d2SChristophe Leroy int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
170e08227d2SChristophe Leroy 			unsigned long __user *datalp);
171323a780cSChristophe Leroy int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
172323a780cSChristophe Leroy long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
173323a780cSChristophe Leroy long ppc_del_hwdebug(struct task_struct *child, long data);
174