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 */
30enum 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
72user_regset_get2_fn fpr_get;
73int 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
79int vsr_active(struct task_struct *target, const struct user_regset *regset);
80user_regset_get2_fn vsr_get;
81int 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
87int vr_active(struct task_struct *target, const struct user_regset *regset);
88user_regset_get2_fn vr_get;
89int 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
95int evr_active(struct task_struct *target, const struct user_regset *regset);
96user_regset_get2_fn evr_get;
97int 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
103int gpr32_get_common(struct task_struct *target,
104 const struct user_regset *regset,
105 struct membuf to,
106 unsigned long *regs);
107int 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
116void flush_tmregs_to_thread(struct task_struct *tsk);
117#else
118static inline void flush_tmregs_to_thread(struct task_struct *tsk) { }
119#endif
120
121int tm_cgpr_active(struct task_struct *target, const struct user_regset *regset);
122user_regset_get2_fn tm_cgpr_get;
123int 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);
126int tm_cfpr_active(struct task_struct *target, const struct user_regset *regset);
127user_regset_get2_fn tm_cfpr_get;
128int 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);
131int tm_cvmx_active(struct task_struct *target, const struct user_regset *regset);
132user_regset_get2_fn tm_cvmx_get;
133int 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);
136int tm_cvsx_active(struct task_struct *target, const struct user_regset *regset);
137user_regset_get2_fn tm_cvsx_get;
138int 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);
141int tm_spr_active(struct task_struct *target, const struct user_regset *regset);
142user_regset_get2_fn tm_spr_get;
143int 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);
146int tm_tar_active(struct task_struct *target, const struct user_regset *regset);
147user_regset_get2_fn tm_tar_get;
148int 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);
151int tm_ppr_active(struct task_struct *target, const struct user_regset *regset);
152user_regset_get2_fn tm_ppr_get;
153int 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);
156int tm_dscr_active(struct task_struct *target, const struct user_regset *regset);
157user_regset_get2_fn tm_dscr_get;
158int 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);
161user_regset_get2_fn tm_cgpr32_get;
162int 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
168int ptrace_get_reg(struct task_struct *task, int regno, unsigned long *data);
169int ptrace_put_reg(struct task_struct *task, int regno, unsigned long data);
170
171extern const struct user_regset_view user_ppc_native_view;
172
173/* ptrace-fpu */
174int ptrace_get_fpr(struct task_struct *child, int index, unsigned long *data);
175int ptrace_put_fpr(struct task_struct *child, int index, unsigned long data);
176
177/* ptrace-(no)adv */
178void ppc_gethwdinfo(struct ppc_debug_info *dbginfo);
179int ptrace_get_debugreg(struct task_struct *child, unsigned long addr,
180 unsigned long __user *datalp);
181int ptrace_set_debugreg(struct task_struct *task, unsigned long addr, unsigned long data);
182long ppc_set_hwdebug(struct task_struct *child, struct ppc_hw_breakpoint *bp_info);
183long ppc_del_hwdebug(struct task_struct *child, long data);
184

source code of linux/arch/powerpc/kernel/ptrace/ptrace-decl.h