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