a9a1bab1451ac670720125c5d0b23bb34cc519c1
[sfrench/cifs-2.6.git] / include / asm-x86 / ptrace.h
1 #ifndef _ASM_X86_PTRACE_H
2 #define _ASM_X86_PTRACE_H
3
4 #include <linux/compiler.h>     /* For __user */
5 #include <asm/ptrace-abi.h>
6
7
8 #ifndef __ASSEMBLY__
9
10 #ifdef __KERNEL__
11
12 #include <asm/ds.h>
13
14 struct task_struct;
15 extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
16
17 #endif /* __KERNEL__ */
18
19
20 #ifdef __i386__
21 /* this struct defines the way the registers are stored on the
22    stack during a system call. */
23
24 #ifndef __KERNEL__
25
26 struct pt_regs {
27         long ebx;
28         long ecx;
29         long edx;
30         long esi;
31         long edi;
32         long ebp;
33         long eax;
34         int  xds;
35         int  xes;
36         int  xfs;
37         /* int  gs; */
38         long orig_eax;
39         long eip;
40         int  xcs;
41         long eflags;
42         long esp;
43         int  xss;
44 };
45
46 #else /* __KERNEL__ */
47
48 struct pt_regs {
49         long bx;
50         long cx;
51         long dx;
52         long si;
53         long di;
54         long bp;
55         long ax;
56         int  ds;
57         int  es;
58         int  fs;
59         /* int  gs; */
60         long orig_ax;
61         long ip;
62         int  cs;
63         long flags;
64         long sp;
65         int  ss;
66 };
67
68 #include <asm/vm86.h>
69 #include <asm/segment.h>
70
71 struct task_struct;
72 extern void send_sigtrap(struct task_struct *tsk, struct pt_regs *regs, int error_code);
73
74 /*
75  * user_mode_vm(regs) determines whether a register set came from user mode.
76  * This is true if V8086 mode was enabled OR if the register set was from
77  * protected mode with RPL-3 CS value.  This tricky test checks that with
78  * one comparison.  Many places in the kernel can bypass this full check
79  * if they have already ruled out V8086 mode, so user_mode(regs) can be used.
80  */
81 static inline int user_mode(struct pt_regs *regs)
82 {
83         return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
84 }
85 static inline int user_mode_vm(struct pt_regs *regs)
86 {
87         return ((regs->cs & SEGMENT_RPL_MASK) |
88                 (regs->flags & VM_MASK)) >= USER_RPL;
89 }
90 static inline int v8086_mode(struct pt_regs *regs)
91 {
92         return (regs->flags & VM_MASK);
93 }
94
95 #define instruction_pointer(regs) ((regs)->ip)
96 #define frame_pointer(regs) ((regs)->bp)
97 #define stack_pointer(regs) ((unsigned long)(regs))
98 #define regs_return_value(regs) ((regs)->ax)
99
100 extern unsigned long profile_pc(struct pt_regs *regs);
101 #endif /* __KERNEL__ */
102
103 #else /* __i386__ */
104
105 #ifndef __KERNEL__
106
107 struct pt_regs {
108         unsigned long r15;
109         unsigned long r14;
110         unsigned long r13;
111         unsigned long r12;
112         unsigned long rbp;
113         unsigned long rbx;
114 /* arguments: non interrupts/non tracing syscalls only save upto here*/
115         unsigned long r11;
116         unsigned long r10;
117         unsigned long r9;
118         unsigned long r8;
119         unsigned long rax;
120         unsigned long rcx;
121         unsigned long rdx;
122         unsigned long rsi;
123         unsigned long rdi;
124         unsigned long orig_rax;
125 /* end of arguments */
126 /* cpu exception frame or undefined */
127         unsigned long rip;
128         unsigned long cs;
129         unsigned long eflags;
130         unsigned long rsp;
131         unsigned long ss;
132 /* top of stack page */
133 };
134
135 #else /* __KERNEL__ */
136
137 struct pt_regs {
138         unsigned long r15;
139         unsigned long r14;
140         unsigned long r13;
141         unsigned long r12;
142         unsigned long bp;
143         unsigned long bx;
144 /* arguments: non interrupts/non tracing syscalls only save upto here*/
145         unsigned long r11;
146         unsigned long r10;
147         unsigned long r9;
148         unsigned long r8;
149         unsigned long ax;
150         unsigned long cx;
151         unsigned long dx;
152         unsigned long si;
153         unsigned long di;
154         unsigned long orig_ax;
155 /* end of arguments */
156 /* cpu exception frame or undefined */
157         unsigned long ip;
158         unsigned long cs;
159         unsigned long flags;
160         unsigned long sp;
161         unsigned long ss;
162 /* top of stack page */
163 };
164
165 #define user_mode(regs) (!!((regs)->cs & 3))
166 #define user_mode_vm(regs) user_mode(regs)
167 #define v8086_mode(regs) 0      /* No V86 mode support in long mode */
168 #define instruction_pointer(regs) ((regs)->ip)
169 #define frame_pointer(regs) ((regs)->bp)
170 #define stack_pointer(regs) ((regs)->sp)
171 #define regs_return_value(regs) ((regs)->ax)
172
173 extern unsigned long profile_pc(struct pt_regs *regs);
174 void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
175
176 struct task_struct;
177
178 extern unsigned long
179 convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);
180
181 #endif /* __KERNEL__ */
182 #endif /* !__i386__ */
183
184 #ifdef __KERNEL__
185
186 /*
187  * These are defined as per linux/ptrace.h, which see.
188  */
189 #define arch_has_single_step()  (1)
190 extern void user_enable_single_step(struct task_struct *);
191 extern void user_disable_single_step(struct task_struct *);
192
193 extern void user_enable_block_step(struct task_struct *);
194 #ifdef CONFIG_X86_DEBUGCTLMSR
195 #define arch_has_block_step()   (1)
196 #else
197 #define arch_has_block_step()   (boot_cpu_data.x86 >= 6)
198 #endif
199
200 struct user_desc;
201 extern int do_get_thread_area(struct task_struct *p, int idx,
202                               struct user_desc __user *info);
203 extern int do_set_thread_area(struct task_struct *p, int idx,
204                               struct user_desc __user *info, int can_allocate);
205
206 #endif /* __KERNEL__ */
207
208 #endif /* !__ASSEMBLY__ */
209
210 #endif