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