^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2004, 2007-2010, 2011-2012 Synopsys, Inc. (www.synopsys.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include <linux/tracehook.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include <linux/sched/task_stack.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include <linux/regset.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include <linux/unistd.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include <linux/elf.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) static struct callee_regs *task_callee_regs(struct task_struct *tsk)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) struct callee_regs *tmp = (struct callee_regs *)tsk->thread.callee_reg;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) return tmp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) static int genregs_get(struct task_struct *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) struct membuf to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) const struct pt_regs *ptregs = task_pt_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) const struct callee_regs *cregs = task_callee_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) unsigned int stop_pc_val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) membuf_zero(&to, 4); // pad
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) membuf_store(&to, ptregs->bta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) membuf_store(&to, ptregs->lp_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) membuf_store(&to, ptregs->lp_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) membuf_store(&to, ptregs->lp_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) membuf_store(&to, ptregs->status32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) membuf_store(&to, ptregs->ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) membuf_store(&to, ptregs->blink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) membuf_store(&to, ptregs->fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) membuf_store(&to, ptregs->r26); // gp
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) membuf_store(&to, ptregs->r12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) membuf_store(&to, ptregs->r11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) membuf_store(&to, ptregs->r10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) membuf_store(&to, ptregs->r9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) membuf_store(&to, ptregs->r8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) membuf_store(&to, ptregs->r7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) membuf_store(&to, ptregs->r6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) membuf_store(&to, ptregs->r5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) membuf_store(&to, ptregs->r4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) membuf_store(&to, ptregs->r3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) membuf_store(&to, ptregs->r2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) membuf_store(&to, ptregs->r1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) membuf_store(&to, ptregs->r0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) membuf_store(&to, ptregs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) membuf_zero(&to, 4); // pad2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) membuf_store(&to, cregs->r25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) membuf_store(&to, cregs->r24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) membuf_store(&to, cregs->r23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) membuf_store(&to, cregs->r22);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) membuf_store(&to, cregs->r21);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) membuf_store(&to, cregs->r20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) membuf_store(&to, cregs->r19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) membuf_store(&to, cregs->r18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) membuf_store(&to, cregs->r17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) membuf_store(&to, cregs->r16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) membuf_store(&to, cregs->r15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) membuf_store(&to, cregs->r14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) membuf_store(&to, cregs->r13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) membuf_store(&to, target->thread.fault_address); // efa
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) if (in_brkpt_trap(ptregs)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) stop_pc_val = target->thread.fault_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) pr_debug("\t\tstop_pc (brk-pt)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) stop_pc_val = ptregs->ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) pr_debug("\t\tstop_pc (others)\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) return membuf_store(&to, stop_pc_val); // stop_pc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) static int genregs_set(struct task_struct *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) unsigned int pos, unsigned int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) const void *kbuf, const void __user *ubuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) const struct pt_regs *ptregs = task_pt_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) const struct callee_regs *cregs = task_callee_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) #define REG_IN_CHUNK(FIRST, NEXT, PTR) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (!ret) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) (void *)(PTR), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) offsetof(struct user_regs_struct, FIRST), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) offsetof(struct user_regs_struct, NEXT));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) #define REG_IN_ONE(LOC, PTR) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) if (!ret) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) (void *)(PTR), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) offsetof(struct user_regs_struct, LOC), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) offsetof(struct user_regs_struct, LOC) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) #define REG_IGNORE_ONE(LOC) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) if (!ret) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) ret = user_regset_copyin_ignore(&pos, &count, &kbuf, &ubuf, \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) offsetof(struct user_regs_struct, LOC), \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) offsetof(struct user_regs_struct, LOC) + 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) REG_IGNORE_ONE(pad);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) REG_IN_ONE(scratch.bta, &ptregs->bta);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) REG_IN_ONE(scratch.lp_start, &ptregs->lp_start);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) REG_IN_ONE(scratch.lp_end, &ptregs->lp_end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) REG_IN_ONE(scratch.lp_count, &ptregs->lp_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) REG_IGNORE_ONE(scratch.status32);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) REG_IN_ONE(scratch.ret, &ptregs->ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) REG_IN_ONE(scratch.blink, &ptregs->blink);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) REG_IN_ONE(scratch.fp, &ptregs->fp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) REG_IN_ONE(scratch.gp, &ptregs->r26);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) REG_IN_ONE(scratch.r12, &ptregs->r12);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) REG_IN_ONE(scratch.r11, &ptregs->r11);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) REG_IN_ONE(scratch.r10, &ptregs->r10);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) REG_IN_ONE(scratch.r9, &ptregs->r9);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) REG_IN_ONE(scratch.r8, &ptregs->r8);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) REG_IN_ONE(scratch.r7, &ptregs->r7);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) REG_IN_ONE(scratch.r6, &ptregs->r6);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) REG_IN_ONE(scratch.r5, &ptregs->r5);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) REG_IN_ONE(scratch.r4, &ptregs->r4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) REG_IN_ONE(scratch.r3, &ptregs->r3);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) REG_IN_ONE(scratch.r2, &ptregs->r2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) REG_IN_ONE(scratch.r1, &ptregs->r1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) REG_IN_ONE(scratch.r0, &ptregs->r0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) REG_IN_ONE(scratch.sp, &ptregs->sp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) REG_IGNORE_ONE(pad2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) REG_IN_ONE(callee.r25, &cregs->r25);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) REG_IN_ONE(callee.r24, &cregs->r24);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) REG_IN_ONE(callee.r23, &cregs->r23);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) REG_IN_ONE(callee.r22, &cregs->r22);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) REG_IN_ONE(callee.r21, &cregs->r21);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) REG_IN_ONE(callee.r20, &cregs->r20);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) REG_IN_ONE(callee.r19, &cregs->r19);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) REG_IN_ONE(callee.r18, &cregs->r18);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) REG_IN_ONE(callee.r17, &cregs->r17);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) REG_IN_ONE(callee.r16, &cregs->r16);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) REG_IN_ONE(callee.r15, &cregs->r15);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) REG_IN_ONE(callee.r14, &cregs->r14);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) REG_IN_ONE(callee.r13, &cregs->r13);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) REG_IGNORE_ONE(efa); /* efa update invalid */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) REG_IGNORE_ONE(stop_pc); /* PC updated via @ret */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) #ifdef CONFIG_ISA_ARCV2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) static int arcv2regs_get(struct task_struct *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) struct membuf to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) const struct pt_regs *regs = task_pt_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) if (IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) * itemized copy not needed like above as layout of regs (r30,r58,r59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) * is exactly same in kernel (pt_regs) and userspace (user_regs_arcv2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) return membuf_write(&to, ®s->r30, sizeof(struct user_regs_arcv2));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) membuf_write(&to, ®s->r30, 4); /* r30 only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) return membuf_zero(&to, sizeof(struct user_regs_arcv2) - 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) static int arcv2regs_set(struct task_struct *target,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) const struct user_regset *regset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) unsigned int pos, unsigned int count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) const void *kbuf, const void __user *ubuf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) const struct pt_regs *regs = task_pt_regs(target);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) int ret, copy_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) if (IS_ENABLED(CONFIG_ARC_HAS_ACCL_REGS))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) copy_sz = sizeof(struct user_regs_arcv2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) copy_sz = 4; /* r30 only */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, (void *)®s->r30,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 0, copy_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) enum arc_getset {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) REGSET_CMN,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) REGSET_ARCV2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) static const struct user_regset arc_regsets[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) [REGSET_CMN] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) .core_note_type = NT_PRSTATUS,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) .n = ELF_NGREG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) .size = sizeof(unsigned long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) .align = sizeof(unsigned long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) .regset_get = genregs_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) .set = genregs_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) #ifdef CONFIG_ISA_ARCV2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) [REGSET_ARCV2] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) .core_note_type = NT_ARC_V2,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) .n = ELF_ARCV2REG,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) .size = sizeof(unsigned long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) .align = sizeof(unsigned long),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) .regset_get = arcv2regs_get,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) .set = arcv2regs_set,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) static const struct user_regset_view user_arc_view = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) .name = "arc",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) .e_machine = EM_ARC_INUSE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) .regsets = arc_regsets,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) .n = ARRAY_SIZE(arc_regsets)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) const struct user_regset_view *task_user_regset_view(struct task_struct *task)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) return &user_arc_view;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) void ptrace_disable(struct task_struct *child)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) long arch_ptrace(struct task_struct *child, long request,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) unsigned long addr, unsigned long data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) int ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) pr_debug("REQ=%ld: ADDR =0x%lx, DATA=0x%lx)\n", request, addr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) switch (request) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) case PTRACE_GET_THREAD_AREA:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) ret = put_user(task_thread_info(child)->thr_ptr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) (unsigned long __user *)data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) ret = ptrace_request(child, request, addr, data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) asmlinkage int syscall_trace_entry(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) if (tracehook_report_syscall_entry(regs))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) return ULONG_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) return regs->r8;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) asmlinkage void syscall_trace_exit(struct pt_regs *regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) tracehook_report_syscall_exit(regs, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) }