^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) * linux/arch/m68k/kernel/ptrace.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Copyright (C) 1994 by Hamish Macdonald
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Taken from linux/kernel/ptrace.c and modified for M680x0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) * linux/kernel/ptrace.c is by Ross Biro 1/23/92, edited by Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) * This file is subject to the terms and conditions of the GNU General
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) * Public License. See the file COPYING in the main directory of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) * this archive for more details.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include <linux/kernel.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include <linux/smp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include <linux/errno.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include <linux/user.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include <linux/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #include <asm/page.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) #include <asm/processor.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) * does not yet catch signals sent when the child dies.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) * in exit.c or in signal.c.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) /* determines which bits in the SR the user has access to. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) /* 1 = access 0 = no access */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #define SR_MASK 0x001f
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) /* sets the trace bits. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) #define TRACE_BITS 0xC000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define T1_BIT 0x8000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) #define T0_BIT 0x4000
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) /* Find the stack offset for a register, relative to thread.esp0. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #define PT_REG(reg) ((long)&((struct pt_regs *)0)->reg)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #define SW_REG(reg) ((long)&((struct switch_stack *)0)->reg \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) - sizeof(struct switch_stack))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) /* Mapping from PT_xxx to the stack offset at which the register is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) saved. Notice that usp has no stack-slot and needs to be treated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) specially (see get_reg/put_reg below). */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) static const int regoff[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) [0] = PT_REG(d1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) [1] = PT_REG(d2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) [2] = PT_REG(d3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) [3] = PT_REG(d4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) [4] = PT_REG(d5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) [5] = SW_REG(d6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) [6] = SW_REG(d7),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) [7] = PT_REG(a0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) [8] = PT_REG(a1),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) [9] = PT_REG(a2),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) [10] = SW_REG(a3),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) [11] = SW_REG(a4),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) [12] = SW_REG(a5),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) [13] = SW_REG(a6),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) [14] = PT_REG(d0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) [15] = -1,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) [16] = PT_REG(orig_d0),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) [17] = PT_REG(sr),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) [18] = PT_REG(pc),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) * Get contents of register REGNO in task TASK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) static inline long get_reg(struct task_struct *task, int regno)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) unsigned long *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) if (regno == PT_USP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) addr = &task->thread.usp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) else if (regno < ARRAY_SIZE(regoff))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) /* Need to take stkadj into account. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) if (regno == PT_SR || regno == PT_PC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) long stkadj = *(long *)(task->thread.esp0 + PT_REG(stkadj));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) addr = (unsigned long *) ((unsigned long)addr + stkadj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) /* The sr is actually a 16 bit register. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (regno == PT_SR)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return *(unsigned short *)addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) * Write contents of register REGNO in task TASK.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) static inline int put_reg(struct task_struct *task, int regno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) unsigned long *addr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) if (regno == PT_USP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) addr = &task->thread.usp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) else if (regno < ARRAY_SIZE(regoff))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) addr = (unsigned long *)(task->thread.esp0 + regoff[regno]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) return -1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) /* Need to take stkadj into account. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) if (regno == PT_SR || regno == PT_PC) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) long stkadj = *(long *)(task->thread.esp0 + PT_REG(stkadj));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) addr = (unsigned long *) ((unsigned long)addr + stkadj);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /* The sr is actually a 16 bit register. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) if (regno == PT_SR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) *(unsigned short *)addr = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) *addr = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) * Make sure the single step bit is not set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static inline void singlestep_disable(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) unsigned long tmp = get_reg(child, PT_SR) & ~TRACE_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) put_reg(child, PT_SR, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) clear_tsk_thread_flag(child, TIF_DELAYED_TRACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) * Called by kernel/ptrace.c when detaching..
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) void ptrace_disable(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) singlestep_disable(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) void user_enable_single_step(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) unsigned long tmp = get_reg(child, PT_SR) & ~TRACE_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) put_reg(child, PT_SR, tmp | T1_BIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) set_tsk_thread_flag(child, TIF_DELAYED_TRACE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) #ifdef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) void user_enable_block_step(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) unsigned long tmp = get_reg(child, PT_SR) & ~TRACE_BITS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) put_reg(child, PT_SR, tmp | T0_BIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) void user_disable_single_step(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) singlestep_disable(child);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) long arch_ptrace(struct task_struct *child, long request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) unsigned long addr, unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) unsigned long tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) int i, ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) int regno = addr >> 2; /* temporary hack. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) unsigned long __user *datap = (unsigned long __user *) data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) switch (request) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) /* read the word at location addr in the USER area. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) case PTRACE_PEEKUSR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) if (addr & 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) if (regno >= 0 && regno < 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) tmp = get_reg(child, regno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) } else if (regno >= 21 && regno < 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) tmp = child->thread.fp[regno - 21];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Convert internal fpu reg representation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) * into long double format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) if (FPU_IS_EMU && (regno < 45) && !(regno % 3))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) tmp = ((tmp & 0xffff0000) << 15) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) ((tmp & 0x0000ffff) << 16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) #ifndef CONFIG_MMU
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) } else if (regno == 49) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) tmp = child->mm->start_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) } else if (regno == 50) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) tmp = child->mm->start_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) } else if (regno == 51) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) tmp = child->mm->end_code;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) ret = put_user(tmp, datap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) case PTRACE_POKEUSR:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) /* write the word at location addr in the USER area */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (addr & 3)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (regno == PT_SR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) data &= SR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) data |= get_reg(child, PT_SR) & ~SR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) if (regno >= 0 && regno < 19) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) if (put_reg(child, regno, data))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) } else if (regno >= 21 && regno < 48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) /* Convert long double format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) * into internal fpu reg representation
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) if (FPU_IS_EMU && (regno < 45) && !(regno % 3)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) data <<= 15;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) data = (data & 0xffff0000) |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) ((data & 0x0000ffff) >> 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) child->thread.fp[regno - 21] = data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) } else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) goto out_eio;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) case PTRACE_GETREGS: /* Get all gp regs from the child. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) for (i = 0; i < 19; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) tmp = get_reg(child, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) ret = put_user(tmp, datap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) datap++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) case PTRACE_SETREGS: /* Set all gp regs in the child. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) for (i = 0; i < 19; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) ret = get_user(tmp, datap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) if (i == PT_SR) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) tmp &= SR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) tmp |= get_reg(child, PT_SR) & ~SR_MASK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) put_reg(child, i, tmp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) datap++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) case PTRACE_GETFPREGS: /* Get the child FPU state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) if (copy_to_user(datap, &child->thread.fp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) sizeof(struct user_m68kfp_struct)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) case PTRACE_SETFPREGS: /* Set the child FPU state. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) if (copy_from_user(&child->thread.fp, datap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) sizeof(struct user_m68kfp_struct)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) ret = -EFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) case PTRACE_GET_THREAD_AREA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) ret = put_user(task_thread_info(child)->tp_value, datap);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) ret = ptrace_request(child, request, addr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) out_eio:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) asmlinkage void syscall_trace(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) ptrace_notify(SIGTRAP | ((current->ptrace & PT_TRACESYSGOOD)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) ? 0x80 : 0));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) * this isn't the same as continuing with a signal, but it will do
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) * for normal use. strace only continues with a signal if the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) * stopping signal is not SIGTRAP. -brl
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) if (current->exit_code) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) send_sig(current->exit_code, current, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) current->exit_code = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) #if defined(CONFIG_COLDFIRE) || !defined(CONFIG_MMU)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) asmlinkage int syscall_trace_enter(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) if (test_thread_flag(TIF_SYSCALL_TRACE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) ret = tracehook_report_syscall_entry(task_pt_regs(current));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) asmlinkage void syscall_trace_leave(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) if (test_thread_flag(TIF_SYSCALL_TRACE))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) tracehook_report_syscall_exit(task_pt_regs(current), 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) #endif /* CONFIG_COLDFIRE */