blob: a9a1bab1451ac670720125c5d0b23bb34cc519c1 [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
12#include <asm/ds.h>
13
14struct task_struct;
15extern void ptrace_bts_take_timestamp(struct task_struct *, enum bts_qualifier);
16
17#endif /* __KERNEL__ */
18
19
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020020#ifdef __i386__
21/* this struct defines the way the registers are stored on the
22 stack during a system call. */
23
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010024#ifndef __KERNEL__
25
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020026struct 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;
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010037 /* int gs; */
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020038 long orig_eax;
39 long eip;
40 int xcs;
41 long eflags;
42 long esp;
43 int xss;
44};
45
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010046#else /* __KERNEL__ */
47
48struct 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};
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020067
68#include <asm/vm86.h>
69#include <asm/segment.h>
70
71struct task_struct;
72extern 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 */
81static inline int user_mode(struct pt_regs *regs)
82{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010083 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020084}
85static inline int user_mode_vm(struct pt_regs *regs)
86{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010087 return ((regs->cs & SEGMENT_RPL_MASK) |
88 (regs->flags & VM_MASK)) >= USER_RPL;
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020089}
90static inline int v8086_mode(struct pt_regs *regs)
91{
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010092 return (regs->flags & VM_MASK);
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020093}
94
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010095#define instruction_pointer(regs) ((regs)->ip)
96#define frame_pointer(regs) ((regs)->bp)
Jan Blunck77f28782007-11-14 17:00:42 -080097#define stack_pointer(regs) ((unsigned long)(regs))
H. Peter Anvin65ea5b02008-01-30 13:30:56 +010098#define regs_return_value(regs) ((regs)->ax)
Thomas Gleixner8fc37f22007-10-23 22:37:24 +020099
100extern unsigned long profile_pc(struct pt_regs *regs);
101#endif /* __KERNEL__ */
102
103#else /* __i386__ */
104
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100105#ifndef __KERNEL__
106
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200107struct 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
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100135#else /* __KERNEL__ */
136
137struct 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};
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200164
165#define user_mode(regs) (!!((regs)->cs & 3))
166#define user_mode_vm(regs) user_mode(regs)
H. Peter Anvin65ea5b02008-01-30 13:30:56 +0100167#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)
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200172
173extern unsigned long profile_pc(struct pt_regs *regs);
174void signal_fault(struct pt_regs *regs, void __user *frame, char *where);
175
176struct task_struct;
177
178extern unsigned long
179convert_rip_to_linear(struct task_struct *child, struct pt_regs *regs);
180
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200181#endif /* __KERNEL__ */
182#endif /* !__i386__ */
Roland McGrathefd1ca52008-01-30 13:30:46 +0100183
184#ifdef __KERNEL__
185
Roland McGrath7f232342008-01-30 13:30:48 +0100186/*
187 * These are defined as per linux/ptrace.h, which see.
188 */
189#define arch_has_single_step() (1)
190extern void user_enable_single_step(struct task_struct *);
191extern void user_disable_single_step(struct task_struct *);
192
Roland McGrath10faa812008-01-30 13:30:54 +0100193extern 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
Roland McGrathefd1ca52008-01-30 13:30:46 +0100200struct user_desc;
201extern int do_get_thread_area(struct task_struct *p, int idx,
202 struct user_desc __user *info);
203extern 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
Thomas Gleixner8fc37f22007-10-23 22:37:24 +0200208#endif /* !__ASSEMBLY__ */
209
Thomas Gleixner96a388d2007-10-11 11:20:03 +0200210#endif