1 #ifndef _ASM_X86_PTRACE_H
2 #define _ASM_X86_PTRACE_H
4 #include <linux/compiler.h> /* For __user */
5 #include <asm/ptrace-abi.h>
11 /* this struct defines the way the registers are stored on the
12 stack during a system call. */
36 #else /* __KERNEL__ */
50 unsigned long orig_ax
;
59 #include <asm/segment.h>
61 #endif /* __KERNEL__ */
74 /* arguments: non interrupts/non tracing syscalls only save upto here*/
84 unsigned long orig_rax
;
85 /* end of arguments */
86 /* cpu exception frame or undefined */
92 /* top of stack page */
95 #else /* __KERNEL__ */
104 /* arguments: non interrupts/non tracing syscalls only save upto here*/
114 unsigned long orig_ax
;
115 /* end of arguments */
116 /* cpu exception frame or undefined */
122 /* top of stack page */
125 #endif /* __KERNEL__ */
126 #endif /* !__i386__ */
130 /* the DS BTS struct is used for ptrace as well */
135 extern void ptrace_bts_take_timestamp(struct task_struct
*, enum bts_qualifier
);
137 extern unsigned long profile_pc(struct pt_regs
*regs
);
140 convert_ip_to_linear(struct task_struct
*child
, struct pt_regs
*regs
);
143 extern void send_sigtrap(struct task_struct
*tsk
, struct pt_regs
*regs
,
146 void signal_fault(struct pt_regs
*regs
, void __user
*frame
, char *where
);
149 static inline unsigned long regs_return_value(struct pt_regs
*regs
)
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.
161 static inline int user_mode(struct pt_regs
*regs
)
164 return (regs
->cs
& SEGMENT_RPL_MASK
) == USER_RPL
;
166 return !!(regs
->cs
& 3);
170 static inline int user_mode_vm(struct pt_regs
*regs
)
173 return ((regs
->cs
& SEGMENT_RPL_MASK
) | (regs
->flags
& X86_VM_MASK
)) >=
176 return user_mode(regs
);
180 static inline int v8086_mode(struct pt_regs
*regs
)
183 return (regs
->flags
& X86_VM_MASK
);
185 return 0; /* No V86 mode support in long mode */
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.
193 * This is valid only for kernel mode traps.
195 static inline unsigned long kernel_trap_sp(struct pt_regs
*regs
)
198 return (unsigned long)regs
;
204 static inline unsigned long instruction_pointer(struct pt_regs
*regs
)
209 static inline unsigned long frame_pointer(struct pt_regs
*regs
)
215 * These are defined as per linux/ptrace.h, which see.
217 #define arch_has_single_step() (1)
218 extern void user_enable_single_step(struct task_struct
*);
219 extern void user_disable_single_step(struct task_struct
*);
221 extern void user_enable_block_step(struct task_struct
*);
222 #ifdef CONFIG_X86_DEBUGCTLMSR
223 #define arch_has_block_step() (1)
225 #define arch_has_block_step() (boot_cpu_data.x86 >= 6)
229 extern int do_get_thread_area(struct task_struct
*p
, int idx
,
230 struct user_desc __user
*info
);
231 extern int do_set_thread_area(struct task_struct
*p
, int idx
,
232 struct user_desc __user
*info
, int can_allocate
);
234 #define __ARCH_WANT_COMPAT_SYS_PTRACE
236 #endif /* __KERNEL__ */
238 #endif /* !__ASSEMBLY__ */