Skip to content

Commit 7be6828

Browse files
simarkcmetcalf-tilera
authored andcommitted
arch/tile: implement user_regset interface on tile
This is a basic implementation of user_regset for the tile architecture. It reuses the basic blocks that were already there. Signed-off-by: Simon Marchi <simon.marchi@polymtl.ca> Signed-off-by: Chris Metcalf <cmetcalf@tilera.com>
1 parent 395e095 commit 7be6828

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

arch/tile/kernel/ptrace.c

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@
1919
#include <linux/kprobes.h>
2020
#include <linux/compat.h>
2121
#include <linux/uaccess.h>
22+
#include <linux/regset.h>
23+
#include <linux/elf.h>
2224
#include <asm/traps.h>
25+
#include <arch/chip.h>
2326

2427
void user_enable_single_step(struct task_struct *child)
2528
{
@@ -80,6 +83,65 @@ static void putregs(struct task_struct *child, struct pt_regs *uregs)
8083
*regs = *uregs;
8184
}
8285

86+
enum tile_regset {
87+
REGSET_GPR,
88+
};
89+
90+
static int tile_gpr_get(struct task_struct *target,
91+
const struct user_regset *regset,
92+
unsigned int pos, unsigned int count,
93+
void *kbuf, void __user *ubuf)
94+
{
95+
struct pt_regs regs;
96+
97+
getregs(target, &regs);
98+
99+
return user_regset_copyout(&pos, &count, &kbuf, &ubuf, &regs, 0,
100+
sizeof(regs));
101+
}
102+
103+
static int tile_gpr_set(struct task_struct *target,
104+
const struct user_regset *regset,
105+
unsigned int pos, unsigned int count,
106+
const void *kbuf, const void __user *ubuf)
107+
{
108+
int ret;
109+
struct pt_regs regs;
110+
111+
ret = user_regset_copyin(&pos, &count, &kbuf, &ubuf, &regs, 0,
112+
sizeof(regs));
113+
if (ret)
114+
return ret;
115+
116+
putregs(target, &regs);
117+
118+
return 0;
119+
}
120+
121+
static const struct user_regset tile_user_regset[] = {
122+
[REGSET_GPR] = {
123+
.core_note_type = NT_PRSTATUS,
124+
.n = ELF_NGREG,
125+
.size = sizeof(elf_greg_t),
126+
.align = sizeof(elf_greg_t),
127+
.get = tile_gpr_get,
128+
.set = tile_gpr_set,
129+
},
130+
};
131+
132+
static const struct user_regset_view tile_user_regset_view = {
133+
.name = CHIP_ARCH_NAME,
134+
.e_machine = ELF_ARCH,
135+
.ei_osabi = ELF_OSABI,
136+
.regsets = tile_user_regset,
137+
.n = ARRAY_SIZE(tile_user_regset),
138+
};
139+
140+
const struct user_regset_view *task_user_regset_view(struct task_struct *task)
141+
{
142+
return &tile_user_regset_view;
143+
}
144+
83145
long arch_ptrace(struct task_struct *child, long request,
84146
unsigned long addr, unsigned long data)
85147
{

0 commit comments

Comments
 (0)