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