~ubuntu-branches/ubuntu/utopic/xen/utopic

« back to all changes in this revision

Viewing changes to xen/include/asm-ia64/linux-xen/asm/ptrace.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2010-05-06 15:47:38 UTC
  • mto: (1.3.1) (15.1.1 sid) (4.1.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20100506154738-agoz0rlafrh1fnq7
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef _ASM_IA64_PTRACE_H
 
2
#define _ASM_IA64_PTRACE_H
 
3
 
 
4
/*
 
5
 * Copyright (C) 1998-2004 Hewlett-Packard Co
 
6
 *      David Mosberger-Tang <davidm@hpl.hp.com>
 
7
 *      Stephane Eranian <eranian@hpl.hp.com>
 
8
 * Copyright (C) 2003 Intel Co
 
9
 *      Suresh Siddha <suresh.b.siddha@intel.com>
 
10
 *      Fenghua Yu <fenghua.yu@intel.com>
 
11
 *      Arun Sharma <arun.sharma@intel.com>
 
12
 *
 
13
 * 12/07/98     S. Eranian      added pt_regs & switch_stack
 
14
 * 12/21/98     D. Mosberger    updated to match latest code
 
15
 *  6/17/99     D. Mosberger    added second unat member to "struct switch_stack"
 
16
 *
 
17
 */
 
18
/*
 
19
 * When a user process is blocked, its state looks as follows:
 
20
 *
 
21
 *            +----------------------+  ------- IA64_STK_OFFSET
 
22
 *            |                      |   ^
 
23
 *            | struct pt_regs       |   |
 
24
 *            |                      |   |
 
25
 *            +----------------------+   |
 
26
 *            |                      |   |
 
27
 *            |    memory stack      |   |
 
28
 *            | (growing downwards)  |   |
 
29
 *            //.....................//  |
 
30
 *                                       |
 
31
 *            //.....................//  |
 
32
 *            |                      |   |
 
33
 *            +----------------------+   |
 
34
 *            | struct switch_stack  |   |
 
35
 *            |                      |   |
 
36
 *            +----------------------+   |
 
37
 *            |                      |   |
 
38
 *            //.....................//  |
 
39
 *                                       |
 
40
 *            //.....................//  |
 
41
 *            |                      |   |
 
42
 *            |  register stack      |   |
 
43
 *            | (growing upwards)    |   |
 
44
 *            |                      |   |
 
45
 *            +----------------------+   |  --- IA64_RBS_OFFSET
 
46
 *            |  struct thread_info  |   |  ^
 
47
 *            +----------------------+   |  |
 
48
 *            |                      |   |  |
 
49
 *            |  struct task_struct  |   |  |
 
50
 * current -> |                      |   |  |
 
51
 *            +----------------------+ -------
 
52
 *
 
53
 * Note that ar.ec is not saved explicitly in pt_reg or switch_stack.
 
54
 * This is because ar.ec is saved as part of ar.pfs.
 
55
 */
 
56
 
 
57
#include <linux/config.h>
 
58
 
 
59
#include <asm/fpu.h>
 
60
#include <asm/offsets.h>
 
61
 
 
62
/*
 
63
 * Base-2 logarithm of number of pages to allocate per task structure
 
64
 * (including register backing store and memory stack):
 
65
 */
 
66
#if defined(CONFIG_IA64_PAGE_SIZE_4KB)
 
67
# define KERNEL_STACK_SIZE_ORDER                3
 
68
#elif defined(CONFIG_IA64_PAGE_SIZE_8KB)
 
69
# define KERNEL_STACK_SIZE_ORDER                2
 
70
#elif defined(CONFIG_IA64_PAGE_SIZE_16KB)
 
71
# define KERNEL_STACK_SIZE_ORDER                1
 
72
#else
 
73
# define KERNEL_STACK_SIZE_ORDER                0
 
74
#endif
 
75
 
 
76
#define IA64_RBS_OFFSET                 ((IA64_TASK_SIZE + IA64_THREAD_INFO_SIZE + 15) & ~15)
 
77
#define IA64_STK_OFFSET                 ((1 << KERNEL_STACK_SIZE_ORDER)*PAGE_SIZE)
 
78
 
 
79
#define KERNEL_STACK_SIZE               IA64_STK_OFFSET
 
80
 
 
81
#ifndef __ASSEMBLY__
 
82
 
 
83
#include <asm/current.h>
 
84
#include <asm/page.h>
 
85
 
 
86
/*
 
87
 * This struct defines the way the registers are saved on system
 
88
 * calls.
 
89
 *
 
90
 * We don't save all floating point register because the kernel
 
91
 * is compiled to use only a very small subset, so the other are
 
92
 * untouched.
 
93
 *
 
94
 * THIS STRUCTURE MUST BE A MULTIPLE 16-BYTE IN SIZE
 
95
 * (because the memory stack pointer MUST ALWAYS be aligned this way)
 
96
 *
 
97
 */
 
98
#ifdef XEN
 
99
#include <xen/types.h>
 
100
#include <public/xen.h>
 
101
 
 
102
#define pt_regs cpu_user_regs
 
103
#endif
 
104
 
 
105
struct pt_regs {
 
106
        /* The following registers are saved by SAVE_MIN: */
 
107
        unsigned long b6;               /* scratch */
 
108
        unsigned long b7;               /* scratch */
 
109
 
 
110
        unsigned long ar_csd;           /* used by cmp8xchg16 (scratch) */
 
111
        unsigned long ar_ssd;           /* reserved for future use (scratch) */
 
112
 
 
113
        unsigned long r8;               /* scratch (return value register 0) */
 
114
        unsigned long r9;               /* scratch (return value register 1) */
 
115
        unsigned long r10;              /* scratch (return value register 2) */
 
116
        unsigned long r11;              /* scratch (return value register 3) */
 
117
 
 
118
        unsigned long cr_ipsr;          /* interrupted task's psr */
 
119
        unsigned long cr_iip;           /* interrupted task's instruction pointer */
 
120
        /*
 
121
         * interrupted task's function state; if bit 63 is cleared, it
 
122
         * contains syscall's ar.pfs.pfm:
 
123
         */
 
124
        unsigned long cr_ifs;
 
125
 
 
126
        unsigned long ar_unat;          /* interrupted task's NaT register (preserved) */
 
127
        unsigned long ar_pfs;           /* prev function state  */
 
128
        unsigned long ar_rsc;           /* RSE configuration */
 
129
        /* The following two are valid only if cr_ipsr.cpl > 0: */
 
130
        unsigned long ar_rnat;          /* RSE NaT */
 
131
        unsigned long ar_bspstore;      /* RSE bspstore */
 
132
 
 
133
        unsigned long pr;               /* 64 predicate registers (1 bit each) */
 
134
        unsigned long b0;               /* return pointer (bp) */
 
135
        unsigned long loadrs;           /* size of dirty partition << 16 */
 
136
 
 
137
        unsigned long r1;               /* the gp pointer */
 
138
        unsigned long r12;              /* interrupted task's memory stack pointer */
 
139
        unsigned long r13;              /* thread pointer */
 
140
 
 
141
        unsigned long ar_fpsr;          /* floating point status (preserved) */
 
142
        unsigned long r15;              /* scratch */
 
143
 
 
144
        /* The remaining registers are NOT saved for system calls.  */
 
145
 
 
146
        unsigned long r14;              /* scratch */
 
147
        unsigned long r2;               /* scratch */
 
148
        unsigned long r3;               /* scratch */
 
149
 
 
150
        /* The following registers are saved by SAVE_REST: */
 
151
        unsigned long r16;              /* scratch */
 
152
        unsigned long r17;              /* scratch */
 
153
        unsigned long r18;              /* scratch */
 
154
        unsigned long r19;              /* scratch */
 
155
        unsigned long r20;              /* scratch */
 
156
        unsigned long r21;              /* scratch */
 
157
        unsigned long r22;              /* scratch */
 
158
        unsigned long r23;              /* scratch */
 
159
        unsigned long r24;              /* scratch */
 
160
        unsigned long r25;              /* scratch */
 
161
        unsigned long r26;              /* scratch */
 
162
        unsigned long r27;              /* scratch */
 
163
        unsigned long r28;              /* scratch */
 
164
        unsigned long r29;              /* scratch */
 
165
        unsigned long r30;              /* scratch */
 
166
        unsigned long r31;              /* scratch */
 
167
 
 
168
        unsigned long ar_ccv;           /* compare/exchange value (scratch) */
 
169
 
 
170
        /*
 
171
         * Floating point registers that the kernel considers scratch:
 
172
         */
 
173
        struct ia64_fpreg f6;           /* scratch */
 
174
        struct ia64_fpreg f7;           /* scratch */
 
175
        struct ia64_fpreg f8;           /* scratch */
 
176
        struct ia64_fpreg f9;           /* scratch */
 
177
        struct ia64_fpreg f10;          /* scratch */
 
178
        struct ia64_fpreg f11;          /* scratch */
 
179
#ifdef XEN
 
180
        unsigned long r4;               /* preserved */
 
181
        unsigned long r5;               /* preserved */
 
182
        unsigned long r6;               /* preserved */
 
183
        unsigned long r7;               /* preserved */
 
184
        unsigned long eml_unat;         /* used for emulating instruction */
 
185
        unsigned long pad0;             /* alignment pad */
 
186
#endif
 
187
};
 
188
 
 
189
#ifdef XEN
 
190
/*
 
191
 * User regs are placed at the end of the vcpu area.
 
192
 * Convert a vcpu pointer to a regs pointer.
 
193
 * Note: this is the same as ia64_task_regs, but it uses a Xen-friendly name.
 
194
 */
 
195
struct vcpu;
 
196
static inline struct cpu_user_regs *vcpu_regs(struct vcpu *v)
 
197
{
 
198
        return (struct cpu_user_regs *)((unsigned long)v + IA64_STK_OFFSET) - 1;
 
199
}
 
200
 
 
201
struct cpu_user_regs *guest_cpu_user_regs(void);
 
202
 
 
203
extern void show_stack(struct task_struct *task, unsigned long *sp);
 
204
#endif
 
205
 
 
206
/*
 
207
 * This structure contains the addition registers that need to
 
208
 * preserved across a context switch.  This generally consists of
 
209
 * "preserved" registers.
 
210
 */
 
211
struct switch_stack {
 
212
        unsigned long caller_unat;      /* user NaT collection register (preserved) */
 
213
        unsigned long ar_fpsr;          /* floating-point status register */
 
214
 
 
215
        struct ia64_fpreg f2;           /* preserved */
 
216
        struct ia64_fpreg f3;           /* preserved */
 
217
        struct ia64_fpreg f4;           /* preserved */
 
218
        struct ia64_fpreg f5;           /* preserved */
 
219
 
 
220
        struct ia64_fpreg f12;          /* scratch, but untouched by kernel */
 
221
        struct ia64_fpreg f13;          /* scratch, but untouched by kernel */
 
222
        struct ia64_fpreg f14;          /* scratch, but untouched by kernel */
 
223
        struct ia64_fpreg f15;          /* scratch, but untouched by kernel */
 
224
        struct ia64_fpreg f16;          /* preserved */
 
225
        struct ia64_fpreg f17;          /* preserved */
 
226
        struct ia64_fpreg f18;          /* preserved */
 
227
        struct ia64_fpreg f19;          /* preserved */
 
228
        struct ia64_fpreg f20;          /* preserved */
 
229
        struct ia64_fpreg f21;          /* preserved */
 
230
        struct ia64_fpreg f22;          /* preserved */
 
231
        struct ia64_fpreg f23;          /* preserved */
 
232
        struct ia64_fpreg f24;          /* preserved */
 
233
        struct ia64_fpreg f25;          /* preserved */
 
234
        struct ia64_fpreg f26;          /* preserved */
 
235
        struct ia64_fpreg f27;          /* preserved */
 
236
        struct ia64_fpreg f28;          /* preserved */
 
237
        struct ia64_fpreg f29;          /* preserved */
 
238
        struct ia64_fpreg f30;          /* preserved */
 
239
        struct ia64_fpreg f31;          /* preserved */
 
240
 
 
241
        unsigned long r4;               /* preserved */
 
242
        unsigned long r5;               /* preserved */
 
243
        unsigned long r6;               /* preserved */
 
244
        unsigned long r7;               /* preserved */
 
245
 
 
246
        unsigned long b0;               /* so we can force a direct return in copy_thread */
 
247
        unsigned long b1;
 
248
        unsigned long b2;
 
249
        unsigned long b3;
 
250
        unsigned long b4;
 
251
        unsigned long b5;
 
252
 
 
253
        unsigned long ar_pfs;           /* previous function state */
 
254
        unsigned long ar_lc;            /* loop counter (preserved) */
 
255
        unsigned long ar_unat;          /* NaT bits for r4-r7 */
 
256
        unsigned long ar_rnat;          /* RSE NaT collection register */
 
257
        unsigned long ar_bspstore;      /* RSE dirty base (preserved) */
 
258
        unsigned long pr;               /* 64 predicate registers (1 bit each) */
 
259
};
 
260
 
 
261
#ifdef __KERNEL__
 
262
/*
 
263
 * We use the ia64_psr(regs)->ri to determine which of the three
 
264
 * instructions in bundle (16 bytes) took the sample. Generate
 
265
 * the canonical representation by adding to instruction pointer.
 
266
 */
 
267
# define instruction_pointer(regs) ((regs)->cr_iip + ia64_psr(regs)->ri)
 
268
/* Conserve space in histogram by encoding slot bits in address
 
269
 * bits 2 and 3 rather than bits 0 and 1.
 
270
 */
 
271
#define profile_pc(regs)                                                \
 
272
({                                                                      \
 
273
        unsigned long __ip = instruction_pointer(regs);                 \
 
274
        (__ip & ~3UL) + ((__ip & 3UL) << 2);                            \
 
275
})
 
276
 
 
277
  /* given a pointer to a task_struct, return the user's pt_regs */
 
278
# define ia64_task_regs(t)              (((struct pt_regs *) ((char *) (t) + IA64_STK_OFFSET)) - 1)
 
279
# define ia64_psr(regs)                 ((struct ia64_psr *) &(regs)->cr_ipsr)
 
280
#ifdef XEN
 
281
# define guest_mode(regs)               (ia64_psr(regs)->cpl != 0)
 
282
# define guest_kernel_mode(regs)        (ia64_psr(regs)->cpl == CONFIG_CPL0_EMUL)
 
283
# define vmx_guest_kernel_mode(regs)    (ia64_psr(regs)->cpl == 0)
 
284
# define regs_increment_iip(regs)                                       \
 
285
do {                                                                    \
 
286
        struct ia64_psr *ipsr = ia64_psr(regs);                         \
 
287
        if (ipsr->ri == 2) {                                            \
 
288
                ipsr->ri = 0;                                           \
 
289
                regs->cr_iip += 16;                                     \
 
290
        } else                                                          \
 
291
                ipsr->ri++;                                             \
 
292
} while (0)
 
293
#else
 
294
# define user_mode(regs)                (((struct ia64_psr *) &(regs)->cr_ipsr)->cpl != 0)
 
295
#endif
 
296
# define user_stack(task,regs)  ((long) regs - (long) task == IA64_STK_OFFSET - sizeof(*regs))
 
297
# define fsys_mode(task,regs)                                   \
 
298
  ({                                                            \
 
299
          struct task_struct *_task = (task);                   \
 
300
          struct pt_regs *_regs = (regs);                       \
 
301
          !user_mode(_regs) && user_stack(_task, _regs);        \
 
302
  })
 
303
 
 
304
  /*
 
305
   * System call handlers that, upon successful completion, need to return a negative value
 
306
   * should call force_successful_syscall_return() right before returning.  On architectures
 
307
   * where the syscall convention provides for a separate error flag (e.g., alpha, ia64,
 
308
   * ppc{,64}, sparc{,64}, possibly others), this macro can be used to ensure that the error
 
309
   * flag will not get set.  On architectures which do not support a separate error flag,
 
310
   * the macro is a no-op and the spurious error condition needs to be filtered out by some
 
311
   * other means (e.g., in user-level, by passing an extra argument to the syscall handler,
 
312
   * or something along those lines).
 
313
   *
 
314
   * On ia64, we can clear the user's pt_regs->r8 to force a successful syscall.
 
315
   */
 
316
# define force_successful_syscall_return()      (ia64_task_regs(current)->r8 = 0)
 
317
 
 
318
  struct task_struct;                   /* forward decl */
 
319
  struct unw_frame_info;                /* forward decl */
 
320
 
 
321
  extern void show_regs (struct pt_regs *);
 
322
  extern void ia64_do_show_stack (struct unw_frame_info *, void *);
 
323
  extern unsigned long ia64_get_user_rbs_end (struct task_struct *, struct pt_regs *,
 
324
                                              unsigned long *);
 
325
  extern long ia64_peek (struct task_struct *, struct switch_stack *, unsigned long,
 
326
                         unsigned long, long *);
 
327
  extern long ia64_poke (struct task_struct *, struct switch_stack *, unsigned long,
 
328
                         unsigned long, long);
 
329
  extern void ia64_flush_fph (struct task_struct *);
 
330
  extern void ia64_sync_fph (struct task_struct *);
 
331
  extern long ia64_sync_user_rbs (struct task_struct *, struct switch_stack *,
 
332
                                  unsigned long, unsigned long);
 
333
 
 
334
  /* get nat bits for scratch registers such that bit N==1 iff scratch register rN is a NaT */
 
335
  extern unsigned long ia64_get_scratch_nat_bits (struct pt_regs *pt, unsigned long scratch_unat);
 
336
  /* put nat bits for scratch registers such that scratch register rN is a NaT iff bit N==1 */
 
337
  extern unsigned long ia64_put_scratch_nat_bits (struct pt_regs *pt, unsigned long nat);
 
338
 
 
339
  extern void ia64_increment_ip (struct pt_regs *pt);
 
340
  extern void ia64_decrement_ip (struct pt_regs *pt);
 
341
 
 
342
#endif /* !__KERNEL__ */
 
343
 
 
344
/* pt_all_user_regs is used for PTRACE_GETREGS PTRACE_SETREGS */
 
345
struct pt_all_user_regs {
 
346
        unsigned long nat;
 
347
        unsigned long cr_iip;
 
348
        unsigned long cfm;
 
349
        unsigned long cr_ipsr;
 
350
        unsigned long pr;
 
351
 
 
352
        unsigned long gr[32];
 
353
        unsigned long br[8];
 
354
        unsigned long ar[128];
 
355
        struct ia64_fpreg fr[128];
 
356
};
 
357
 
 
358
#endif /* !__ASSEMBLY__ */
 
359
 
 
360
/* indices to application-registers array in pt_all_user_regs */
 
361
#define PT_AUR_RSC      16
 
362
#define PT_AUR_BSP      17
 
363
#define PT_AUR_BSPSTORE 18
 
364
#define PT_AUR_RNAT     19
 
365
#define PT_AUR_CCV      32
 
366
#define PT_AUR_UNAT     36
 
367
#define PT_AUR_FPSR     40
 
368
#define PT_AUR_PFS      64
 
369
#define PT_AUR_LC       65
 
370
#define PT_AUR_EC       66
 
371
 
 
372
/*
 
373
 * The numbers chosen here are somewhat arbitrary but absolutely MUST
 
374
 * not overlap with any of the number assigned in <linux/ptrace.h>.
 
375
 */
 
376
#define PTRACE_SINGLEBLOCK      12      /* resume execution until next branch */
 
377
#define PTRACE_OLD_GETSIGINFO   13      /* (replaced by PTRACE_GETSIGINFO in <linux/ptrace.h>)  */
 
378
#define PTRACE_OLD_SETSIGINFO   14      /* (replaced by PTRACE_SETSIGINFO in <linux/ptrace.h>)  */
 
379
#define PTRACE_GETREGS          18      /* get all registers (pt_all_user_regs) in one shot */
 
380
#define PTRACE_SETREGS          19      /* set all registers (pt_all_user_regs) in one shot */
 
381
 
 
382
#define PTRACE_OLDSETOPTIONS    21
 
383
 
 
384
#endif /* _ASM_IA64_PTRACE_H */