xref: /OK3568_Linux_fs/kernel/arch/um/include/shared/ptrace_user.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0 */
2*4882a593Smuzhiyun /*
3*4882a593Smuzhiyun  * Copyright (C) 2000 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
4*4882a593Smuzhiyun  */
5*4882a593Smuzhiyun 
6*4882a593Smuzhiyun #ifndef __PTRACE_USER_H__
7*4882a593Smuzhiyun #define __PTRACE_USER_H__
8*4882a593Smuzhiyun 
9*4882a593Smuzhiyun #include <sys/ptrace.h>
10*4882a593Smuzhiyun #include <sysdep/ptrace_user.h>
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun extern int ptrace_getregs(long pid, unsigned long *regs_out);
13*4882a593Smuzhiyun extern int ptrace_setregs(long pid, unsigned long *regs_in);
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun /* syscall emulation path in ptrace */
16*4882a593Smuzhiyun 
17*4882a593Smuzhiyun #ifndef PTRACE_SYSEMU
18*4882a593Smuzhiyun #define PTRACE_SYSEMU 31
19*4882a593Smuzhiyun #endif
20*4882a593Smuzhiyun #ifndef PTRACE_SYSEMU_SINGLESTEP
21*4882a593Smuzhiyun #define PTRACE_SYSEMU_SINGLESTEP 32
22*4882a593Smuzhiyun #endif
23*4882a593Smuzhiyun 
24*4882a593Smuzhiyun /* On architectures, that started to support PTRACE_O_TRACESYSGOOD
25*4882a593Smuzhiyun  * in linux 2.4, there are two different definitions of
26*4882a593Smuzhiyun  * PTRACE_SETOPTIONS: linux 2.4 uses 21 while linux 2.6 uses 0x4200.
27*4882a593Smuzhiyun  * For binary compatibility, 2.6 also supports the old "21", named
28*4882a593Smuzhiyun  * PTRACE_OLDSETOPTION. On these architectures, UML always must use
29*4882a593Smuzhiyun  * "21", to ensure the kernel runs on 2.4 and 2.6 host without
30*4882a593Smuzhiyun  * recompilation. So, we use PTRACE_OLDSETOPTIONS in UML.
31*4882a593Smuzhiyun  * We also want to be able to build the kernel on 2.4, which doesn't
32*4882a593Smuzhiyun  * have PTRACE_OLDSETOPTIONS. So, if it is missing, we declare
33*4882a593Smuzhiyun  * PTRACE_OLDSETOPTIONS to be the same as PTRACE_SETOPTIONS.
34*4882a593Smuzhiyun  *
35*4882a593Smuzhiyun  * On architectures, that start to support PTRACE_O_TRACESYSGOOD on
36*4882a593Smuzhiyun  * linux 2.6, PTRACE_OLDSETOPTIONS never is defined, and also isn't
37*4882a593Smuzhiyun  * supported by the host kernel. In that case, our trick lets us use
38*4882a593Smuzhiyun  * the new 0x4200 with the name PTRACE_OLDSETOPTIONS.
39*4882a593Smuzhiyun  */
40*4882a593Smuzhiyun #ifndef PTRACE_OLDSETOPTIONS
41*4882a593Smuzhiyun #define PTRACE_OLDSETOPTIONS PTRACE_SETOPTIONS
42*4882a593Smuzhiyun #endif
43*4882a593Smuzhiyun 
44*4882a593Smuzhiyun void set_using_sysemu(int value);
45*4882a593Smuzhiyun int get_using_sysemu(void);
46*4882a593Smuzhiyun extern int sysemu_supported;
47*4882a593Smuzhiyun 
48*4882a593Smuzhiyun #define SELECT_PTRACE_OPERATION(sysemu_mode, singlestep_mode) \
49*4882a593Smuzhiyun 	(((int[3][3] ) { \
50*4882a593Smuzhiyun 		{ PTRACE_SYSCALL, PTRACE_SYSCALL, PTRACE_SINGLESTEP }, \
51*4882a593Smuzhiyun 		{ PTRACE_SYSEMU, PTRACE_SYSEMU, PTRACE_SINGLESTEP }, \
52*4882a593Smuzhiyun 		{ PTRACE_SYSEMU, PTRACE_SYSEMU_SINGLESTEP, \
53*4882a593Smuzhiyun 		  PTRACE_SYSEMU_SINGLESTEP } }) \
54*4882a593Smuzhiyun 		[sysemu_mode][singlestep_mode])
55*4882a593Smuzhiyun 
56*4882a593Smuzhiyun #endif
57