1
2
3
4
5
6
7
8
9
10#include <linux/ptrace.h>
11#include <linux/tracehook.h>
12#include <linux/regset.h>
13#include <linux/elf.h>
14#include <linux/sched/task_stack.h>
15
16#include <asm/cacheflush.h>
17
18#define PT_REG_SIZE (sizeof(struct pt_regs))
19
20
21
22
23void ptrace_disable(struct task_struct *child)
24{
25
26}
27
28
29
30
31static inline long get_reg(struct task_struct *task, int regno)
32{
33 long *addr = (long *)task_pt_regs(task);
34
35 if (regno == PT_TSR || regno == PT_CSR)
36 return 0;
37
38 return addr[regno];
39}
40
41
42
43
44static inline int put_reg(struct task_struct *task,
45 int regno,
46 unsigned long data)
47{
48 unsigned long *addr = (unsigned long *)task_pt_regs(task);
49
50 if (regno != PT_TSR && regno != PT_CSR)
51 addr[regno] = data;
52
53 return 0;
54}
55
56
57
58static int gpr_get(struct task_struct *target,
59 const struct user_regset *regset,
60 unsigned int pos, unsigned int count,
61 void *kbuf, void __user *ubuf)
62{
63 struct pt_regs *regs = task_pt_regs(target);
64
65 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
66 regs,
67 0, sizeof(*regs));
68}
69
70enum c6x_regset {
71 REGSET_GPR,
72};
73
74static const struct user_regset c6x_regsets[] = {
75 [REGSET_GPR] = {
76 .core_note_type = NT_PRSTATUS,
77 .n = ELF_NGREG,
78 .size = sizeof(u32),
79 .align = sizeof(u32),
80 .get = gpr_get,
81 },
82};
83
84static const struct user_regset_view user_c6x_native_view = {
85 .name = "tic6x",
86 .e_machine = EM_TI_C6000,
87 .regsets = c6x_regsets,
88 .n = ARRAY_SIZE(c6x_regsets),
89};
90
91const struct user_regset_view *task_user_regset_view(struct task_struct *task)
92{
93 return &user_c6x_native_view;
94}
95
96
97
98
99long arch_ptrace(struct task_struct *child, long request,
100 unsigned long addr, unsigned long data)
101{
102 int ret = 0;
103
104 switch (request) {
105
106
107
108 case PTRACE_POKETEXT:
109 ret = generic_ptrace_pokedata(child, addr, data);
110 if (ret == 0 && request == PTRACE_POKETEXT)
111 flush_icache_range(addr, addr + 4);
112 break;
113 default:
114 ret = ptrace_request(child, request, addr, data);
115 break;
116 }
117
118 return ret;
119}
120
121
122
123
124
125asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs)
126{
127 if (tracehook_report_syscall_entry(regs))
128
129
130
131
132
133 return ULONG_MAX;
134
135 return regs->b0;
136}
137
138
139
140
141asmlinkage void syscall_trace_exit(struct pt_regs *regs)
142{
143 tracehook_report_syscall_exit(regs, 0);
144}
145