This source file includes following definitions.
- instruction_pointer
- instruction_pointer_set
- user_stack_pointer
- frame_pointer
- is_syscall_success
- regs_return_value
- regs_set_return_value
- regs_get_register
- regs_within_kernel_stack
- regs_get_kernel_stack_nth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #ifndef _ASM_POWERPC_PTRACE_H
20 #define _ASM_POWERPC_PTRACE_H
21
22 #include <uapi/asm/ptrace.h>
23 #include <asm/asm-const.h>
24
25 #ifndef __ASSEMBLY__
26 struct pt_regs
27 {
28 union {
29 struct user_pt_regs user_regs;
30 struct {
31 unsigned long gpr[32];
32 unsigned long nip;
33 unsigned long msr;
34 unsigned long orig_gpr3;
35 unsigned long ctr;
36 unsigned long link;
37 unsigned long xer;
38 unsigned long ccr;
39 #ifdef CONFIG_PPC64
40 unsigned long softe;
41 #else
42 unsigned long mq;
43 #endif
44 unsigned long trap;
45 unsigned long dar;
46 unsigned long dsisr;
47 unsigned long result;
48 };
49 };
50
51 union {
52 struct {
53 #ifdef CONFIG_PPC64
54 unsigned long ppr;
55 #endif
56 #ifdef CONFIG_PPC_KUAP
57 unsigned long kuap;
58 #endif
59 };
60 unsigned long __pad[2];
61 };
62 };
63 #endif
64
65 #ifdef __powerpc64__
66
67
68
69
70
71
72
73
74
75
76 #define USER_REDZONE_SIZE 512
77 #define KERNEL_REDZONE_SIZE 288
78
79 #define STACK_FRAME_OVERHEAD 112
80 #define STACK_FRAME_LR_SAVE 2
81 #define STACK_FRAME_REGS_MARKER ASM_CONST(0x7265677368657265)
82 #define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + \
83 STACK_FRAME_OVERHEAD + KERNEL_REDZONE_SIZE)
84 #define STACK_FRAME_MARKER 12
85
86 #ifdef PPC64_ELF_ABI_v2
87 #define STACK_FRAME_MIN_SIZE 32
88 #else
89 #define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
90 #endif
91
92
93 #define __SIGNAL_FRAMESIZE 128
94 #define __SIGNAL_FRAMESIZE32 64
95
96 #else
97
98 #define USER_REDZONE_SIZE 0
99 #define KERNEL_REDZONE_SIZE 0
100 #define STACK_FRAME_OVERHEAD 16
101 #define STACK_FRAME_LR_SAVE 1
102 #define STACK_FRAME_REGS_MARKER ASM_CONST(0x72656773)
103 #define STACK_INT_FRAME_SIZE (sizeof(struct pt_regs) + STACK_FRAME_OVERHEAD)
104 #define STACK_FRAME_MARKER 2
105 #define STACK_FRAME_MIN_SIZE STACK_FRAME_OVERHEAD
106
107
108 #define __SIGNAL_FRAMESIZE 64
109
110 #endif
111
112 #ifndef __ASSEMBLY__
113
114 static inline unsigned long instruction_pointer(struct pt_regs *regs)
115 {
116 return regs->nip;
117 }
118
119 static inline void instruction_pointer_set(struct pt_regs *regs,
120 unsigned long val)
121 {
122 regs->nip = val;
123 }
124
125 static inline unsigned long user_stack_pointer(struct pt_regs *regs)
126 {
127 return regs->gpr[1];
128 }
129
130 static inline unsigned long frame_pointer(struct pt_regs *regs)
131 {
132 return 0;
133 }
134
135 #ifdef CONFIG_SMP
136 extern unsigned long profile_pc(struct pt_regs *regs);
137 #else
138 #define profile_pc(regs) instruction_pointer(regs)
139 #endif
140
141 #define kernel_stack_pointer(regs) ((regs)->gpr[1])
142 static inline int is_syscall_success(struct pt_regs *regs)
143 {
144 return !(regs->ccr & 0x10000000);
145 }
146
147 static inline long regs_return_value(struct pt_regs *regs)
148 {
149 if (is_syscall_success(regs))
150 return regs->gpr[3];
151 else
152 return -regs->gpr[3];
153 }
154
155 static inline void regs_set_return_value(struct pt_regs *regs, unsigned long rc)
156 {
157 regs->gpr[3] = rc;
158 }
159
160 #ifdef __powerpc64__
161 #define user_mode(regs) ((((regs)->msr) >> MSR_PR_LG) & 0x1)
162 #else
163 #define user_mode(regs) (((regs)->msr & MSR_PR) != 0)
164 #endif
165
166 #define force_successful_syscall_return() \
167 do { \
168 set_thread_flag(TIF_NOERROR); \
169 } while(0)
170
171 struct task_struct;
172 extern int ptrace_get_reg(struct task_struct *task, int regno,
173 unsigned long *data);
174 extern int ptrace_put_reg(struct task_struct *task, int regno,
175 unsigned long data);
176
177 #define current_pt_regs() \
178 ((struct pt_regs *)((unsigned long)task_stack_page(current) + THREAD_SIZE) - 1)
179
180
181
182
183
184
185
186 #define FULL_REGS(regs) (((regs)->trap & 1) == 0)
187 #ifndef __powerpc64__
188 #define IS_CRITICAL_EXC(regs) (((regs)->trap & 2) != 0)
189 #define IS_MCHECK_EXC(regs) (((regs)->trap & 4) != 0)
190 #define IS_DEBUG_EXC(regs) (((regs)->trap & 8) != 0)
191 #endif
192 #define TRAP(regs) ((regs)->trap & ~0xF)
193 #ifdef __powerpc64__
194 #define NV_REG_POISON 0xdeadbeefdeadbeefUL
195 #define CHECK_FULL_REGS(regs) BUG_ON(regs->trap & 1)
196 #else
197 #define NV_REG_POISON 0xdeadbeef
198 #define CHECK_FULL_REGS(regs) \
199 do { \
200 if ((regs)->trap & 1) \
201 printk(KERN_CRIT "%s: partial register set\n", __func__); \
202 } while (0)
203 #endif
204
205 #define arch_has_single_step() (1)
206 #ifndef CONFIG_BOOK3S_601
207 #define arch_has_block_step() (true)
208 #else
209 #define arch_has_block_step() (false)
210 #endif
211 #define ARCH_HAS_USER_SINGLE_STEP_REPORT
212
213
214
215
216
217 #include <linux/stddef.h>
218 #include <linux/thread_info.h>
219 extern int regs_query_register_offset(const char *name);
220 extern const char *regs_query_register_name(unsigned int offset);
221 #define MAX_REG_OFFSET (offsetof(struct pt_regs, dsisr))
222
223
224
225
226
227
228
229
230
231
232 static inline unsigned long regs_get_register(struct pt_regs *regs,
233 unsigned int offset)
234 {
235 if (unlikely(offset > MAX_REG_OFFSET))
236 return 0;
237 return *(unsigned long *)((unsigned long)regs + offset);
238 }
239
240
241
242
243
244
245
246
247
248
249 static inline bool regs_within_kernel_stack(struct pt_regs *regs,
250 unsigned long addr)
251 {
252 return ((addr & ~(THREAD_SIZE - 1)) ==
253 (kernel_stack_pointer(regs) & ~(THREAD_SIZE - 1)));
254 }
255
256
257
258
259
260
261
262
263
264
265 static inline unsigned long regs_get_kernel_stack_nth(struct pt_regs *regs,
266 unsigned int n)
267 {
268 unsigned long *addr = (unsigned long *)kernel_stack_pointer(regs);
269 addr += n;
270 if (regs_within_kernel_stack(regs, (unsigned long)addr))
271 return *addr;
272 else
273 return 0;
274 }
275
276 #endif
277
278 #ifndef __powerpc64__
279 #else
280 #define PT_FPSCR32 (PT_FPR0 + 2*32 + 1)
281 #define PT_VR0_32 164
282 #define PT_VSCR_32 (PT_VR0 + 32*4 + 3)
283 #define PT_VRSAVE_32 (PT_VR0 + 33*4)
284 #define PT_VSR0_32 300
285 #endif
286 #endif