All of lore.kernel.org
 help / color / mirror / Atom feed
* [uml-devel] [PATCH 9/19] UML - Tidy ptrace interface
@ 2008-04-25 17:56 ` Jeff Dike
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Dike @ 2008-04-25 17:56 UTC (permalink / raw)
  To: Andrew Morton, LKML, uml-devel

Tidy the ptrace interface code.  Removed a bunch of unused macros.
Started converting register sets from arrays of longs to structures.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
---
 arch/um/include/sysdep-i386/ptrace_user.h   |   30 ----------------------------
 arch/um/include/sysdep-x86_64/ptrace_user.h |   17 +++------------
 arch/um/os-Linux/sys-i386/registers.c       |    5 ++--
 arch/um/sys-i386/ptrace.c                   |   30 +++++++++++++---------------
 arch/um/sys-i386/user-offsets.c             |    2 -
 arch/um/sys-x86_64/user-offsets.c           |    1 
 6 files changed, 23 insertions(+), 62 deletions(-)

Index: linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h
===================================================================
--- linux-2.6-git.orig/arch/um/include/sysdep-i386/ptrace_user.h	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h	2008-02-12 13:09:44.000000000 -0500
@@ -41,38 +41,10 @@
 #define PT_SP_OFFSET PT_OFFSET(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
 #define FRAME_SIZE (17)
 #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
Index: linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h
===================================================================
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/ptrace_user.h	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h	2008-02-12 13:09:44.000000000 -0500
@@ -48,7 +48,8 @@
 #define PT_ORIG_RAX_OFFSET (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
  * 2.4 name and value for 2.4 host compatibility.
  */
@@ -56,7 +57,8 @@
 #define PTRACE_OLDSETOPTIONS 21
 #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
  */
 #define REGS_SYSCALL_NR PT_INDEX(RAX)
@@ -73,14 +75,3 @@
 #define FP_SIZE (HOST_FP_SIZE)
 
 #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:
- */
Index: linux-2.6-git/arch/um/sys-i386/ptrace.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-i386/ptrace.c	2008-02-12 12:44:44.000000000 -0500
+++ linux-2.6-git/arch/um/sys-i386/ptrace.c	2008-02-12 13:16:14.000000000 -0500
@@ -148,14 +148,13 @@ int peek_user(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;
-	long fpregs[HOST_FP_SIZE];
+	struct user_i387_struct fpregs;
 
-	BUG_ON(sizeof(*buf) != sizeof(fpregs));
-	err = save_fp_registers(userspace_pid[cpu], fpregs);
+	err = save_fp_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
 	if (err)
 		return err;
 
-	n = copy_to_user(buf, fpregs, sizeof(fpregs));
+	n = copy_to_user(buf, &fpregs, sizeof(fpregs));
 	if(n > 0)
 		return -EFAULT;
 
@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct _
 int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
 	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)
 		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 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], fpregs);
+	err = save_fpx_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
 	if (err)
 		return err;
 
-	n = copy_to_user(buf, fpregs, sizeof(fpregs));
+	n = copy_to_user(buf, &fpregs, sizeof(fpregs));
 	if(n > 0)
 		return -EFAULT;
 
@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct 
 int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
 {
 	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)
 		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,
Index: linux-2.6-git/arch/um/os-Linux/sys-i386/registers.c
===================================================================
--- linux-2.6-git.orig/arch/um/os-Linux/sys-i386/registers.c	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/os-Linux/sys-i386/registers.c	2008-02-12 13:10:44.000000000 -0500
@@ -5,6 +5,7 @@
  */
 
 #include <errno.h>
+#include <asm/user.h>
 #include "kern_constants.h"
 #include "longjmp.h"
 #include "user.h"
@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned l
 
 void arch_init_registers(int pid)
 {
-	unsigned long fpx_regs[HOST_XFP_SIZE];
+	struct user_fxsr_struct fpx_regs;
 	int err;
 
-	err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs);
+	err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs);
 	if (!err)
 		return;
 
Index: linux-2.6-git/arch/um/sys-i386/user-offsets.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-i386/user-offsets.c	2008-02-12 13:00:01.000000000 -0500
+++ linux-2.6-git/arch/um/sys-i386/user-offsets.c	2008-02-12 13:09:44.000000000 -0500
@@ -22,7 +22,7 @@ void foo(void)
 	OFFSET(HOST_SC_CR2, sigcontext, cr2);
 
 	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_SP, UESP);
Index: linux-2.6-git/arch/um/sys-x86_64/user-offsets.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-x86_64/user-offsets.c	2008-02-12 13:00:01.000000000 -0500
+++ linux-2.6-git/arch/um/sys-x86_64/user-offsets.c	2008-02-12 13:09:44.000000000 -0500
@@ -24,7 +24,6 @@ void foo(void)
 	OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
 
 	DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
-	DEFINE(HOST_XFP_SIZE, 0);
 	DEFINE_LONGS(HOST_RBX, RBX);
 	DEFINE_LONGS(HOST_RCX, RCX);
 	DEFINE_LONGS(HOST_RDI, RDI);

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 9/19] UML - Tidy ptrace interface
@ 2008-04-25 17:56 ` Jeff Dike
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Dike @ 2008-04-25 17:56 UTC (permalink / raw)
  To: Andrew Morton, LKML, uml-devel

