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 user_regset_get2_fn fpr_get;
67 int fpr_set(struct task_struct *target, const struct user_regset *regset,
68 	    unsigned int pos, unsigned int count,
69 	    const void *kbuf, const void __user *ubuf);
70 
71 /* ptrace-vsx */
72 
73 int vsr_active(struct task_struct *target, const struct user_regset *regset);
74 user_regset_get2_fn vsr_get;
75 int vsr_set(struct task_struct *target, const struct user_regset *regset,
76 	    unsigned int pos, unsigned int count,
77 	    const void *kbuf, const void __user *ubuf);
78 
79 /* ptrace-altivec */
80 
81 int vr_active(struct task_struct *target, const struct user_regset *regset);
82 user_regset_get2_fn vr_get;
83 int vr_set(struct task_struct *target, const struct user_regset *regset,
84 	   unsigned int pos, unsigned int count,
85 	   const void *kbuf, const void __user *ubuf);
86 
87 /* ptrace-spe */
88 
89 int evr_active(struct task_struct *target, const struct user_regset *regset);
90 user_regset_get2_fn evr_get;
91 int evr_set(struct task_struct *target, const struct user_regset *regset,
92 	    unsigned int pos, unsigned int count,
93 	    const void *kbuf, const void __user *ubuf);
94 
95 /* ptrace */
96 
97 int gpr32_get_common(struct task_struct *target,
98 		     const struct user_regset *regset,
99 		     struct membuf to,
100 		     unsigned long *regs);
101 int gpr32_set_common(struct task_struct *target,
102 		     const struct user_regset *regset,
103 		     unsigned int pos, unsigned int count,
104 		     const void *kbuf, const void __user *ubuf,
105 		     unsigned long *regs);
106 
107 /* ptrace-tm */
108 
109 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
110 void flush_tmregs_to_thread(struct task_struct *tsk);
111 #else
112 static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
113 #endif
114 
115 int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
116 user_regset_get2_fn tm_cgpr_get;
117 int tm_cgpr_set(struct task_struct *target, const struct user_regset *regset,
118 		unsigned int pos, unsigned int count,
119 		const void *kbuf, const void __user *ubuf);
120 int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
121 user_regset_get2_fn tm_cfpr_get;
122 int tm_cfpr_set(struct task_struct *target, const struct user_regset *regset,
123 		unsigned int pos, unsigned int count,
124 		const void *kbuf, const void __user *ubuf);
125 int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
126 user_regset_get2_fn tm_cvmx_get;
127 int tm_cvmx_set(struct task_struct *target, const struct user_regset *regset,
128 		unsigned int pos, unsigned int count,
129 		const void *kbuf, const void __user *ubuf);
130 int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
131 user_regset_get2_fn tm_cvsx_get;
132 int tm_cvsx_set(struct task_struct *target, const struct user_regset *regset,
133 		unsigned int pos, unsigned int count,
134 		const void *kbuf, const void __user *ubuf);
135 int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
136 user_regset_get2_fn tm_spr_get;
137 int tm_spr_set(struct task_struct *target, const struct user_regset *regset,
138 	       unsigned int pos, unsigned int count,
139 	       const void *kbuf, const void __user *ubuf);
140 int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
141 user_regset_get2_fn tm_tar_get;
142 int tm_tar_set(struct task_struct *target, const struct user_regset *regset,
143 	       unsigned int pos, unsigned int count,
144 	       const void *kbuf, const void __user *ubuf);
145 int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
146 user_regset_get2_fn tm_ppr_get;
147 int tm_ppr_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_dscr_active(struct task_struct *target, const struct user_regset *regset);
151 user_regset_get2_fn tm_dscr_get;
152 int tm_dscr_set(struct task_struct *target, const struct user_regset *regset,
153 		unsigned int pos, unsigned int count,
154 		const void *kbuf, const void __user *ubuf);
155 user_regset_get2_fn tm_cgpr32_get;
156 int tm_cgpr32_set(struct task_struct *target, const struct user_regset *regset,
157 		  unsigned int pos, unsigned int count,
158 		  const void *kbuf, const void __user *ubuf);
159 
160 /* ptrace-view */
161 
162 int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data);
163 int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
164 
165 extern const struct user_regset_view user_ppc_native_view;
166 
167 /* ptrace-fpu */
168 int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data);
169 int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data);
170 
171 /* ptrace-(no)adv */
172 void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
173 int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
174 			unsigned long __user *datalp);
175 int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
176 long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
177 long ppc_del_hwdebug(struct task_struct *child, long data);
178