]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blame - include/asm-x86/ptrace.h
x86, ptrace: support for branch trace store(BTS)
[mirror_ubuntu-artful-kernel.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
eee3af4a
MM
10#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
8fc37f2c
TG
20#ifdef __i386__
21/* this struct defines the way the registers are stored on the
22 stack during a system call. */
23
65ea5b03
PA
24#ifndef __KERNEL__
25
8fc37f2c
TG
26struct 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;
65ea5b03 37 /* int gs; */
8fc37f2c
TG
38 long orig_eax;
39 long eip;
40 int xcs;
41 long eflags;
42 long esp;
43 int xss;
44};
45
65ea5b03
PA
46#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};
8fc37f2c
TG
67
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{
65ea5b03 83 return (regs->cs & SEGMENT_RPL_MASK) == USER_RPL;
8fc37f2c
TG
84}
85static inline int user_mode_vm(struct pt_regs *regs)
86{
65ea5b03
PA
87 return ((regs->cs & SEGMENT_RPL_MASK) |
88 (regs->flags & VM_MASK)) >= USER_RPL;
8fc37f2c
TG
89}
90static inline int v8086_mode(struct pt_regs *regs)
91{
65ea5b03 92 return (regs->flags & VM_MASK);
8fc37f2c
TG
93}
94
65ea5b03
PA
95#define instruction_pointer(regs) ((regs)->ip)
96#define frame_pointer(regs) ((regs)->bp)
77f2878b 97#define stack_pointer(regs) ((unsigned long)(regs))
65ea5b03 98#define regs_return_value(regs) ((regs)->ax)
8fc37f2c
TG
99
100extern unsigned long profile_pc(struct pt_regs *regs);
101#endif /* __KERNEL__ */
102
103#else /* __i386__ */
104
65ea5b03
PA
105#ifndef __KERNEL__
106
8fc37f2c
TG
107struct 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
65ea5b03
PA
135#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};
8fc37f2c
TG
164
165#define user_mode(regs) (!!((regs)->cs & 3))
166#define user_mode_vm(regs) user_mode(regs)
65ea5b03
PA
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)
8fc37f2c
TG
172
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
8fc37f2c
TG
181#endif /* __KERNEL__ */
182#endif /* !__i386__ */
efd1ca52
RM
183
184#ifdef __KERNEL__
185
7f232343
RM
186/*
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
10faa81e
RM
193extern 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
efd1ca52
RM
200struct 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
8fc37f2c
TG
208#endif /* !__ASSEMBLY__ */
209
96a388de 210#endif