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