Tidy the ptrace interface code.  Removed a bunch of unused macros.
Started converting register sets from arrays of longs to structures.

Signed-off-by: Jeff Dike <jdike@linux.intel.com>
---
 arch/um/include/sysdep-i386/ptrace_user.h   |   30 ----------------------------
 arch/um/include/sysdep-x86_64/ptrace_user.h |   17 +++------------
 arch/um/os-Linux/sys-i386/registers.c       |    5 ++--
 arch/um/sys-i386/ptrace.c                   |   30 +++++++++++++---------------
 arch/um/sys-i386/user-offsets.c             |    2 -
 arch/um/sys-x86_64/user-offsets.c           |    1 
 6 files changed, 23 insertions(+), 62 deletions(-)

Index: linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h
===================================================================
--- linux-2.6-git.orig/arch/um/include/sysdep-i386/ptrace_user.h	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/include/sysdep-i386/ptrace_user.h	2008-02-12 13:09:44.000000000 -0500
@@ -41,38 +41,10 @@
 #define PT_SP_OFFSET PT_OFFSET(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
 #define FRAME_SIZE (17)
 #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
Index: linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h
===================================================================
--- linux-2.6-git.orig/arch/um/include/sysdep-x86_64/ptrace_user.h	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/include/sysdep-x86_64/ptrace_user.h	2008-02-12 13:09:44.000000000 -0500
@@ -48,7 +48,8 @@
 #define PT_ORIG_RAX_OFFSET (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
  * 2.4 name and value for 2.4 host compatibility.
  */
@@ -56,7 +57,8 @@
 #define PTRACE_OLDSETOPTIONS 21
 #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
  */
 #define REGS_SYSCALL_NR PT_INDEX(RAX)
@@ -73,14 +75,3 @@
 #define FP_SIZE (HOST_FP_SIZE)
 
 #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:
- */
Index: linux-2.6-git/arch/um/sys-i386/ptrace.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-i386/ptrace.c	2008-02-12 12:44:44.000000000 -0500
+++ linux-2.6-git/arch/um/sys-i386/ptrace.c	2008-02-12 13:16:14.000000000 -0500
@@ -148,14 +148,13 @@ int peek_user(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;
-	long fpregs[HOST_FP_SIZE];
+	struct user_i387_struct fpregs;
 
-	BUG_ON(sizeof(*buf) != sizeof(fpregs));
-	err = save_fp_registers(userspace_pid[cpu], fpregs);
+	err = save_fp_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
 	if (err)
 		return err;
 
-	n = copy_to_user(buf, fpregs, sizeof(fpregs));
+	n = copy_to_user(buf, &fpregs, sizeof(fpregs));
 	if(n > 0)
 		return -EFAULT;
 
@@ -165,27 +164,26 @@ int get_fpregs(struct user_i387_struct _
 int set_fpregs(struct user_i387_struct __user *buf, struct task_struct *child)
 {
 	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)
 		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 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], fpregs);
+	err = save_fpx_registers(userspace_pid[cpu], (unsigned long *) &fpregs);
 	if (err)
 		return err;
 
-	n = copy_to_user(buf, fpregs, sizeof(fpregs));
+	n = copy_to_user(buf, &fpregs, sizeof(fpregs));
 	if(n > 0)
 		return -EFAULT;
 
