Skip to content

Commit a96dacf

Browse files
author
Al Viro
committed
arm64: take fetching compat reg out of pt_regs into a new helper
Signed-off-by: Al Viro <[email protected]>
1 parent b3a9e3b commit a96dacf

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

arch/arm64/kernel/ptrace.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,6 +1237,22 @@ enum compat_regset {
12371237
REGSET_COMPAT_VFP,
12381238
};
12391239

1240+
static inline compat_ulong_t compat_get_user_reg(struct task_struct *task, int idx)
1241+
{
1242+
struct pt_regs *regs = task_pt_regs(task);
1243+
1244+
switch (idx) {
1245+
case 15:
1246+
return regs->pc;
1247+
case 16:
1248+
return pstate_to_compat_psr(regs->pstate);
1249+
case 17:
1250+
return regs->orig_x0;
1251+
default:
1252+
return regs->regs[idx];
1253+
}
1254+
}
1255+
12401256
static int compat_gpr_get(struct task_struct *target,
12411257
const struct user_regset *regset,
12421258
unsigned int pos, unsigned int count,
@@ -1255,23 +1271,7 @@ static int compat_gpr_get(struct task_struct *target,
12551271
return -EIO;
12561272

12571273
for (i = 0; i < num_regs; ++i) {
1258-
unsigned int idx = start + i;
1259-
compat_ulong_t reg;
1260-
1261-
switch (idx) {
1262-
case 15:
1263-
reg = task_pt_regs(target)->pc;
1264-
break;
1265-
case 16:
1266-
reg = task_pt_regs(target)->pstate;
1267-
reg = pstate_to_compat_psr(reg);
1268-
break;
1269-
case 17:
1270-
reg = task_pt_regs(target)->orig_x0;
1271-
break;
1272-
default:
1273-
reg = task_pt_regs(target)->regs[idx];
1274-
}
1274+
compat_ulong_t reg = compat_get_user_reg(target, start + i);
12751275

12761276
if (kbuf) {
12771277
memcpy(kbuf, &reg, sizeof(reg));

0 commit comments

Comments
 (0)