This source file includes following definitions.
- reg_save_addr
- arch_ptrace
- do_syscall_trace_enter
- do_syscall_trace_leave
- ptrace_disable
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 #include <linux/kernel.h>
28 #include <linux/mm.h>
29 #include <linux/sched.h>
30 #include <linux/sched/task_stack.h>
31 #include <linux/ptrace.h>
32 #include <linux/signal.h>
33 #include <linux/elf.h>
34 #include <linux/audit.h>
35 #include <linux/seccomp.h>
36 #include <linux/tracehook.h>
37
38 #include <linux/errno.h>
39 #include <asm/processor.h>
40 #include <linux/uaccess.h>
41 #include <asm/asm-offsets.h>
42 #include <asm/cacheflush.h>
43 #include <asm/syscall.h>
44 #include <linux/io.h>
45
46
47 static microblaze_reg_t *reg_save_addr(unsigned reg_offs,
48 struct task_struct *t)
49 {
50 struct pt_regs *regs;
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73 regs = task_pt_regs(t);
74
75 return (microblaze_reg_t *)((char *)regs + reg_offs);
76 }
77
78 long arch_ptrace(struct task_struct *child, long request,
79 unsigned long addr, unsigned long data)
80 {
81 int rval;
82 unsigned long val = 0;
83
84 switch (request) {
85
86 case PTRACE_PEEKUSR:
87 case PTRACE_POKEUSR:
88 pr_debug("PEEKUSR/POKEUSR : 0x%08lx\n", addr);
89 rval = 0;
90 if (addr >= PT_SIZE && request == PTRACE_PEEKUSR) {
91
92
93
94
95 if (addr == PT_TEXT_ADDR) {
96 val = child->mm->start_code;
97 } else if (addr == PT_DATA_ADDR) {
98 val = child->mm->start_data;
99 } else if (addr == PT_TEXT_LEN) {
100 val = child->mm->end_code
101 - child->mm->start_code;
102 } else {
103 rval = -EIO;
104 }
105 } else if (addr < PT_SIZE && (addr & 0x3) == 0) {
106 microblaze_reg_t *reg_addr = reg_save_addr(addr, child);
107 if (request == PTRACE_PEEKUSR)
108 val = *reg_addr;
109 else {
110 #if 1
111 *reg_addr = data;
112 #else
113
114
115
116
117
118 u32 paddr = virt_to_phys((u32)reg_addr);
119 invalidate_icache_range(paddr, paddr + 4);
120 *reg_addr = data;
121 flush_dcache_range(paddr, paddr + 4);
122 #endif
123 }
124 } else
125 rval = -EIO;
126
127 if (rval == 0 && request == PTRACE_PEEKUSR)
128 rval = put_user(val, (unsigned long __user *)data);
129 break;
130 default:
131 rval = ptrace_request(child, request, addr, data);
132 }
133 return rval;
134 }
135
136 asmlinkage unsigned long do_syscall_trace_enter(struct pt_regs *regs)
137 {
138 unsigned long ret = 0;
139
140 secure_computing_strict(regs->r12);
141
142 if (test_thread_flag(TIF_SYSCALL_TRACE) &&
143 tracehook_report_syscall_entry(regs))
144
145
146
147
148
149 ret = -1L;
150
151 audit_syscall_entry(regs->r12, regs->r5, regs->r6, regs->r7, regs->r8);
152
153 return ret ?: regs->r12;
154 }
155
156 asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
157 {
158 int step;
159
160 audit_syscall_exit(regs);
161
162 step = test_thread_flag(TIF_SINGLESTEP);
163 if (step || test_thread_flag(TIF_SYSCALL_TRACE))
164 tracehook_report_syscall_exit(regs, step);
165 }
166
167 void ptrace_disable(struct task_struct *child)
168 {
169
170 }