blob: 54f8102ccde5d2774f375f6584c31c712f46d915 [file] [log] [blame]
Al Viro243412b2012-05-20 00:05:58 -04001#ifndef __UM_X86_PTRACE_H
2#define __UM_X86_PTRACE_H
3
Al Viro8813f672012-10-08 03:26:17 +01004#include <linux/compiler.h>
5#ifndef CONFIG_X86_32
6#define __FRAME_OFFSETS /* Needed to get the R* macros */
Al Viro27f85f12011-08-18 20:02:59 +01007#endif
Al Viro8813f672012-10-08 03:26:17 +01008#include <asm/ptrace-generic.h>
9
10#define user_mode(r) UPT_IS_USER(&(r)->regs)
Al Viro243412b2012-05-20 00:05:58 -040011
12#define PT_REGS_AX(r) UPT_AX(&(r)->regs)
13#define PT_REGS_BX(r) UPT_BX(&(r)->regs)
14#define PT_REGS_CX(r) UPT_CX(&(r)->regs)
15#define PT_REGS_DX(r) UPT_DX(&(r)->regs)
16
17#define PT_REGS_SI(r) UPT_SI(&(r)->regs)
18#define PT_REGS_DI(r) UPT_DI(&(r)->regs)
19#define PT_REGS_BP(r) UPT_BP(&(r)->regs)
20#define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
21
22#define PT_REGS_CS(r) UPT_CS(&(r)->regs)
23#define PT_REGS_SS(r) UPT_SS(&(r)->regs)
24#define PT_REGS_DS(r) UPT_DS(&(r)->regs)
25#define PT_REGS_ES(r) UPT_ES(&(r)->regs)
26
27#define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
28#define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)
29
30#define PT_FIX_EXEC_STACK(sp) do ; while(0)
31
32#define profile_pc(regs) PT_REGS_IP(regs)
33
34#define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
Al Viroa3170d22012-05-22 21:16:35 -040035#define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
Al Viro243412b2012-05-20 00:05:58 -040036
Al Viroa3170d22012-05-22 21:16:35 -040037static inline long regs_return_value(struct pt_regs *regs)
Al Viro243412b2012-05-20 00:05:58 -040038{
Al Viroa3170d22012-05-22 21:16:35 -040039 return PT_REGS_AX(regs);
Al Viro243412b2012-05-20 00:05:58 -040040}
Al Viro8813f672012-10-08 03:26:17 +010041
42/*
43 * Forward declaration to avoid including sysdep/tls.h, which causes a
44 * circular include, and compilation failures.
45 */
46struct user_desc;
47
48#ifdef CONFIG_X86_32
49
50#define HOST_AUDIT_ARCH AUDIT_ARCH_I386
51
52extern int ptrace_get_thread_area(struct task_struct *child, int idx,
53 struct user_desc __user *user_desc);
54
55extern int ptrace_set_thread_area(struct task_struct *child, int idx,
56 struct user_desc __user *user_desc);
57
58#else
59
60#define HOST_AUDIT_ARCH AUDIT_ARCH_X86_64
61
62#define PT_REGS_R8(r) UPT_R8(&(r)->regs)
63#define PT_REGS_R9(r) UPT_R9(&(r)->regs)
64#define PT_REGS_R10(r) UPT_R10(&(r)->regs)
65#define PT_REGS_R11(r) UPT_R11(&(r)->regs)
66#define PT_REGS_R12(r) UPT_R12(&(r)->regs)
67#define PT_REGS_R13(r) UPT_R13(&(r)->regs)
68#define PT_REGS_R14(r) UPT_R14(&(r)->regs)
69#define PT_REGS_R15(r) UPT_R15(&(r)->regs)
70
71#include <asm/errno.h>
72
73static inline int ptrace_get_thread_area(struct task_struct *child, int idx,
74 struct user_desc __user *user_desc)
75{
76 return -ENOSYS;
77}
78
79static inline int ptrace_set_thread_area(struct task_struct *child, int idx,
80 struct user_desc __user *user_desc)
81{
82 return -ENOSYS;
83}
84
85extern long arch_prctl(struct task_struct *task, int code,
86 unsigned long __user *addr);
87
88#endif
Al Viro5208ba22012-12-14 01:50:19 -050089#define user_stack_pointer(regs) PT_REGS_SP(regs)
Al Viro243412b2012-05-20 00:05:58 -040090#endif /* __UM_X86_PTRACE_H */