blob: ee4b595e1ccc4ffbeb4a6306015d93d004ece504 [file] [log] [blame]
Thomas Gleixner8fc37f22007-10-23 22:37:24 +02001#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
Markus Metzgereee3af42008-01-30 13:31:09 +01007
Thomas Gleixner8fc37f22007-10-23 22:37:24 +02008#ifndef __ASSEMBLY__
9
Markus Metzgereee3af42008-01-30 13:31:09 +010010#ifdef __KERNEL__
11
Markus Metzgera95d67f2008-01-30 13:31:20 +010012/* the DS BTS struct is used for ptrace as well */
Markus Metzgereee3af42008-01-30 13:31:09 +010013#include <asm/ds.h>
14
15struct task_struct;
16extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
17
18#endif /* __KERNEL__ */
19
20
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020021#ifdef __i386__
22/* this struct defines the way the registers are stored on the
23 stack during a system call. */
24
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010025#ifndef __KERNEL__
26
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020027struct 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;
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010038 /* int gs; */
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020039 long orig_eax;
40 long eip;
41 int xcs;
42 long eflags;
43 long esp;
44 int xss;
45};
46
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010047#else /* __KERNEL__ */
48
49struct 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};
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020068
69#include <asm/vm86.h>
70#include <asm/segment.h>
71
72struct task_struct;
Harvey Harrisonf2857ce2008-01-30 13:33:12 +010073
74extern unsigned long
75convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
76
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020077extern 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 */
86static inline int user_mode(struct pt_regs *regs)
87{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010088 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020089}
90static inline int user_mode_vm(struct pt_regs *regs)
91{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010092 return ((regs->cs & SEGMENT_RPL_MASK) |
93 (regs->flags & VM_MASK)) >= USER_RPL;
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020094}
95static inline int v8086_mode(struct pt_regs *regs)
96{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010097 return (regs->flags & VM_MASK);
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020098}
99
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100100#define instruction_pointer(regs) ((regs)->ip)
101#define frame_pointer(regs) ((regs)->bp)
Jan Blunck77f28782007-11-14 17:00:42 -0800102#define stack_pointer(regs) ((unsigned long)(regs))
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100103#define regs_return_value(regs) ((regs)->ax)
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200104
105extern unsigned long profile_pc(struct pt_regs *regs);
106#endif /* __KERNEL__ */
107
108#else /* __i386__ */
109
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100110#ifndef __KERNEL__
111
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200112struct 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
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100140#else /* __KERNEL__ */
141
142struct 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};
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200169
170#define user_mode(regs) (!!((regs)->cs & 3))
171#define user_mode_vm(regs) user_mode(regs)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100172#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)
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200177
178extern unsigned long profile_pc(struct pt_regs *regs);
179void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
180
181struct task_struct;
182
183extern unsigned long
Harvey Harrison37cd9cf2008-01-30 13:33:12 +0100184convert_ip_to_linear(struct task_struct *child, struct pt_regs *regs);
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200185
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200186#endif /* __KERNEL__ */
187#endif /* !__i386__ */
Roland McGrathefd1ca52008-01-30 13:30:46 +0100188
189#ifdef __KERNEL__
190
Roland McGrath7f232342008-01-30 13:30:48 +0100191/*
192 * These are defined as per linux/ptrace.h, which see.
193 */
194#define arch_has_single_step() (1)
195extern void user_enable_single_step(struct task_struct *);
196extern void user_disable_single_step(struct task_struct *);
197
Roland McGrath10faa812008-01-30 13:30:54 +0100198extern 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
Roland McGrathefd1ca52008-01-30 13:30:46 +0100205struct user_desc;
206extern int do_get_thread_area(struct task_struct *p, int idx,
207 struct user_desc __user *info);
208extern 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
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200213#endif /* !__ASSEMBLY__ */
214
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200215#endif