.. | .. |
---|
| 1 | +// SPDX-License-Identifier: GPL-2.0-only |
---|
1 | 2 | /* |
---|
2 | 3 | * Ptrace support for Hexagon |
---|
3 | 4 | * |
---|
4 | 5 | * Copyright (c) 2010-2013, The Linux Foundation. All rights reserved. |
---|
5 | | - * |
---|
6 | | - * This program is free software; you can redistribute it and/or modify |
---|
7 | | - * it under the terms of the GNU General Public License version 2 and |
---|
8 | | - * only version 2 as published by the Free Software Foundation. |
---|
9 | | - * |
---|
10 | | - * This program is distributed in the hope that it will be useful, |
---|
11 | | - * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
12 | | - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
13 | | - * GNU General Public License for more details. |
---|
14 | | - * |
---|
15 | | - * You should have received a copy of the GNU General Public License |
---|
16 | | - * along with this program; if not, write to the Free Software |
---|
17 | | - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
---|
18 | | - * 02110-1301, USA. |
---|
19 | 6 | */ |
---|
20 | 7 | |
---|
21 | 8 | #include <linux/kernel.h> |
---|
.. | .. |
---|
48 | 35 | |
---|
49 | 36 | static int genregs_get(struct task_struct *target, |
---|
50 | 37 | const struct user_regset *regset, |
---|
51 | | - unsigned int pos, unsigned int count, |
---|
52 | | - void *kbuf, void __user *ubuf) |
---|
| 38 | + struct membuf to) |
---|
53 | 39 | { |
---|
54 | | - int ret; |
---|
55 | | - unsigned int dummy; |
---|
56 | 40 | struct pt_regs *regs = task_pt_regs(target); |
---|
57 | | - |
---|
58 | | - |
---|
59 | | - if (!regs) |
---|
60 | | - return -EIO; |
---|
61 | 41 | |
---|
62 | 42 | /* The general idea here is that the copyout must happen in |
---|
63 | 43 | * exactly the same order in which the userspace expects these |
---|
.. | .. |
---|
65 | 45 | * sequence in the kernel, so everything past the 32 gprs |
---|
66 | 46 | * happens one at a time. |
---|
67 | 47 | */ |
---|
68 | | - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, |
---|
69 | | - ®s->r00, 0, 32*sizeof(unsigned long)); |
---|
70 | | - |
---|
71 | | -#define ONEXT(KPT_REG, USR_REG) \ |
---|
72 | | - if (!ret) \ |
---|
73 | | - ret = user_regset_copyout(&pos, &count, &kbuf, &ubuf, \ |
---|
74 | | - KPT_REG, offsetof(struct user_regs_struct, USR_REG), \ |
---|
75 | | - offsetof(struct user_regs_struct, USR_REG) + \ |
---|
76 | | - sizeof(unsigned long)); |
---|
77 | | - |
---|
| 48 | + membuf_write(&to, ®s->r00, 32*sizeof(unsigned long)); |
---|
78 | 49 | /* Must be exactly same sequence as struct user_regs_struct */ |
---|
79 | | - ONEXT(®s->sa0, sa0); |
---|
80 | | - ONEXT(®s->lc0, lc0); |
---|
81 | | - ONEXT(®s->sa1, sa1); |
---|
82 | | - ONEXT(®s->lc1, lc1); |
---|
83 | | - ONEXT(®s->m0, m0); |
---|
84 | | - ONEXT(®s->m1, m1); |
---|
85 | | - ONEXT(®s->usr, usr); |
---|
86 | | - ONEXT(®s->preds, p3_0); |
---|
87 | | - ONEXT(®s->gp, gp); |
---|
88 | | - ONEXT(®s->ugp, ugp); |
---|
89 | | - ONEXT(&pt_elr(regs), pc); |
---|
90 | | - dummy = pt_cause(regs); |
---|
91 | | - ONEXT(&dummy, cause); |
---|
92 | | - ONEXT(&pt_badva(regs), badva); |
---|
| 50 | + membuf_store(&to, regs->sa0); |
---|
| 51 | + membuf_store(&to, regs->lc0); |
---|
| 52 | + membuf_store(&to, regs->sa1); |
---|
| 53 | + membuf_store(&to, regs->lc1); |
---|
| 54 | + membuf_store(&to, regs->m0); |
---|
| 55 | + membuf_store(&to, regs->m1); |
---|
| 56 | + membuf_store(&to, regs->usr); |
---|
| 57 | + membuf_store(&to, regs->preds); |
---|
| 58 | + membuf_store(&to, regs->gp); |
---|
| 59 | + membuf_store(&to, regs->ugp); |
---|
| 60 | + membuf_store(&to, pt_elr(regs)); // pc |
---|
| 61 | + membuf_store(&to, (unsigned long)pt_cause(regs)); // cause |
---|
| 62 | + membuf_store(&to, pt_badva(regs)); // badva |
---|
93 | 63 | #if CONFIG_HEXAGON_ARCH_VERSION >=4 |
---|
94 | | - ONEXT(®s->cs0, cs0); |
---|
95 | | - ONEXT(®s->cs1, cs1); |
---|
| 64 | + membuf_store(&to, regs->cs0); |
---|
| 65 | + membuf_store(&to, regs->cs1); |
---|
| 66 | + return membuf_zero(&to, sizeof(unsigned long)); |
---|
| 67 | +#else |
---|
| 68 | + return membuf_zero(&to, 3 * sizeof(unsigned long)); |
---|
96 | 69 | #endif |
---|
97 | | - |
---|
98 | | - /* Pad the rest with zeros, if needed */ |
---|
99 | | - if (!ret) |
---|
100 | | - ret = user_regset_copyout_zero(&pos, &count, &kbuf, &ubuf, |
---|
101 | | - offsetof(struct user_regs_struct, pad1), -1); |
---|
102 | | - return ret; |
---|
103 | 70 | } |
---|
104 | 71 | |
---|
105 | 72 | static int genregs_set(struct task_struct *target, |
---|
.. | .. |
---|
172 | 139 | .n = ELF_NGREG, |
---|
173 | 140 | .size = sizeof(unsigned long), |
---|
174 | 141 | .align = sizeof(unsigned long), |
---|
175 | | - .get = genregs_get, |
---|
| 142 | + .regset_get = genregs_get, |
---|
176 | 143 | .set = genregs_set, |
---|
177 | 144 | }, |
---|
178 | 145 | }; |
---|