File: /usr/src/linux/include/asm-s390/ptrace.h
1 /*
2 * include/asm-s390/ptrace.h
3 *
4 * S390 version
5 * Copyright (C) 1999,2000 IBM Deutschland Entwicklung GmbH, IBM Corporation
6 * Author(s): Denis Joseph Barrow (djbarrow@de.ibm.com,barrow_dj@yahoo.com)
7 */
8
9 #ifndef _S390_PTRACE_H
10 #define _S390_PTRACE_H
11
12 /*
13 * Offsets in the user_regs_struct. They are used for the ptrace
14 * system call and in entry.S
15 */
16 #define PT_PSWMASK 0x00
17 #define PT_PSWADDR 0x04
18 #define PT_GPR0 0x08
19 #define PT_GPR1 0x0C
20 #define PT_GPR2 0x10
21 #define PT_GPR3 0x14
22 #define PT_GPR4 0x18
23 #define PT_GPR5 0x1C
24 #define PT_GPR6 0x20
25 #define PT_GPR7 0x24
26 #define PT_GPR8 0x28
27 #define PT_GPR9 0x2C
28 #define PT_GPR10 0x30
29 #define PT_GPR11 0x34
30 #define PT_GPR12 0x38
31 #define PT_GPR13 0x3C
32 #define PT_GPR14 0x40
33 #define PT_GPR15 0x44
34 #define PT_ACR0 0x48
35 #define PT_ACR1 0x4C
36 #define PT_ACR2 0x50
37 #define PT_ACR3 0x54
38 #define PT_ACR4 0x58
39 #define PT_ACR5 0x5C
40 #define PT_ACR6 0x60
41 #define PT_ACR7 0x64
42 #define PT_ACR8 0x68
43 #define PT_ACR9 0x6C
44 #define PT_ACR10 0x70
45 #define PT_ACR11 0x74
46 #define PT_ACR12 0x78
47 #define PT_ACR13 0x7C
48 #define PT_ACR14 0x80
49 #define PT_ACR15 0x84
50 #define PT_ORIGGPR2 0x88
51 #define PT_FPC 0x90
52 /*
53 * A nasty fact of life that the ptrace api
54 * only supports passing of longs.
55 */
56 #define PT_FPR0_HI 0x98
57 #define PT_FPR0_LO 0x9C
58 #define PT_FPR1_HI 0xA0
59 #define PT_FPR1_LO 0xA4
60 #define PT_FPR2_HI 0xA8
61 #define PT_FPR2_LO 0xAC
62 #define PT_FPR3_HI 0xB0
63 #define PT_FPR3_LO 0xB4
64 #define PT_FPR4_HI 0xB8
65 #define PT_FPR4_LO 0xBC
66 #define PT_FPR5_HI 0xC0
67 #define PT_FPR5_LO 0xC4
68 #define PT_FPR6_HI 0xC8
69 #define PT_FPR6_LO 0xCC
70 #define PT_FPR7_HI 0xD0
71 #define PT_FPR7_LO 0xD4
72 #define PT_FPR8_HI 0xD8
73 #define PT_FPR8_LO 0XDC
74 #define PT_FPR9_HI 0xE0
75 #define PT_FPR9_LO 0xE4
76 #define PT_FPR10_HI 0xE8
77 #define PT_FPR10_LO 0xEC
78 #define PT_FPR11_HI 0xF0
79 #define PT_FPR11_LO 0xF4
80 #define PT_FPR12_HI 0xF8
81 #define PT_FPR12_LO 0xFC
82 #define PT_FPR13_HI 0x100
83 #define PT_FPR13_LO 0x104
84 #define PT_FPR14_HI 0x108
85 #define PT_FPR14_LO 0x10C
86 #define PT_FPR15_HI 0x110
87 #define PT_FPR15_LO 0x114
88 #define PT_CR_9 0x118
89 #define PT_CR_10 0x11C
90 #define PT_CR_11 0x120
91 #define PT_IEEE_IP 0x13C
92 #define PT_LASTOFF PT_IEEE_IP
93 #define PT_ENDREGS 0x140-1
94
95 #define NUM_GPRS 16
96 #define NUM_FPRS 16
97 #define NUM_CRS 16
98 #define NUM_ACRS 16
99 #define GPR_SIZE 4
100 #define FPR_SIZE 8
101 #define FPC_SIZE 4
102 #define FPC_PAD_SIZE 4 /* gcc insists on aligning the fpregs */
103 #define CR_SIZE 4
104 #define ACR_SIZE 4
105
106 #define STACK_FRAME_OVERHEAD 96 /* size of minimum stack frame */
107
108 #ifndef __ASSEMBLY__
109 #include <linux/config.h>
110 #include <linux/stddef.h>
111 #include <linux/types.h>
112
113 #include <asm/current.h>
114 #include <asm/setup.h>
115
116 /* this typedef defines how a Program Status Word looks like */
117 typedef struct
118 {
119 __u32 mask;
120 __u32 addr;
121 } psw_t __attribute__ ((aligned(8)));
122
123 #ifdef __KERNEL__
124 #define FIX_PSW(addr) ((unsigned long)(addr)|0x80000000UL)
125 #define ADDR_BITS_REMOVE(addr) ((addr)&0x7fffffff)
126 #endif
127
128 typedef union
129 {
130 float f;
131 double d;
132 __u64 ui;
133 struct
134 {
135 __u32 hi;
136 __u32 lo;
137 } fp;
138 } freg_t;
139
140 typedef struct
141 {
142 __u32 fpc;
143 freg_t fprs[NUM_FPRS];
144 } s390_fp_regs;
145
146 #define FPC_EXCEPTION_MASK 0xF8000000
147 #define FPC_FLAGS_MASK 0x00F80000
148 #define FPC_DXC_MASK 0x0000FF00
149 #define FPC_RM_MASK 0x00000003
150 #define FPC_VALID_MASK 0xF8F8FF03
151
152 /*
153 * The first entries in pt_regs, gdb_pt_regs and user_regs_struct
154 * are common for all three structures. The s390_regs structure
155 * covers the common parts. It simplifies copying the common part
156 * between the three structures.
157 */
158 typedef struct
159 {
160 psw_t psw;
161 __u32 gprs[NUM_GPRS];
162 __u32 acrs[NUM_ACRS];
163 __u32 orig_gpr2;
164 } s390_regs;
165
166 /*
167 * The pt_regs struct defines the way the registers are stored on
168 * the stack during a system call.
169 */
170 struct pt_regs
171 {
172 psw_t psw;
173 __u32 gprs[NUM_GPRS];
174 __u32 acrs[NUM_ACRS];
175 __u32 orig_gpr2;
176 __u32 trap;
177 __u32 old_ilc;
178 };
179
180 /*
181 * The gdb_pt_regs struct is used instead of the pt_regs structure
182 * if kernel remote debugging is used.
183 */
184 #if CONFIG_REMOTE_DEBUG
185 struct gdb_pt_regs
186 {
187 psw_t psw;
188 __u32 gprs[NUM_GPRS];
189 __u32 acrs[NUM_ACRS];
190 __u32 orig_gpr2;
191 __u32 trap;
192 __u32 crs[16];
193 s390_fp_regs fp_regs;
194 };
195 #endif
196
197 /*
198 * Now for the program event recording (trace) definitions.
199 */
200 typedef struct
201 {
202 __u32 cr[3];
203 } per_cr_words __attribute__((packed));
204
205 #define PER_EM_MASK 0xE8000000
206
207 typedef struct
208 {
209 unsigned em_branching : 1;
210 unsigned em_instruction_fetch : 1;
211 /*
212 * Switching on storage alteration automatically fixes
213 * the storage alteration event bit in the users std.
214 */
215 unsigned em_storage_alteration : 1;
216 unsigned em_gpr_alt_unused : 1;
217 unsigned em_store_real_address : 1;
218 unsigned : 3;
219 unsigned branch_addr_ctl : 1;
220 unsigned : 1;
221 unsigned storage_alt_space_ctl : 1;
222 unsigned : 21;
223 addr_t starting_addr;
224 addr_t ending_addr;
225 } per_cr_bits __attribute__((packed));
226
227 typedef struct
228 {
229 __u16 perc_atmid; /* 0x096 */
230 __u32 address; /* 0x098 */
231 __u8 access_id; /* 0x0a1 */
232 } per_lowcore_words __attribute__((packed));
233
234 typedef struct
235 {
236 unsigned perc_branching : 1; /* 0x096 */
237 unsigned perc_instruction_fetch : 1;
238 unsigned perc_storage_alteration : 1;
239 unsigned perc_gpr_alt_unused : 1;
240 unsigned perc_store_real_address : 1;
241 unsigned : 4;
242 unsigned atmid_validity_bit : 1;
243 unsigned atmid_psw_bit_32 : 1;
244 unsigned atmid_psw_bit_5 : 1;
245 unsigned atmid_psw_bit_16 : 1;
246 unsigned atmid_psw_bit_17 : 1;
247 unsigned si : 2;
248 addr_t address; /* 0x098 */
249 unsigned : 4; /* 0x0a1 */
250 unsigned access_id : 4;
251 } per_lowcore_bits __attribute__((packed));
252
253 typedef struct
254 {
255 union {
256 per_cr_words words;
257 per_cr_bits bits;
258 } control_regs __attribute__((packed));
259 /*
260 * Use these flags instead of setting em_instruction_fetch
261 * directly they are used so that single stepping can be
262 * switched on & off while not affecting other tracing
263 */
264 unsigned single_step : 1;
265 unsigned instruction_fetch : 1;
266 unsigned : 30;
267 /*
268 * These addresses are copied into cr10 & cr11 if single
269 * stepping is switched off
270 */
271 __u32 starting_addr;
272 __u32 ending_addr;
273 union {
274 per_lowcore_words words;
275 per_lowcore_bits bits;
276 } lowcore;
277 } per_struct __attribute__((packed));
278
279 typedef struct
280 {
281 __u32 len;
282 addr_t kernel_addr;
283 addr_t process_addr;
284 } ptrace_area;
285
286 /*
287 * S/390 specific non posix ptrace requests. I chose unusual values so
288 * they are unlikely to clash with future ptrace definitions.
289 */
290 #define PTRACE_PEEKUSR_AREA 0x5000
291 #define PTRACE_POKEUSR_AREA 0x5001
292 #define PTRACE_PEEKTEXT_AREA 0x5002
293 #define PTRACE_PEEKDATA_AREA 0x5003
294 #define PTRACE_POKETEXT_AREA 0x5004
295 #define PTRACE_POKEDATA_AREA 0x5005
296 /*
297 * PT_PROT definition is loosely based on hppa bsd definition in
298 * gdb/hppab-nat.c
299 */
300 #define PTRACE_PROT 21
301
302 typedef enum
303 {
304 ptprot_set_access_watchpoint,
305 ptprot_set_write_watchpoint,
306 ptprot_disable_watchpoint
307 } ptprot_flags;
308
309 typedef struct
310 {
311 addr_t lowaddr;
312 addr_t hiaddr;
313 ptprot_flags prot;
314 } ptprot_area;
315
316 /* Sequence of bytes for breakpoint illegal instruction. */
317 #define S390_BREAKPOINT {0x0,0x1}
318 #define S390_BREAKPOINT_U16 ((__u16)0x0001)
319 #define S390_SYSCALL_OPCODE ((__u16)0x0a00)
320 #define S390_SYSCALL_SIZE 2
321
322 /*
323 * The user_regs_struct defines the way the user registers are
324 * store on the stack for signal handling.
325 */
326 struct user_regs_struct
327 {
328 psw_t psw;
329 __u32 gprs[NUM_GPRS];
330 __u32 acrs[NUM_ACRS];
331 __u32 orig_gpr2;
332 s390_fp_regs fp_regs;
333 /*
334 * These per registers are in here so that gdb can modify them
335 * itself as there is no "official" ptrace interface for hardware
336 * watchpoints. This is the way intel does it.
337 */
338 per_struct per_info;
339 addr_t ieee_instruction_pointer;
340 /* Used to give failing instruction back to user for ieee exceptions */
341 };
342
343 #ifdef __KERNEL__
344 #define user_mode(regs) (((regs)->psw.mask & PSW_PROBLEM_STATE) != 0)
345 #define instruction_pointer(regs) ((regs)->psw.addr)
346 extern void show_regs(struct pt_regs * regs);
347 extern char *task_show_regs(struct task_struct *task, char *buffer);
348 #endif
349
350 #endif /* __ASSEMBLY__ */
351
352 #endif /* _S390_PTRACE_H */
353