1*b2441318SGreg Kroah-Hartman /* SPDX-License-Identifier: GPL-2.0 */
2243412beSAl Viro #ifndef __UM_X86_PTRACE_H
3243412beSAl Viro #define __UM_X86_PTRACE_H
4243412beSAl Viro
58813f674SAl Viro #include <linux/compiler.h>
68813f674SAl Viro #ifndef CONFIG_X86_32
78813f674SAl Viro #define __FRAME_OFFSETS /* Needed to get the R* macros */
85c48b108SAl Viro #endif
98813f674SAl Viro #include <asm/ptrace-generic.h>
108813f674SAl Viro
118813f674SAl Viro #define user_mode(r) UPT_IS_USER(&(r)->regs)
12243412beSAl Viro
13243412beSAl Viro #define PT_REGS_AX(r) UPT_AX(&(r)->regs)
14243412beSAl Viro #define PT_REGS_BX(r) UPT_BX(&(r)->regs)
15243412beSAl Viro #define PT_REGS_CX(r) UPT_CX(&(r)->regs)
16243412beSAl Viro #define PT_REGS_DX(r) UPT_DX(&(r)->regs)
17243412beSAl Viro
18243412beSAl Viro #define PT_REGS_SI(r) UPT_SI(&(r)->regs)
19243412beSAl Viro #define PT_REGS_DI(r) UPT_DI(&(r)->regs)
20243412beSAl Viro #define PT_REGS_BP(r) UPT_BP(&(r)->regs)
21243412beSAl Viro #define PT_REGS_EFLAGS(r) UPT_EFLAGS(&(r)->regs)
22243412beSAl Viro
23243412beSAl Viro #define PT_REGS_CS(r) UPT_CS(&(r)->regs)
24243412beSAl Viro #define PT_REGS_SS(r) UPT_SS(&(r)->regs)
25243412beSAl Viro #define PT_REGS_DS(r) UPT_DS(&(r)->regs)
26243412beSAl Viro #define PT_REGS_ES(r) UPT_ES(&(r)->regs)
27243412beSAl Viro
28243412beSAl Viro #define PT_REGS_ORIG_SYSCALL(r) PT_REGS_AX(r)
29243412beSAl Viro #define PT_REGS_SYSCALL_RET(r) PT_REGS_AX(r)
30243412beSAl Viro
31243412beSAl Viro #define PT_FIX_EXEC_STACK(sp) do ; while(0)
32243412beSAl Viro
33243412beSAl Viro #define profile_pc(regs) PT_REGS_IP(regs)
34243412beSAl Viro
35243412beSAl Viro #define UPT_RESTART_SYSCALL(r) (UPT_IP(r) -= 2)
36a3170d2eSAl Viro #define PT_REGS_SET_SYSCALL_RETURN(r, res) (PT_REGS_AX(r) = (res))
37243412beSAl Viro
regs_return_value(struct pt_regs * regs)38a3170d2eSAl Viro static inline long regs_return_value(struct pt_regs *regs)
39243412beSAl Viro {
40a3170d2eSAl Viro return PT_REGS_AX(regs);
41243412beSAl Viro }
428813f674SAl Viro
438813f674SAl Viro /*
448813f674SAl Viro * Forward declaration to avoid including sysdep/tls.h, which causes a
458813f674SAl Viro * circular include, and compilation failures.
468813f674SAl Viro */
478813f674SAl Viro struct user_desc;
488813f674SAl Viro
498813f674SAl Viro #ifdef CONFIG_X86_32
508813f674SAl Viro
518813f674SAl Viro extern int ptrace_get_thread_area(struct task_struct *child, int idx,
528813f674SAl Viro struct user_desc __user *user_desc);
538813f674SAl Viro
548813f674SAl Viro extern int ptrace_set_thread_area(struct task_struct *child, int idx,
558813f674SAl Viro struct user_desc __user *user_desc);
568813f674SAl Viro
578813f674SAl Viro #else
588813f674SAl Viro
598813f674SAl Viro #define PT_REGS_R8(r) UPT_R8(&(r)->regs)
608813f674SAl Viro #define PT_REGS_R9(r) UPT_R9(&(r)->regs)
618813f674SAl Viro #define PT_REGS_R10(r) UPT_R10(&(r)->regs)
628813f674SAl Viro #define PT_REGS_R11(r) UPT_R11(&(r)->regs)
638813f674SAl Viro #define PT_REGS_R12(r) UPT_R12(&(r)->regs)
648813f674SAl Viro #define PT_REGS_R13(r) UPT_R13(&(r)->regs)
658813f674SAl Viro #define PT_REGS_R14(r) UPT_R14(&(r)->regs)
668813f674SAl Viro #define PT_REGS_R15(r) UPT_R15(&(r)->regs)
678813f674SAl Viro
688813f674SAl Viro #include <asm/errno.h>
698813f674SAl Viro
ptrace_get_thread_area(struct task_struct * child,int idx,struct user_desc __user * user_desc)708813f674SAl Viro static inline int ptrace_get_thread_area(struct task_struct *child, int idx,
718813f674SAl Viro struct user_desc __user *user_desc)
728813f674SAl Viro {
738813f674SAl Viro return -ENOSYS;
748813f674SAl Viro }
758813f674SAl Viro
ptrace_set_thread_area(struct task_struct * child,int idx,struct user_desc __user * user_desc)768813f674SAl Viro static inline int ptrace_set_thread_area(struct task_struct *child, int idx,
778813f674SAl Viro struct user_desc __user *user_desc)
788813f674SAl Viro {
798813f674SAl Viro return -ENOSYS;
808813f674SAl Viro }
818813f674SAl Viro
82dd93938aSKyle Huey extern long arch_prctl(struct task_struct *task, int option,
838813f674SAl Viro unsigned long __user *addr);
848813f674SAl Viro
858813f674SAl Viro #endif
865208ba24SAl Viro #define user_stack_pointer(regs) PT_REGS_SP(regs)
87243412beSAl Viro #endif /* __UM_X86_PTRACE_H */
88