123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205 |
- #include <stddef.h>
- #include <linux/kernel.h>
- #include <linux/sched.h>
- #include <linux/string.h>
- #include <linux/mm.h>
- #include <linux/errno.h>
- #include <linux/ptrace.h>
- #include <linux/audit.h>
- #include <linux/regset.h>
- #include <linux/tracehook.h>
- #include <linux/elf.h>
- #include <asm/thread_info.h>
- #include <asm/segment.h>
- #include <asm/page.h>
- #include <asm/pgtable.h>
- static int genregs_get(struct task_struct *target,
- const struct user_regset *regset,
- unsigned int pos, unsigned int count,
- void *kbuf, void __user * ubuf)
- {
- const struct pt_regs *regs = task_pt_regs(target);
- int ret;
-
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, 0, 4);
- if (!ret)
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
- regs->gpr+1, 4, 4*32);
- if (!ret)
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
- ®s->pc, 4*32, 4*33);
- if (!ret)
- ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf,
- ®s->sr, 4*33, 4*34);
- if (!ret)
- ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf,
- 4*34, -1);
- return ret;
- }
- static int genregs_set(struct task_struct *target,
- const struct user_regset *regset,
- unsigned int pos, unsigned int count,
- const void *kbuf, const void __user * ubuf)
- {
- struct pt_regs *regs = task_pt_regs(target);
- int ret;
-
- ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, 0, 4);
-
- if (!ret)
- ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
- regs->gpr+1, 4, 4*32);
-
- if (!ret)
- ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf,
- ®s->pc, 4*32, 4*33);
-
- if (!ret)
- ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf,
- 4*33, -1);
- return ret;
- }
- enum or1k_regset {
- REGSET_GENERAL,
- };
- static const struct user_regset or1k_regsets[] = {
- [REGSET_GENERAL] = {
- .core_note_type = NT_PRSTATUS,
- .n = ELF_NGREG,
- .size = sizeof(long),
- .align = sizeof(long),
- .get = genregs_get,
- .set = genregs_set,
- },
- };
- static const struct user_regset_view user_or1k_native_view = {
- .name = "or1k",
- .e_machine = EM_OPENRISC,
- .regsets = or1k_regsets,
- .n = ARRAY_SIZE(or1k_regsets),
- };
- const struct user_regset_view *task_user_regset_view(struct task_struct *task)
- {
- return &user_or1k_native_view;
- }
- void ptrace_disable(struct task_struct *child)
- {
- pr_debug("ptrace_disable(): TODO\n");
- user_disable_single_step(child);
- clear_tsk_thread_flag(child, TIF_SYSCALL_TRACE);
- }
- long arch_ptrace(struct task_struct *child, long request, unsigned long addr,
- unsigned long data)
- {
- int ret;
- switch (request) {
- default:
- ret = ptrace_request(child, request, addr, data);
- break;
- }
- return ret;
- }
- asmlinkage long do_syscall_trace_enter(struct pt_regs *regs)
- {
- long ret = 0;
- if (test_thread_flag(TIF_SYSCALL_TRACE) &&
- tracehook_report_syscall_entry(regs))
-
- ret = -1L;
- audit_syscall_entry(regs->gpr[11], regs->gpr[3], regs->gpr[4],
- regs->gpr[5], regs->gpr[6]);
- return ret ? : regs->gpr[11];
- }
- asmlinkage void do_syscall_trace_leave(struct pt_regs *regs)
- {
- int step;
- audit_syscall_exit(regs);
- step = test_thread_flag(TIF_SINGLESTEP);
- if (step || test_thread_flag(TIF_SYSCALL_TRACE))
- tracehook_report_syscall_exit(regs, step);
- }
|