@@ -195,14 +193,14 @@ int get_fpxregs(struct user_fxsr_struct 
 int set_fpxregs(struct user_fxsr_struct __user *buf, struct task_struct *child)
 {
 	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)
 		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,
Index: linux-2.6-git/arch/um/os-Linux/sys-i386/registers.c
===================================================================
--- linux-2.6-git.orig/arch/um/os-Linux/sys-i386/registers.c	2008-02-12 13:05:07.000000000 -0500
+++ linux-2.6-git/arch/um/os-Linux/sys-i386/registers.c	2008-02-12 13:10:44.000000000 -0500
@@ -5,6 +5,7 @@
  */
 
 #include <errno.h>
+#include <asm/user.h>
 #include "kern_constants.h"
 #include "longjmp.h"
 #include "user.h"
@@ -74,10 +75,10 @@ int put_fp_registers(int pid, unsigned l
 
 void arch_init_registers(int pid)
 {
-	unsigned long fpx_regs[HOST_XFP_SIZE];
+	struct user_fxsr_struct fpx_regs;
 	int err;
 
-	err = ptrace(PTRACE_GETFPXREGS, pid, 0, fpx_regs);
+	err = ptrace(PTRACE_GETFPXREGS, pid, 0, &fpx_regs);
 	if (!err)
 		return;
 
Index: linux-2.6-git/arch/um/sys-i386/user-offsets.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-i386/user-offsets.c	2008-02-12 13:00:01.000000000 -0500
+++ linux-2.6-git/arch/um/sys-i386/user-offsets.c	2008-02-12 13:09:44.000000000 -0500
@@ -22,7 +22,7 @@ void foo(void)
 	OFFSET(HOST_SC_CR2, sigcontext, cr2);
 
 	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_SP, UESP);
Index: linux-2.6-git/arch/um/sys-x86_64/user-offsets.c
===================================================================
--- linux-2.6-git.orig/arch/um/sys-x86_64/user-offsets.c	2008-02-12 13:00:01.000000000 -0500
+++ linux-2.6-git/arch/um/sys-x86_64/user-offsets.c	2008-02-12 13:09:44.000000000 -0500
@@ -24,7 +24,6 @@ void foo(void)
 	OFFSET(HOST_SC_TRAPNO, sigcontext, trapno);
 
 	DEFINE(HOST_FP_SIZE, sizeof(struct _fpstate) / sizeof(unsigned long));
-	DEFINE(HOST_XFP_SIZE, 0);
 	DEFINE_LONGS(HOST_RBX, RBX);
 	DEFINE_LONGS(HOST_RCX, RCX);
 	DEFINE_LONGS(HOST_RDI, RDI);

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [uml-devel] [PATCH 9/19] UML - Tidy ptrace interface
  2008-04-25 17:56 ` Jeff Dike
@ 2008-04-26  9:35   ` WANG Cong
  -1 siblings, 0 replies; 8+ messages in thread
From: WANG Cong @ 2008-04-26  9:35 UTC (permalink / raw)
  To: jdike; +Cc: akpm, linux-kernel, user-mode-linux-devel

From: Jeff Dike <jdike@addtoit.com>
Date: Fri, 25 Apr 2008 13:56:10 -0400
> Tidy the ptrace interface code.  Removed a bunch of unused macros.
> Started converting register sets from arrays of longs to structures.

Could you please explain a bit why do this? I think long arrary is OK.

Thanks.

Cong

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 9/19] UML - Tidy ptrace interface
@ 2008-04-26  9:35   ` WANG Cong
  0 siblings, 0 replies; 8+ messages in thread
From: WANG Cong @ 2008-04-26  9:35 UTC (permalink / raw)
  To: jdike; +Cc: akpm, linux-kernel, user-mode-linux-devel

From: Jeff Dike <jdike@addtoit.com>
Date: Fri, 25 Apr 2008 13:56:10 -0400
> Tidy the ptrace interface code.  Removed a bunch of unused macros.
> Started converting register sets from arrays of longs to structures.

Could you please explain a bit why do this? I think long arrary is OK.

Thanks.

Cong

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [uml-devel] [PATCH 9/19] UML - Tidy ptrace interface
  2008-04-26  9:35   ` WANG Cong
@ 2008-04-28 15:42     ` Jeff Dike
  -1 siblings, 0 replies; 8+ messages in thread
From: Jeff Dike @ 2008-04-28 15:42 UTC (permalink / raw)
  To: WANG Cong; +Cc: akpm, linux-kernel, user-mode-linux-devel

On Sat, Apr 26, 2008 at 05:35:38PM +0800, WANG Cong wrote:
> From: Jeff Dike <jdike@addtoit.com>
> Date: Fri, 25 Apr 2008 13:56:10 -0400
> > Tidy the ptrace interface code.  Removed a bunch of unused macros.
> > Started converting register sets from arrays of longs to structures.
> 
> Could you please explain a bit why do this? I think long arrary is OK.

It's wrong on x86_64.  There, FRAME_SIZE is 168 -
     #define FRAME_SIZE 
and SS is the last register defined -
    #define SS 160
but there are a number of registers beyond that in the user_regs_struct:
	unsigned long	ss;
	unsigned long	fs_base;
	unsigned long	gs_base;
	unsigned long	ds;
	unsigned long	es;
	unsigned long	fs;
	unsigned long	gs;

The effect of GETREGS into a long[FRAME_SIZE] will be stack corruption.

    	      	      Jeff

-- 
Work email - jdike at linux dot intel dot com

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 9/19] UML - Tidy ptrace interface
@ 2008-04-28 15:42     ` Jeff Dike
  0 siblings, 0 replies; 8+ messages in thread
From: Jeff Dike @ 2008-04-28 15:42 UTC (permalink / raw)
  To: WANG Cong; +Cc: akpm, linux-kernel, user-mode-linux-devel

On Sat, Apr 26, 2008 at 05:35:38PM +0800, WANG Cong wrote:
> From: Jeff Dike <jdike@addtoit.com>
> Date: Fri, 25 Apr 2008 13:56:10 -0400
> > Tidy the ptrace interface code.  Removed a bunch of unused macros.
> > Started converting register sets from arrays of longs to structures.
> 
> Could you please explain a bit why do this? I think long arrary is OK.

It's wrong on x86_64.  There, FRAME_SIZE is 168 -
     #define FRAME_SIZE 
and SS is the last register defined -
    #define SS 160
but there are a number of registers beyond that in the user_regs_struct:
	unsigned long	ss;
	unsigned long	fs_base;
	unsigned long	gs_base;
	unsigned long	ds;
	unsigned long	es;
	unsigned long	fs;
	unsigned long	gs;

The effect of GETREGS into a long[FRAME_SIZE] will be stack corruption.

    	      	      Jeff

-- 
Work email - jdike at linux dot intel dot com

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [uml-devel] [PATCH 9/19] UML - Tidy ptrace interface
  2008-04-28 15:42     ` Jeff Dike
@ 2008-04-29  8:14       ` WANG Cong
  -1 siblings, 0 replies; 8+ messages in thread
From: WANG Cong @ 2008-04-29  8:14 UTC (permalink / raw)
  To: Jeff Dike; +Cc: akpm, WANG Cong, linux-kernel, user-mode-linux-devel

On Mon, 28 Apr 2008, Jeff Dike wrote:

> On Sat, Apr 26, 2008 at 05:35:38PM +0800, WANG Cong wrote:
>> From: Jeff Dike <jdike@addtoit.com>
>> Date: Fri, 25 Apr 2008 13:56:10 -0400
>> > Tidy the ptrace interface code.  Removed a bunch of unused macros.
>> > Started converting register sets from arrays of longs to structures.
>> 
>> Could you please explain a bit why do this? I think long arrary is OK.
>
> It's wrong on x86_64.  There, FRAME_SIZE is 168 -
>     #define FRAME_SIZE 
> and SS is the last register defined -
>    #define SS 160
> but there are a number of registers beyond that in the user_regs_struct:
> 	unsigned long	ss;
> 	unsigned long	fs_base;
> 	unsigned long	gs_base;
> 	unsigned long	ds;
> 	unsigned long	es;
> 	unsigned long	fs;
> 	unsigned long	gs;
>
> The effect of GETREGS into a long[FRAME_SIZE] will be stack corruption.
>

Thanks for teaching this. ;-)

