diff options
author | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
---|---|---|
committer | Jonathan Herman <hermanjl@cs.unc.edu> | 2013-01-17 16:15:55 -0500 |
commit | 8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch) | |
tree | a8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /include/linux/ptrace.h | |
parent | 406089d01562f1e2bf9f089fd7637009ebaad589 (diff) |
Patched in Tegra support.
Diffstat (limited to 'include/linux/ptrace.h')
-rw-r--r-- | include/linux/ptrace.h | 140 |
1 files changed, 93 insertions, 47 deletions
diff --git a/include/linux/ptrace.h b/include/linux/ptrace.h index 1693775ecfe..800f113bea6 100644 --- a/include/linux/ptrace.h +++ b/include/linux/ptrace.h | |||
@@ -1,12 +1,82 @@ | |||
1 | #ifndef _LINUX_PTRACE_H | 1 | #ifndef _LINUX_PTRACE_H |
2 | #define _LINUX_PTRACE_H | 2 | #define _LINUX_PTRACE_H |
3 | /* ptrace.h */ | ||
4 | /* structs and defines to help the user use the ptrace system call. */ | ||
3 | 5 | ||
4 | #include <linux/compiler.h> /* For unlikely. */ | 6 | /* has the defines to get at the registers. */ |
5 | #include <linux/sched.h> /* For struct task_struct. */ | 7 | |
6 | #include <linux/err.h> /* for IS_ERR_VALUE */ | 8 | #define PTRACE_TRACEME 0 |
7 | #include <linux/bug.h> /* For BUG_ON. */ | 9 | #define PTRACE_PEEKTEXT 1 |
8 | #include <uapi/linux/ptrace.h> | 10 | #define PTRACE_PEEKDATA 2 |
11 | #define PTRACE_PEEKUSR 3 | ||
12 | #define PTRACE_POKETEXT 4 | ||
13 | #define PTRACE_POKEDATA 5 | ||
14 | #define PTRACE_POKEUSR 6 | ||
15 | #define PTRACE_CONT 7 | ||
16 | #define PTRACE_KILL 8 | ||
17 | #define PTRACE_SINGLESTEP 9 | ||
18 | |||
19 | #define PTRACE_ATTACH 16 | ||
20 | #define PTRACE_DETACH 17 | ||
9 | 21 | ||
22 | #define PTRACE_SYSCALL 24 | ||
23 | |||
24 | /* 0x4200-0x4300 are reserved for architecture-independent additions. */ | ||
25 | #define PTRACE_SETOPTIONS 0x4200 | ||
26 | #define PTRACE_GETEVENTMSG 0x4201 | ||
27 | #define PTRACE_GETSIGINFO 0x4202 | ||
28 | #define PTRACE_SETSIGINFO 0x4203 | ||
29 | |||
30 | /* | ||
31 | * Generic ptrace interface that exports the architecture specific regsets | ||
32 | * using the corresponding NT_* types (which are also used in the core dump). | ||
33 | * Please note that the NT_PRSTATUS note type in a core dump contains a full | ||
34 | * 'struct elf_prstatus'. But the user_regset for NT_PRSTATUS contains just the | ||
35 | * elf_gregset_t that is the pr_reg field of 'struct elf_prstatus'. For all the | ||
36 | * other user_regset flavors, the user_regset layout and the ELF core dump note | ||
37 | * payload are exactly the same layout. | ||
38 | * | ||
39 | * This interface usage is as follows: | ||
40 | * struct iovec iov = { buf, len}; | ||
41 | * | ||
42 | * ret = ptrace(PTRACE_GETREGSET/PTRACE_SETREGSET, pid, NT_XXX_TYPE, &iov); | ||
43 | * | ||
44 | * On the successful completion, iov.len will be updated by the kernel, | ||
45 | * specifying how much the kernel has written/read to/from the user's iov.buf. | ||
46 | */ | ||
47 | #define PTRACE_GETREGSET 0x4204 | ||
48 | #define PTRACE_SETREGSET 0x4205 | ||
49 | |||
50 | #define PTRACE_SEIZE 0x4206 | ||
51 | #define PTRACE_INTERRUPT 0x4207 | ||
52 | #define PTRACE_LISTEN 0x4208 | ||
53 | |||
54 | /* flags in @data for PTRACE_SEIZE */ | ||
55 | #define PTRACE_SEIZE_DEVEL 0x80000000 /* temp flag for development */ | ||
56 | |||
57 | /* options set using PTRACE_SETOPTIONS */ | ||
58 | #define PTRACE_O_TRACESYSGOOD 0x00000001 | ||
59 | #define PTRACE_O_TRACEFORK 0x00000002 | ||
60 | #define PTRACE_O_TRACEVFORK 0x00000004 | ||
61 | #define PTRACE_O_TRACECLONE 0x00000008 | ||
62 | #define PTRACE_O_TRACEEXEC 0x00000010 | ||
63 | #define PTRACE_O_TRACEVFORKDONE 0x00000020 | ||
64 | #define PTRACE_O_TRACEEXIT 0x00000040 | ||
65 | |||
66 | #define PTRACE_O_MASK 0x0000007f | ||
67 | |||
68 | /* Wait extended result codes for the above trace options. */ | ||
69 | #define PTRACE_EVENT_FORK 1 | ||
70 | #define PTRACE_EVENT_VFORK 2 | ||
71 | #define PTRACE_EVENT_CLONE 3 | ||
72 | #define PTRACE_EVENT_EXEC 4 | ||
73 | #define PTRACE_EVENT_VFORK_DONE 5 | ||
74 | #define PTRACE_EVENT_EXIT 6 | ||
75 | #define PTRACE_EVENT_STOP 7 | ||
76 | |||
77 | #include <asm/ptrace.h> | ||
78 | |||
79 | #ifdef __KERNEL__ | ||
10 | /* | 80 | /* |
11 | * Ptrace flags | 81 | * Ptrace flags |
12 | * | 82 | * |
@@ -18,21 +88,21 @@ | |||
18 | #define PT_SEIZED 0x00010000 /* SEIZE used, enable new behavior */ | 88 | #define PT_SEIZED 0x00010000 /* SEIZE used, enable new behavior */ |
19 | #define PT_PTRACED 0x00000001 | 89 | #define PT_PTRACED 0x00000001 |
20 | #define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ | 90 | #define PT_DTRACE 0x00000002 /* delayed trace (used on m68k, i386) */ |
21 | #define PT_PTRACE_CAP 0x00000004 /* ptracer can follow suid-exec */ | 91 | #define PT_TRACESYSGOOD 0x00000004 |
92 | #define PT_PTRACE_CAP 0x00000008 /* ptracer can follow suid-exec */ | ||
22 | 93 | ||
23 | #define PT_OPT_FLAG_SHIFT 3 | ||
24 | /* PT_TRACE_* event enable flags */ | 94 | /* PT_TRACE_* event enable flags */ |
25 | #define PT_EVENT_FLAG(event) (1 << (PT_OPT_FLAG_SHIFT + (event))) | 95 | #define PT_EVENT_FLAG_SHIFT 4 |
26 | #define PT_TRACESYSGOOD PT_EVENT_FLAG(0) | 96 | #define PT_EVENT_FLAG(event) (1 << (PT_EVENT_FLAG_SHIFT + (event) - 1)) |
97 | |||
27 | #define PT_TRACE_FORK PT_EVENT_FLAG(PTRACE_EVENT_FORK) | 98 | #define PT_TRACE_FORK PT_EVENT_FLAG(PTRACE_EVENT_FORK) |
28 | #define PT_TRACE_VFORK PT_EVENT_FLAG(PTRACE_EVENT_VFORK) | 99 | #define PT_TRACE_VFORK PT_EVENT_FLAG(PTRACE_EVENT_VFORK) |
29 | #define PT_TRACE_CLONE PT_EVENT_FLAG(PTRACE_EVENT_CLONE) | 100 | #define PT_TRACE_CLONE PT_EVENT_FLAG(PTRACE_EVENT_CLONE) |
30 | #define PT_TRACE_EXEC PT_EVENT_FLAG(PTRACE_EVENT_EXEC) | 101 | #define PT_TRACE_EXEC PT_EVENT_FLAG(PTRACE_EVENT_EXEC) |
31 | #define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE) | 102 | #define PT_TRACE_VFORK_DONE PT_EVENT_FLAG(PTRACE_EVENT_VFORK_DONE) |
32 | #define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) | 103 | #define PT_TRACE_EXIT PT_EVENT_FLAG(PTRACE_EVENT_EXIT) |
33 | #define PT_TRACE_SECCOMP PT_EVENT_FLAG(PTRACE_EVENT_SECCOMP) | ||
34 | 104 | ||
35 | #define PT_EXITKILL (PTRACE_O_EXITKILL << PT_OPT_FLAG_SHIFT) | 105 | #define PT_TRACE_MASK 0x000003f4 |
36 | 106 | ||
37 | /* single stepping state bits (used on ARM and PA-RISC) */ | 107 | /* single stepping state bits (used on ARM and PA-RISC) */ |
38 | #define PT_SINGLESTEP_BIT 31 | 108 | #define PT_SINGLESTEP_BIT 31 |
@@ -40,6 +110,10 @@ | |||
40 | #define PT_BLOCKSTEP_BIT 30 | 110 | #define PT_BLOCKSTEP_BIT 30 |
41 | #define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT) | 111 | #define PT_BLOCKSTEP (1<<PT_BLOCKSTEP_BIT) |
42 | 112 | ||
113 | #include <linux/compiler.h> /* For unlikely. */ | ||
114 | #include <linux/sched.h> /* For struct task_struct. */ | ||
115 | |||
116 | |||
43 | extern long arch_ptrace(struct task_struct *child, long request, | 117 | extern long arch_ptrace(struct task_struct *child, long request, |
44 | unsigned long addr, unsigned long data); | 118 | unsigned long addr, unsigned long data); |
45 | extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len); | 119 | extern int ptrace_readdata(struct task_struct *tsk, unsigned long src, char __user *dst, int len); |
@@ -53,9 +127,10 @@ extern void __ptrace_link(struct task_struct *child, | |||
53 | struct task_struct *new_parent); | 127 | struct task_struct *new_parent); |
54 | extern void __ptrace_unlink(struct task_struct *child); | 128 | extern void __ptrace_unlink(struct task_struct *child); |
55 | extern void exit_ptrace(struct task_struct *tracer); | 129 | extern void exit_ptrace(struct task_struct *tracer); |
56 | #define PTRACE_MODE_READ 0x01 | 130 | #define PTRACE_MODE_READ 1 |
57 | #define PTRACE_MODE_ATTACH 0x02 | 131 | #define PTRACE_MODE_ATTACH 2 |
58 | #define PTRACE_MODE_NOAUDIT 0x04 | 132 | /* Returns 0 on success, -errno on denial. */ |
133 | extern int __ptrace_may_access(struct task_struct *task, unsigned int mode); | ||
59 | /* Returns true on success, false on denial. */ | 134 | /* Returns true on success, false on denial. */ |
60 | extern bool ptrace_may_access(struct task_struct *task, unsigned int mode); | 135 | extern bool ptrace_may_access(struct task_struct *task, unsigned int mode); |
61 | 136 | ||
@@ -122,10 +197,9 @@ static inline void ptrace_event(int event, unsigned long message) | |||
122 | if (unlikely(ptrace_event_enabled(current, event))) { | 197 | if (unlikely(ptrace_event_enabled(current, event))) { |
123 | current->ptrace_message = message; | 198 | current->ptrace_message = message; |
124 | ptrace_notify((event << 8) | SIGTRAP); | 199 | ptrace_notify((event << 8) | SIGTRAP); |
125 | } else if (event == PTRACE_EVENT_EXEC) { | 200 | } else if (event == PTRACE_EVENT_EXEC && unlikely(current->ptrace)) { |
126 | /* legacy EXEC report via SIGTRAP */ | 201 | /* legacy EXEC report via SIGTRAP */ |
127 | if ((current->ptrace & (PT_PTRACED|PT_SEIZED)) == PT_PTRACED) | 202 | send_sig(SIGTRAP, current, 0); |
128 | send_sig(SIGTRAP, current, 0); | ||
129 | } | 203 | } |
130 | } | 204 | } |
131 | 205 | ||
@@ -191,15 +265,6 @@ static inline void ptrace_release_task(struct task_struct *task) | |||
191 | #define force_successful_syscall_return() do { } while (0) | 265 | #define force_successful_syscall_return() do { } while (0) |
192 | #endif | 266 | #endif |
193 | 267 | ||
194 | #ifndef is_syscall_success | ||
195 | /* | ||
196 | * On most systems we can tell if a syscall is a success based on if the retval | ||
197 | * is an error value. On some systems like ia64 and powerpc they have different | ||
198 | * indicators of success/failure and must define their own. | ||
199 | */ | ||
200 | #define is_syscall_success(regs) (!IS_ERR_VALUE((unsigned long)(regs_return_value(regs)))) | ||
201 | #endif | ||
202 | |||
203 | /* | 268 | /* |
204 | * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__. | 269 | * <asm/ptrace.h> should define the following things inside #ifdef __KERNEL__. |
205 | * | 270 | * |
@@ -327,27 +392,6 @@ static inline void user_single_step_siginfo(struct task_struct *tsk, | |||
327 | #define arch_ptrace_stop(code, info) do { } while (0) | 392 | #define arch_ptrace_stop(code, info) do { } while (0) |
328 | #endif | 393 | #endif |
329 | 394 | ||
330 | #ifndef current_pt_regs | ||
331 | #define current_pt_regs() task_pt_regs(current) | ||
332 | #endif | ||
333 | |||
334 | #ifndef ptrace_signal_deliver | ||
335 | #define ptrace_signal_deliver() ((void)0) | ||
336 | #endif | ||
337 | |||
338 | /* | ||
339 | * unlike current_pt_regs(), this one is equal to task_pt_regs(current) | ||
340 | * on *all* architectures; the only reason to have a per-arch definition | ||
341 | * is optimisation. | ||
342 | */ | ||
343 | #ifndef signal_pt_regs | ||
344 | #define signal_pt_regs() task_pt_regs(current) | ||
345 | #endif | ||
346 | |||
347 | #ifndef current_user_stack_pointer | ||
348 | #define current_user_stack_pointer() user_stack_pointer(current_pt_regs()) | ||
349 | #endif | ||
350 | |||
351 | extern int task_current_syscall(struct task_struct *target, long *callno, | 395 | extern int task_current_syscall(struct task_struct *target, long *callno, |
352 | unsigned long args[6], unsigned int maxargs, | 396 | unsigned long args[6], unsigned int maxargs, |
353 | unsigned long *sp, unsigned long *pc); | 397 | unsigned long *sp, unsigned long *pc); |
@@ -359,4 +403,6 @@ extern void ptrace_put_breakpoints(struct task_struct *tsk); | |||
359 | static inline void ptrace_put_breakpoints(struct task_struct *tsk) { } | 403 | static inline void ptrace_put_breakpoints(struct task_struct *tsk) { } |
360 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ | 404 | #endif /* CONFIG_HAVE_HW_BREAKPOINT */ |
361 | 405 | ||
406 | #endif /* __KERNEL */ | ||
407 | |||
362 | #endif | 408 | #endif |