xref: /linux/arch/powerpc/kernel/ptrace/ptrace-decl.h (revision b8265621f4888af9494e1d685620871ec81bc33d)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 /*
4  * Set of msr bits that gdb can change on behalf of a process.
5  */
6 #ifdef CONFIG_PPC_ADV_DEBUG_REGS
7 #define MSR_DEBUGCHANGE	0
8 #else
9 #define MSR_DEBUGCHANGE	(MSR_SE | MSR_BE)
10 #endif
11 
12 /*
13  * Max register writeable via put_reg
14  */
15 #ifdef CONFIG_PPC32
16 #define PT_MAX_PUT_REG	PT_MQ
17 #else
18 #define PT_MAX_PUT_REG	PT_CCR
19 #endif
20 
21 #define TVSO(f)	(offsetof(struct thread_vr_state, f))
22 #define TFSO(f)	(offsetof(struct thread_fp_state, f))
23 #define TSO(f)	(offsetof(struct thread_struct, f))
24 
25 /*
26  * These are our native regset flavors.
27  */
28 enum powerpc_regset {
29 	REGSET_GPR,
30 	REGSET_FPR,
31 #ifdef CONFIG_ALTIVEC
32 	REGSET_VMX,
33 #endif
34 #ifdef CONFIG_VSX
35 	REGSET_VSX,
36 #endif
37 #ifdef CONFIG_SPE
38 	REGSET_SPE,
39 #endif
40 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
41 	REGSET_TM_CGPR,		/* TM checkpointed GPR registers */
42 	REGSET_TM_CFPR,		/* TM checkpointed FPR registers */
43 	REGSET_TM_CVMX,		/* TM checkpointed VMX registers */
44 	REGSET_TM_CVSX,		/* TM checkpointed VSX registers */
45 	REGSET_TM_SPR,		/* TM specific SPR registers */
46 	REGSET_TM_CTAR,		/* TM checkpointed TAR register */
47 	REGSET_TM_CPPR,		/* TM checkpointed PPR register */
48 	REGSET_TM_CDSCR,	/* TM checkpointed DSCR register */
49 #endif
50 #ifdef CONFIG_PPC64
51 	REGSET_PPR,		/* PPR register */
52 	REGSET_DSCR,		/* DSCR register */
53 #endif
54 #ifdef CONFIG_PPC_BOOK3S_64
55 	REGSET_TAR,		/* TAR register */
56 	REGSET_EBB,		/* EBB registers */
57 	REGSET_PMR,		/* Performance Monitor Registers */
58 #endif
59 #ifdef CONFIG_PPC_MEM_KEYS
60 	REGSET_PKEY,		/* AMR register */
61 #endif
62 };
63 
64 /* ptrace-(no)vsx */
65 
66 int fpr_get(struct task_struct *target, const struct user_regset *regset,
67 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
68 int fpr_set(struct task_struct *target, const struct user_regset *regset,
69 	    unsigned int pos, unsigned int count,
70 	    const void *kbuf, const void __user *ubuf);
71 
72 /* ptrace-vsx */
73 
74 int vsr_active(struct task_struct *target, const struct user_regset *regset);
75 int vsr_get(struct task_struct *target, const struct user_regset *regset,
76 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
77 int vsr_set(struct task_struct *target, const struct user_regset *regset,
78 	    unsigned int pos, unsigned int count,
79 	    const void *kbuf, const void __user *ubuf);
80 
81 /* ptrace-altivec */
82 
83 int vr_active(struct task_struct *target, const struct user_regset *regset);
84 int vr_get(struct task_struct *target, const struct user_regset *regset,
85 	   unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
86 int vr_set(struct task_struct *target, const struct user_regset *regset,
87 	   unsigned int pos, unsigned int count,
88 	   const void *kbuf, const void __user *ubuf);
89 
90 /* ptrace-spe */
91 
92 int evr_active(struct task_struct *target, const struct user_regset *regset);
93 int evr_get(struct task_struct *target, const struct user_regset *regset,
94 	    unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
95 int evr_set(struct task_struct *target, const struct user_regset *regset,
96 	    unsigned int pos, unsigned int count,
97 	    const void *kbuf, const void __user *ubuf);
98 
99 /* ptrace */
100 
101 int gpr32_get_common(struct task_struct *target,
102 		     const struct user_regset *regset,
103 		     unsigned int pos, unsigned int count,
104 			    void *kbuf, void __user *ubuf,
105 			    unsigned long *regs);
106 int gpr32_set_common(struct task_struct *target,
107 		     const struct user_regset *regset,
108 		     unsigned int pos, unsigned int count,
109 		     const void *kbuf, const void __user *ubuf,
110 		     unsigned long *regs);
111 
112 /* ptrace-tm */
113 
114 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
115 void flush_tmregs_to_thread(struct task_struct *tsk);
116 #else
117 static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
118 #endif
119 
120 int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
121 int tm_cgpr_get(struct task_struct *target, const struct user_regset *regset,
122 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
123 int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
124 		unsigned int pos, unsigned int count,
125 		const void *kbuf, const void __user *ubuf);
126 int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
127 int tm_cfpr_get(struct task_struct *target, const struct user_regset *regset,
128 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
129 int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
130 		unsigned int pos, unsigned int count,
131 		const void *kbuf, const void __user *ubuf);
132 int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
133 int tm_cvmx_get(struct task_struct *target, const struct user_regset *regset,
134 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
135 int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
136 		unsigned int pos, unsigned int count,
137 		const void *kbuf, const void __user *ubuf);
138 int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
139 int tm_cvsx_get(struct task_struct *target, const struct user_regset *regset,
140 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
141 int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
142 		unsigned int pos, unsigned int count,
143 		const void *kbuf, const void __user *ubuf);
144 int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
145 int tm_spr_get(struct task_struct *target, const struct user_regset *regset,
146 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
147 int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
148 	       unsigned int pos, unsigned int count,
149 	       const void *kbuf, const void __user *ubuf);
150 int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
151 int tm_tar_get(struct task_struct *target, const struct user_regset *regset,
152 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
153 int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
154 	       unsigned int pos, unsigned int count,
155 	       const void *kbuf, const void __user *ubuf);
156 int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
157 int tm_ppr_get(struct task_struct *target, const struct user_regset *regset,
158 	       unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
159 int tm_ppr_set(struct task_struct *target, const struct user_regset *regset,
160 	       unsigned int pos, unsigned int count,
161 	       const void *kbuf, const void __user *ubuf);
162 int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
163 int tm_dscr_get(struct task_struct *target, const struct user_regset *regset,
164 		unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
165 int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
166 		unsigned int pos, unsigned int count,
167 		const void *kbuf, const void __user *ubuf);
168 int tm_cgpr32_get(struct task_struct *target, const struct user_regset *regset,
169 		  unsigned int pos, unsigned int count, void *kbuf, void __user *ubuf);
170 int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
171 		  unsigned int pos, unsigned int count,
172 		  const void *kbuf, const void __user *ubuf);
173 
174 /* ptrace-view */
175 
176 extern const struct user_regset_view user_ppc_native_view;
177 
178 /* ptrace-(no)adv */
179 void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
180 int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
181 			unsigned long __user *datalp);
182 int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
183 long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
184 long ppc_del_hwdebug(struct task_struct *child, long data);
185