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