~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/arch/c6x/kernel/ptrace.c

Version: ~ [ linux-5.2-rc1 ] ~ [ linux-5.1.2 ] ~ [ linux-5.0.16 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.43 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.119 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.176 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.179 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.19.8 ] ~ [ linux-3.18.139 ] ~ [ linux-3.17.8 ] ~ [ linux-3.16.67 ] ~ [ linux-3.15.10 ] ~ [ linux-3.14.79 ] ~ [ linux-3.13.11 ] ~ [ linux-3.12.74 ] ~ [ linux-3.11.10 ] ~ [ linux-3.10.108 ] ~ [ linux-3.9.11 ] ~ [ linux-3.8.13 ] ~ [ linux-3.7.10 ] ~ [ linux-3.6.11 ] ~ [ linux-3.5.7 ] ~ [ linux-3.4.113 ] ~ [ linux-3.3.8 ] ~ [ linux-3.2.102 ] ~ [ linux-3.1.10 ] ~ [ linux-3.0.101 ] ~ [ linux-2.6.39.4 ] ~ [ linux-2.6.38.8 ] ~ [ linux-2.6.37.6 ] ~ [ linux-2.6.36.4 ] ~ [ linux-2.6.35.14 ] ~ [ linux-2.6.34.15 ] ~ [ linux-2.6.33.20 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /*
  2  *  Port on Texas Instruments TMS320C6x architecture
  3  *
  4  *  Copyright (C) 2004, 2006, 2009, 2010, 2011 Texas Instruments Incorporated
  5  *  Author: Aurelien Jacquiot (aurelien.jacquiot@jaluna.com)
  6  *
  7  *  Updated for 2.6.34: Mark Salter <msalter@redhat.com>
  8  *
  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.
 12  */
 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>
 18 
 19 #include <asm/cacheflush.h>
 20 
 21 #define PT_REG_SIZE       (sizeof(struct pt_regs))
 22 
 23 /*
 24  * Called by kernel/ptrace.c when detaching.
 25  */
 26 void ptrace_disable(struct task_struct *child)
 27 {
 28         /* nothing to do */
 29 }
 30 
 31 /*
 32  * Get a register number from live pt_regs for the specified task.
 33  */
 34 static inline long get_reg(struct task_struct *task, int regno)
 35 {
 36         long *addr = (long *)task_pt_regs(task);
 37 
 38         if (regno == PT_TSR || regno == PT_CSR)
 39                 return 0;
 40 
 41         return addr[regno];
 42 }
 43 
 44 /*
 45  * Write contents of register REGNO in task TASK.
 46  */
 47 static inline int put_reg(struct task_struct *task,
 48                           int regno,
 49                           unsigned long data)
 50 {
 51         unsigned long *addr = (unsigned long *)task_pt_regs(task);
 52 
 53         if (regno != PT_TSR && regno != PT_CSR)
 54                 addr[regno] = data;
 55 
 56         return 0;
 57 }
 58 
 59 /* regset get/set implementations */
 60 
 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)
 65 {
 66         struct pt_regs *regs = task_pt_regs(target);
 67 
 68         return user_regset_copyout(&pos, &count, &kbuf, &ubuf,
 69                                    regs,
 70                                    0, sizeof(*regs));
 71 }
 72 
 73 enum c6x_regset {
 74         REGSET_GPR,
 75 };
 76 
 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,
 84         },
 85 };
 86 
 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),
 92 };
 93 
 94 const struct user_regset_view *task_user_regset_view(struct task_struct *task)
 95 {
 96         return &user_c6x_native_view;
 97 }
 98 
 99 /*
100  * Perform ptrace request
101  */
102 long arch_ptrace(struct task_struct *child, long request,
103                  unsigned long addr, unsigned long data)
104 {
105         int ret = 0;
106 
107         switch (request) {
108                 /*
109                  * write the word at location addr.
110                  */
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;
119         }
120 
121         return ret;
122 }
123 
124 /*
125  * handle tracing of system call entry
126  * - return the revised system call number or ULONG_MAX to cause ENOSYS
127  */
128 asmlinkage unsigned long syscall_trace_entry(struct pt_regs *regs)
129 {
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
135                  */
136                 return ULONG_MAX;
137 
138         return regs->b0;
139 }
140 
141 /*
142  * handle tracing of system call exit
143  */
144 asmlinkage void syscall_trace_exit(struct pt_regs *regs)
145 {
146         tracehook_report_syscall_exit(regs, 0);
147 }
148 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp