mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-12 03:26:26 +00:00
sparc64: switch genregs32_get() to use of get_from_target()
... for fetching the register window from target's stack, rather than open-coding it. Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
b3a9e3b962
commit
030754c995
1 changed files with 16 additions and 43 deletions
|
@ -518,10 +518,10 @@ static int genregs32_get(struct task_struct *target,
|
||||||
void *kbuf, void __user *ubuf)
|
void *kbuf, void __user *ubuf)
|
||||||
{
|
{
|
||||||
const struct pt_regs *regs = task_pt_regs(target);
|
const struct pt_regs *regs = task_pt_regs(target);
|
||||||
compat_ulong_t __user *reg_window;
|
|
||||||
compat_ulong_t *k = kbuf;
|
compat_ulong_t *k = kbuf;
|
||||||
compat_ulong_t __user *u = ubuf;
|
compat_ulong_t __user *u = ubuf;
|
||||||
compat_ulong_t reg;
|
u32 uregs[16];
|
||||||
|
u32 reg;
|
||||||
|
|
||||||
if (target == current)
|
if (target == current)
|
||||||
flushw_user();
|
flushw_user();
|
||||||
|
@ -533,52 +533,25 @@ static int genregs32_get(struct task_struct *target,
|
||||||
for (; count > 0 && pos < 16; count--)
|
for (; count > 0 && pos < 16; count--)
|
||||||
*k++ = regs->u_regs[pos++];
|
*k++ = regs->u_regs[pos++];
|
||||||
|
|
||||||
reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
|
if (count && pos < 32) {
|
||||||
reg_window -= 16;
|
if (get_from_target(target, regs->u_regs[UREG_I6],
|
||||||
if (target == current) {
|
uregs, sizeof(uregs)))
|
||||||
for (; count > 0 && pos < 32; count--) {
|
return -EFAULT;
|
||||||
if (get_user(*k++, ®_window[pos++]))
|
for (; count > 0 && pos < 32; count--)
|
||||||
return -EFAULT;
|
*k++ = uregs[pos++ - 16];
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (; count > 0 && pos < 32; count--) {
|
|
||||||
if (access_process_vm(target,
|
|
||||||
(unsigned long)
|
|
||||||
®_window[pos],
|
|
||||||
k, sizeof(*k),
|
|
||||||
FOLL_FORCE)
|
|
||||||
!= sizeof(*k))
|
|
||||||
return -EFAULT;
|
|
||||||
k++;
|
|
||||||
pos++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
for (; count > 0 && pos < 16; count--) {
|
for (; count > 0 && pos < 16; count--)
|
||||||
if (put_user((compat_ulong_t) regs->u_regs[pos++], u++))
|
if (put_user((compat_ulong_t) regs->u_regs[pos++], u++))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
if (count && pos < 32) {
|
||||||
|
if (get_from_target(target, regs->u_regs[UREG_I6],
|
||||||
reg_window = (compat_ulong_t __user *) regs->u_regs[UREG_I6];
|
uregs, sizeof(uregs)))
|
||||||
reg_window -= 16;
|
return -EFAULT;
|
||||||
if (target == current) {
|
for (; count > 0 && pos < 32; count--)
|
||||||
for (; count > 0 && pos < 32; count--) {
|
if (put_user(uregs[pos++ - 16], u++))
|
||||||
if (get_user(reg, ®_window[pos++]) ||
|
|
||||||
put_user(reg, u++))
|
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (; count > 0 && pos < 32; count--) {
|
|
||||||
if (access_process_vm(target,
|
|
||||||
(unsigned long)
|
|
||||||
®_window[pos++],
|
|
||||||
®, sizeof(reg),
|
|
||||||
FOLL_FORCE)
|
|
||||||
!= sizeof(reg))
|
|
||||||
return -EFAULT;
|
|
||||||
if (put_user(reg, u++))
|
|
||||||
return -EFAULT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while (count > 0) {
|
while (count > 0) {
|
||||||
|
|
Loading…
Reference in a new issue