Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
[cris-mirror.git] / arch / c6x / kernel / ptrace.c
blob8801dc98fd442a85cd09113ce6794040ac2e22dd
1 /*
2 * Port on Texas Instruments TMS320C6x architecture
4 * Copyright (C) 2004, 2006, 2009, 2010, 2011 Texas Instruments Incorporated
5 * Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
7 * Updated for 2.6.34: Mark Salter <msalter@redhat.com>
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
13 #include <linux/ptrace.h>
14 #include <linux/tracehook.h>
15 #include <linux/regset.h>
16 #include <linux/elf.h>
17 #include <linux/sched/task_stack.h>
19 #include <asm/cacheflush.h>
21 #define PT_REG_SIZE (sizeof(struct pt_regs))
24 * Called by kernel/ptrace.c when detaching.
26 void ptrace_disable(struct task_struct *child)
28 /* nothing to do */
32 * Get a register number from live pt_regs for the specified task.
34 static inline long get_reg(struct task_struct *task, int regno)
36 long *addr = (long *)task_pt_regs(task);
38 if (regno == PT_TSR || regno == PT_CSR)
39 return 0;
41 return addr[regno];
45 * Write contents of register REGNO in task TASK.
47 static inline int put_reg(struct task_struct *task,
48 int regno,
49 unsigned long data)
51 unsigned long *addr = (unsigned long *)task_pt_regs(task);
53 if (regno != PT_TSR && regno != PT_CSR)
54 addr[regno] = data;
56 return 0;
59 /* regset get/set implementations */
61 static int gpr_get(struct task_struct *target,
62 const struct user_regset *regset,
63 unsigned int pos, unsigned int count,
64 void *kbuf, void __user *ubuf)
66 struct pt_regs *regs = task_pt_regs(target);
68 return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
69 regs,
70 0, sizeof(*regs));
73 enum c6x_regset {
74 REGSET_GPR,
77 static const struct user_regset c6x_regsets[] = {
78 [REGSET_GPR] = {
79 .core_note_type = NT_PRSTATUS,
80 .n = ELF_NGREG,
81 .size = sizeof(u32),
82 .align = sizeof(u32),
83 .get = gpr_get,
87 static const struct user_regset_view user_c6x_native_view = {
88 .name = "tic6x",
89 .e_machine = EM_TI_C6000,
90 .regsets = c6x_regsets,
91 .n = ARRAY_SIZE(c6x_regsets),
94 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
96 return &user_c6x_native_view;
100 * Perform ptrace request
102 long arch_ptrace(struct task_struct *child, long request,
103 unsigned long addr, unsigned long data)
105 int ret = 0;
107 switch (request) {
109 * write the word at location addr.
111 case PTRACE_POKETEXT:
112 ret = generic_ptrace_pokedata(child, addr, data);
113 if (ret == 0 && request == PTRACE_POKETEXT)
114 flush_icache_range(addr, addr + 4);
115 break;
116 default:
117 ret = ptrace_request(child, request, addr, data);
118 break;
121 return ret;
125 * handle tracing of system call entry
126 * - return the revised system call number or ULONG_MAX to cause ENOSYS
128 asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs)
130 if (tracehook_report_syscall_entry(regs))
131 /* tracing decided this syscall should not happen, so
132 * We'll return a bogus call number to get an ENOSYS
133 * error, but leave the original number in
134 * regs->orig_a4
136 return ULONG_MAX;
138 return regs->b0;
142 * handle tracing of system call exit
144 asmlinkage void syscall_trace_exit(struct pt_regs *regs)
146 tracehook_report_syscall_exit(regs, 0);