1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __UM_X86_PTRACE_H
3 #define __UM_X86_PTRACE_H
5 #include <linux/compiler.h>
7 #define __FRAME_OFFSETS /* Needed to get the R* macros */
9 #include <asm/ptrace-generic.h>
11 #define user_mode(r) UPT_IS_USER(&(r)->regs)
13 #define PT_REGS_AX(r) UPT_AX(&(r)->regs)
14 #define PT_REGS_BX(r) UPT_BX(&(r)->regs)
15 #define PT_REGS_CX(r) UPT_CX(&(r)->regs)
16 #define PT_REGS_DX(r) UPT_DX(&(r)->regs)
18 #define PT_REGS_SI(r) UPT_SI(&(r)->regs)
19 #define PT_REGS_DI(r) UPT_DI(&(r)->regs)
20 #define PT_REGS_BP(r) UPT_BP(&(r)->regs)
21 #define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
23 #define PT_REGS_CS(r) UPT_CS(&(r)->regs)
24 #define PT_REGS_SS(r) UPT_SS(&(r)->regs)
25 #define PT_REGS_DS(r) UPT_DS(&(r)->regs)
26 #define PT_REGS_ES(r) UPT_ES(&(r)->regs)
28 #define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
29 #define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)
31 #define PT_FIX_EXEC_STACK(sp) do ; while(0)
33 #define profile_pc(regs) PT_REGS_IP(regs)
35 #define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
36 #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
38 static inline long regs_return_value(struct pt_regs
*regs
)
40 return PT_REGS_AX(regs
);
44 * Forward declaration to avoid including sysdep/tls.h, which causes a
45 * circular include, and compilation failures.
51 extern int ptrace_get_thread_area(struct task_struct
*child
, int idx
,
52 struct user_desc __user
*user_desc
);
54 extern int ptrace_set_thread_area(struct task_struct
*child
, int idx
,
55 struct user_desc __user
*user_desc
);
59 #define PT_REGS_R8(r) UPT_R8(&(r)->regs)
60 #define PT_REGS_R9(r) UPT_R9(&(r)->regs)
61 #define PT_REGS_R10(r) UPT_R10(&(r)->regs)
62 #define PT_REGS_R11(r) UPT_R11(&(r)->regs)
63 #define PT_REGS_R12(r) UPT_R12(&(r)->regs)
64 #define PT_REGS_R13(r) UPT_R13(&(r)->regs)
65 #define PT_REGS_R14(r) UPT_R14(&(r)->regs)
66 #define PT_REGS_R15(r) UPT_R15(&(r)->regs)
68 #include <asm/errno.h>
70 static inline int ptrace_get_thread_area(struct task_struct
*child
, int idx
,
71 struct user_desc __user
*user_desc
)
76 static inline int ptrace_set_thread_area(struct task_struct
*child
, int idx
,
77 struct user_desc __user
*user_desc
)
82 extern long arch_prctl(struct task_struct
*task
, int option
,
83 unsigned long __user
*addr
);
86 #define user_stack_pointer(regs) PT_REGS_SP(regs)
87 #endif /* __UM_X86_PTRACE_H */