--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.

-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference 
Don't miss this year's exciting event. There's still time to save $100. 
Use priority code J8TL2D2. 
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 9/19] UML - Tidy ptrace interface
@ 2008-04-29  8:14       ` WANG Cong
  0 siblings, 0 replies; 8+ messages in thread
From: WANG Cong @ 2008-04-29  8:14 UTC (permalink / raw)
  To: Jeff Dike; +Cc: WANG Cong, akpm, linux-kernel, user-mode-linux-devel

On Mon, 28 Apr 2008, Jeff Dike wrote:

> On Sat, Apr 26, 2008 at 05:35:38PM +0800, WANG Cong wrote:
>> From: Jeff Dike <jdike@addtoit.com>
>> Date: Fri, 25 Apr 2008 13:56:10 -0400
>> > Tidy the ptrace interface code.  Removed a bunch of unused macros.
>> > Started converting register sets from arrays of longs to structures.
>> 
>> Could you please explain a bit why do this? I think long arrary is OK.
>
> It's wrong on x86_64.  There, FRAME_SIZE is 168 -
>     #define FRAME_SIZE 
> and SS is the last register defined -
>    #define SS 160
> but there are a number of registers beyond that in the user_regs_struct:
> 	unsigned long	ss;
> 	unsigned long	fs_base;
> 	unsigned long	gs_base;
> 	unsigned long	ds;
> 	unsigned long	es;
> 	unsigned long	fs;
> 	unsigned long	gs;
>
> The effect of GETREGS into a long[FRAME_SIZE] will be stack corruption.
>

Thanks for teaching this. ;-)

--
Hi, I'm a .signature virus, please copy/paste me to help me spread
all over the world.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2008-04-29  8:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-25 17:56 [uml-devel] [PATCH 9/19] UML - Tidy ptrace interface Jeff Dike
2008-04-25 17:56 ` Jeff Dike
2008-04-26  9:35 ` [uml-devel] " WANG Cong
2008-04-26  9:35   ` WANG Cong
2008-04-28 15:42   ` [uml-devel] " Jeff Dike
2008-04-28 15:42     ` Jeff Dike
2008-04-29  8:14     ` [uml-devel] " WANG Cong
2008-04-29  8:14       ` WANG Cong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.