mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
uml: ptrace floating point fixes
Handle floating point state better in ptrace. The code now correctly distinguishes between PTRACE_[GS]ETFPREGS and PTRACE_[GS]ETFPXREGS. The FPX requests get handed off to arch-specific code because that's not generic. get_fpregs, set_fpregs, set_fpregs, and set_fpxregs needed real implementations. Something here exposed a missing include in asm/page.h, which needed linux/types.h in order to get gfp_t, so that's fixed here. Signed-off-by: Jeff Dike <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
a5f6096c80
commit
e8012b584f
6 changed files with 107 additions and 55 deletions
|
|
@ -143,22 +143,14 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
|
|||
#endif
|
||||
#ifdef PTRACE_GETFPREGS
|
||||
case PTRACE_GETFPREGS: /* Get the child FPU state. */
|
||||
ret = get_fpregs(data, child);
|
||||
ret = get_fpregs((struct user_i387_struct __user *) data,
|
||||
child);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PTRACE_SETFPREGS
|
||||
case PTRACE_SETFPREGS: /* Set the child FPU state. */
|
||||
ret = set_fpregs(data, child);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PTRACE_GETFPXREGS
|
||||
case PTRACE_GETFPXREGS: /* Get the child FPU state. */
|
||||
ret = get_fpxregs(data, child);
|
||||
break;
|
||||
#endif
|
||||
#ifdef PTRACE_SETFPXREGS
|
||||
case PTRACE_SETFPXREGS: /* Set the child FPU state. */
|
||||
ret = set_fpxregs(data, child);
|
||||
ret = set_fpregs((struct user_i387_struct __user *) data,
|
||||
child);
|
||||
break;
|
||||
#endif
|
||||
case PTRACE_GET_THREAD_AREA:
|
||||
|
|
@ -227,6 +219,8 @@ long arch_ptrace(struct task_struct *child, long request, long addr, long data)
|
|||
#endif
|
||||
default:
|
||||
ret = ptrace_request(child, request, addr, data);
|
||||
if (ret == -EIO)
|
||||
ret = subarch_ptrace(child, request, addr, data);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#include "linux/mm.h"
|
||||
#include "linux/sched.h"
|
||||
#include "asm/uaccess.h"
|
||||
#include "skas.h"
|
||||
|
||||
extern int arch_switch_tls(struct task_struct *from, struct task_struct *to);
|
||||
|
||||
|
|
@ -144,48 +145,64 @@ int peek_user(struct task_struct *child, long addr, long data)
|
|||
return put_user(tmp, (unsigned long __user *) data);
|
||||
}
|
||||
|
||||
static inline int convert_fxsr_to_user(struct _fpstate __user *buf,
|
||||
struct pt_regs *regs)
|
||||
int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_FP_SIZE];
|
||||
|
||||
static inline int convert_fxsr_from_user(struct pt_regs *regs,
|
||||
struct _fpstate __user *buf)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int get_fpregs(unsigned long buf, struct task_struct *child)
|
||||
{
|
||||
int err;
|
||||
|
||||
err = convert_fxsr_to_user((struct _fpstate __user *) buf,
|
||||
&child->thread.regs);
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
err = save_fp_registers(userspace_pid[cpu], fpregs);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
n = copy_to_user((void *) buf, fpregs, sizeof(fpregs));
|
||||
if(n > 0)
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int set_fpregs(unsigned long buf, struct task_struct *child)
|
||||
int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
int err;
|
||||
int n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_FP_SIZE];
|
||||
|
||||
err = convert_fxsr_from_user(&child->thread.regs,
|
||||
(struct _fpstate __user *) buf);
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs));
|
||||
if (n > 0)
|
||||
return -EFAULT;
|
||||
|
||||
return restore_fp_registers(userspace_pid[cpu], fpregs);
|
||||
}
|
||||
|
||||
int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_XFP_SIZE];
|
||||
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
err = save_fpx_registers(userspace_pid[cpu], fpregs);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
n = copy_to_user((void *) buf, fpregs, sizeof(fpregs));
|
||||
if(n > 0)
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int get_fpxregs(unsigned long buf, struct task_struct *tsk)
|
||||
int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_XFP_SIZE];
|
||||
|
||||
int set_fpxregs(unsigned long buf, struct task_struct *tsk)
|
||||
{
|
||||
return 0;
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs));
|
||||
if (n > 0)
|
||||
return -EFAULT;
|
||||
|
||||
return restore_fpx_registers(userspace_pid[cpu], fpregs);
|
||||
}
|
||||
|
||||
#ifdef notdef
|
||||
|
|
@ -209,3 +226,9 @@ int dump_fpu(struct pt_regs *regs, elf_fpregset_t *fpu )
|
|||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
long subarch_ptrace(struct task_struct *child, long request, long addr,
|
||||
long data)
|
||||
{
|
||||
return -EIO;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,28 +156,53 @@ int is_syscall(unsigned long addr)
|
|||
return(instr == 0x050f);
|
||||
}
|
||||
|
||||
int get_fpregs(unsigned long buf, struct task_struct *child)
|
||||
int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
panic("get_fpregs");
|
||||
return(0);
|
||||
int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_FP_SIZE];
|
||||
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
err = save_fp_registers(userspace_pid[cpu], fpregs);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
n = copy_to_user((void *) buf, fpregs, sizeof(fpregs));
|
||||
if(n > 0)
|
||||
return -EFAULT;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
int set_fpregs(unsigned long buf, struct task_struct *child)
|
||||
int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
|
||||
{
|
||||
panic("set_fpregs");
|
||||
return(0);
|
||||
int n, cpu = ((struct thread_info *) child->stack)->cpu;
|
||||
long fpregs[HOST_FP_SIZE];
|
||||
|
||||
BUG_ON(sizeof(*buf) != sizeof(fpregs));
|
||||
n = copy_from_user(fpregs, (void *) buf, sizeof(fpregs));
|
||||
if (n > 0)
|
||||
return -EFAULT;
|
||||
|
||||
return restore_fp_registers(userspace_pid[cpu], fpregs);
|
||||
}
|
||||
|
||||
int get_fpxregs(unsigned long buf, struct task_struct *tsk)
|
||||
long subarch_ptrace(struct task_struct *child, long request, long addr,
|
||||
long data)
|
||||
{
|
||||
panic("get_fpxregs");
|
||||
return(0);
|
||||
}
|
||||
int ret = -EIO;
|
||||
|
||||
int set_fpxregs(unsigned long buf, struct task_struct *tsk)
|
||||
{
|
||||
panic("set_fxpregs");
|
||||
return(0);
|
||||
switch (request) {
|
||||
case PTRACE_GETFPXREGS: /* Get the child FPU state. */
|
||||
ret = get_fpregs((struct user_i387_struct __user *) data,
|
||||
child);
|
||||
break;
|
||||
case PTRACE_SETFPXREGS: /* Set the child FPU state. */
|
||||
ret = set_fpregs((struct user_i387_struct __user *) data,
|
||||
child);
|
||||
break;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
Loading…
Reference in a new issue