Commit 47906dd9 authored by Jeff Dike's avatar Jeff Dike Committed by Linus Torvalds

uml: tidy ptrace interface

Tidy the ptrace interface code.  Removed a bunch of unused macros.
Started converting register sets from arrays of longs to structures.
Signed-off-by: default avatarJeff Dike <jdike@linux.intel.com>
Cc: WANG Cong <xiyou.wangcong@gmail.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 46d7b522
...@@ -41,38 +41,10 @@ ...@@ -41,38 +41,10 @@
#define PT_SP_OFFSET PT_OFFSET(UESP) #define PT_SP_OFFSET PT_OFFSET(UESP)
#define PT_SP(regs) ((regs)[UESP]) #define PT_SP(regs) ((regs)[UESP])
#define FP_SIZE ((HOST_XFP_SIZE > HOST_FP_SIZE) ? HOST_XFP_SIZE : HOST_FP_SIZE) #define FP_SIZE ((HOST_FPX_SIZE > HOST_FP_SIZE) ? HOST_FPX_SIZE : HOST_FP_SIZE)
#ifndef FRAME_SIZE #ifndef FRAME_SIZE
#define FRAME_SIZE (17) #define FRAME_SIZE (17)
#endif #endif
#define FRAME_SIZE_OFFSET (FRAME_SIZE * sizeof(unsigned long))
#define FP_FRAME_SIZE (27)
#define FPX_FRAME_SIZE (128)
#ifdef PTRACE_GETREGS
#define UM_HAVE_GETREGS
#endif
#ifdef PTRACE_SETREGS
#define UM_HAVE_SETREGS
#endif
#ifdef PTRACE_GETFPREGS
#define UM_HAVE_GETFPREGS
#endif
#ifdef PTRACE_SETFPREGS
#define UM_HAVE_SETFPREGS
#endif
#ifdef PTRACE_GETFPXREGS
#define UM_HAVE_GETFPXREGS
#endif
#ifdef PTRACE_SETFPXREGS
#define UM_HAVE_SETFPXREGS
#endif
#endif #endif
...@@ -48,7 +48,8 @@ ...@@ -48,7 +48,8 @@
#define PT_ORIG_RAX_OFFSET (ORIG_RAX) #define PT_ORIG_RAX_OFFSET (ORIG_RAX)
#define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)]) #define PT_ORIG_RAX(regs) ((regs)[PT_INDEX(ORIG_RAX)])
/* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though /*
* x86_64 FC3 doesn't define this in /usr/include/linux/ptrace.h even though
* it's defined in the kernel's include/linux/ptrace.h. Additionally, use the * it's defined in the kernel's include/linux/ptrace.h. Additionally, use the
* 2.4 name and value for 2.4 host compatibility. * 2.4 name and value for 2.4 host compatibility.
*/ */
...@@ -56,7 +57,8 @@ ...@@ -56,7 +57,8 @@
#define PTRACE_OLDSETOPTIONS 21 #define PTRACE_OLDSETOPTIONS 21
#endif #endif
/* These are before the system call, so the system call number is RAX /*
* These are before the system call, so the system call number is RAX
* rather than ORIG_RAX, and arg4 is R10 rather than RCX * rather than ORIG_RAX, and arg4 is R10 rather than RCX
*/ */
#define REGS_SYSCALL_NR PT_INDEX(RAX) #define REGS_SYSCALL_NR PT_INDEX(RAX)
...@@ -73,14 +75,3 @@ ...@@ -73,14 +75,3 @@
#define FP_SIZE (HOST_FP_SIZE) #define FP_SIZE (HOST_FP_SIZE)
#endif #endif
/*
* Overrides for Emacs so that we follow Linus's tabbing style.
* Emacs will notice this stuff at the end of the file and automatically
* adjust the settings for this buffer only. This must remain at the end
* of the file.
* ---------------------------------------------------------------------------
* Local variables:
* c-file-style: "linux"
* End:
*/
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
*/ */
#include <errno.h> #include <errno.h>
#include <asm/user.h>
#include "kern_constants.h" #include "kern_constants.h"
#include "longjmp.h" #include "longjmp.h"
#include "user.h" #include "user.h"
...@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned long *regs) ...@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned long *regs)
void arch_init_registers(int pid) void arch_init_registers(int pid)
{ {
unsigned long fpx_regs[HOST_XFP_SIZE]; struct user_fxsr_struct fpx_regs;
int err; int err;
err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs); err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs);
if (!err) if (!err)
return; return;
......
...@@ -148,14 +148,13 @@ int peek_user(struct task_struct *child, long addr, long data) ...@@ -148,14 +148,13 @@ int peek_user(struct task_struct *child, long addr, long data)
int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int err, n, cpu = ((struct thread_info *) child->stack)->cpu; int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_FP_SIZE]; struct user_i387_struct fpregs;
BUG_ON(sizeof(*buf) != sizeof(fpregs)); err = save_fp_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
err = save_fp_registers(userspace_pid[cpu], fpregs);
if (err) if (err)
return err; return err;
n = copy_to_user(buf, fpregs, sizeof(fpregs)); n = copy_to_user(buf, &fpregs, sizeof(fpregs));
if(n > 0) if(n > 0)
return -EFAULT; return -EFAULT;
...@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) ...@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child) int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
{ {
int n, cpu = ((struct thread_info *) child->stack)->cpu; int n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_FP_SIZE]; struct user_i387_struct fpregs;
BUG_ON(sizeof(*buf) != sizeof(fpregs)); n = copy_from_user(&fpregs, buf, sizeof(fpregs));
n = copy_from_user(fpregs, buf, sizeof(fpregs));
if (n > 0) if (n > 0)
return -EFAULT; return -EFAULT;
return restore_fp_registers(userspace_pid[cpu], fpregs); return restore_fp_registers(userspace_pid[cpu],
(unsigned long *) &fpregs);
} }
int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
{ {
int err, n, cpu = ((struct thread_info *) child->stack)->cpu; int err, n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_XFP_SIZE]; struct user_fxsr_struct fpregs;
BUG_ON(sizeof(*buf) != sizeof(fpregs)); err = save_fpx_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
err = save_fpx_registers(userspace_pid[cpu], fpregs);
if (err) if (err)
return err; return err;
n = copy_to_user(buf, fpregs, sizeof(fpregs)); n = copy_to_user(buf, &fpregs, sizeof(fpregs));
if(n > 0) if(n > 0)
return -EFAULT; return -EFAULT;
...@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) ...@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child) int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
{ {
int n, cpu = ((struct thread_info *) child->stack)->cpu; int n, cpu = ((struct thread_info *) child->stack)->cpu;
long fpregs[HOST_XFP_SIZE]; struct user_fxsr_struct fpregs;
BUG_ON(sizeof(*buf) != sizeof(fpregs)); n = copy_from_user(&fpregs, buf, sizeof(fpregs));
n = copy_from_user(fpregs, buf, sizeof(fpregs));
if (n > 0) if (n > 0)
return -EFAULT; return -EFAULT;
return restore_fpx_registers(userspace_pid[cpu], fpregs); return restore_fpx_registers(userspace_pid[cpu],
(unsigned long *) &fpregs);
} }
long subarch_ptrace(struct task_struct *child, long request, long addr, long subarch_ptrace(struct task_struct *child, long request, long addr,
......
...@@ -22,7 +22,7 @@ void foo(void) ...@@ -22,7 +22,7 @@ void foo(void)
OFFSET(HOST_SC_CR2, sigcontext, cr2); OFFSET(HOST_SC_CR2, sigcontext, cr2);
DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct)); DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_fpregs_struct));
DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fpxregs_struct)); DEFINE_LONGS(HOST_FPX_SIZE, sizeof(struct user_fpxregs_struct));
DEFINE(HOST_IP, EIP); DEFINE(HOST_IP, EIP);
DEFINE(HOST_SP, UESP); DEFINE(HOST_SP, UESP);
......
...@@ -24,7 +24,6 @@ void foo(void) ...@@ -24,7 +24,6 @@ void foo(void)
OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long)); DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
DEFINE(HOST_XFP_SIZE, 0);
DEFINE_LONGS(HOST_RBX, RBX); DEFINE_LONGS(HOST_RBX, RBX);
DEFINE_LONGS(HOST_RCX, RCX); DEFINE_LONGS(HOST_RCX, RCX);
DEFINE_LONGS(HOST_RDI, RDI); DEFINE_LONGS(HOST_RDI, RDI);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment