xref: /openbmc/linux/arch/x86/um/shared/sysdep/ptrace.h (revision 12eb4683)
1 #ifndef __SYSDEP_X86_PTRACE_H
2 #define __SYSDEP_X86_PTRACE_H
3 
4 #include <generated/user_constants.h>
5 #include <sysdep/faultinfo.h>
6 
7 #define MAX_REG_OFFSET (UM_FRAME_SIZE)
8 #define MAX_REG_NR ((MAX_REG_OFFSET) / sizeof(unsigned long))
9 
10 #define REGS_IP(r) ((r)[HOST_IP])
11 #define REGS_SP(r) ((r)[HOST_SP])
12 #define REGS_EFLAGS(r) ((r)[HOST_EFLAGS])
13 #define REGS_AX(r) ((r)[HOST_AX])
14 #define REGS_BX(r) ((r)[HOST_BX])
15 #define REGS_CX(r) ((r)[HOST_CX])
16 #define REGS_DX(r) ((r)[HOST_DX])
17 #define REGS_SI(r) ((r)[HOST_SI])
18 #define REGS_DI(r) ((r)[HOST_DI])
19 #define REGS_BP(r) ((r)[HOST_BP])
20 #define REGS_CS(r) ((r)[HOST_CS])
21 #define REGS_SS(r) ((r)[HOST_SS])
22 #define REGS_DS(r) ((r)[HOST_DS])
23 #define REGS_ES(r) ((r)[HOST_ES])
24 
25 #define UPT_IP(r) REGS_IP((r)->gp)
26 #define UPT_SP(r) REGS_SP((r)->gp)
27 #define UPT_EFLAGS(r) REGS_EFLAGS((r)->gp)
28 #define UPT_AX(r) REGS_AX((r)->gp)
29 #define UPT_BX(r) REGS_BX((r)->gp)
30 #define UPT_CX(r) REGS_CX((r)->gp)
31 #define UPT_DX(r) REGS_DX((r)->gp)
32 #define UPT_SI(r) REGS_SI((r)->gp)
33 #define UPT_DI(r) REGS_DI((r)->gp)
34 #define UPT_BP(r) REGS_BP((r)->gp)
35 #define UPT_CS(r) REGS_CS((r)->gp)
36 #define UPT_SS(r) REGS_SS((r)->gp)
37 #define UPT_DS(r) REGS_DS((r)->gp)
38 #define UPT_ES(r) REGS_ES((r)->gp)
39 
40 #ifdef __i386__
41 #include "ptrace_32.h"
42 #else
43 #include "ptrace_64.h"
44 #endif
45 
46 struct syscall_args {
47 	unsigned long args[6];
48 };
49 
50 #define SYSCALL_ARGS(r) ((struct syscall_args) \
51 			 { .args = { UPT_SYSCALL_ARG1(r),	 \
52 				     UPT_SYSCALL_ARG2(r),	 \
53 				     UPT_SYSCALL_ARG3(r),	 \
54 				     UPT_SYSCALL_ARG4(r),	 \
55 				     UPT_SYSCALL_ARG5(r),	 \
56 				     UPT_SYSCALL_ARG6(r) } } )
57 
58 struct uml_pt_regs {
59 	unsigned long gp[MAX_REG_NR];
60 	unsigned long fp[MAX_FP_NR];
61 	struct faultinfo faultinfo;
62 	long syscall;
63 	int is_user;
64 };
65 
66 #define EMPTY_UML_PT_REGS { }
67 
68 #define UPT_SYSCALL_NR(r) ((r)->syscall)
69 #define UPT_FAULTINFO(r) (&(r)->faultinfo)
70 #define UPT_IS_USER(r) ((r)->is_user)
71 
72 extern int user_context(unsigned long sp);
73 
74 #endif /* __SYSDEP_X86_PTRACE_H */
75