public inbox for linux-ia64@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ia64: use generic compat_sys_ptrace
@ 2008-09-01 16:19 Christoph Hellwig
  2008-10-17 17:25 ` Christoph Hellwig
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Christoph Hellwig @ 2008-09-01 16:19 UTC (permalink / raw)
  To: linux-ia64

By using the generic compat_sys_ptrace we can remove lots of boilerplate
code.


Signed-off-by: Christoph Hellwig <hch@lst.de>

Index: linux-2.6/arch/ia64/ia32/sys_ia32.c
=================================--- linux-2.6.orig/arch/ia64/ia32/sys_ia32.c	2008-09-01 09:41:03.000000000 -0300
+++ linux-2.6/arch/ia64/ia32/sys_ia32.c	2008-09-01 09:46:09.000000000 -0300
@@ -1566,50 +1566,26 @@ restore_ia32_fpxstate (struct task_struc
 	return 0;
 }
 
-asmlinkage long
-sys32_ptrace (int request, pid_t pid, unsigned int addr, unsigned int data)
+long compat_arch_ptrace(struct task_struct *child, compat_long_t request,
+			       compat_ulong_t addr, compat_ulong_t data)
 {
-	struct task_struct *child;
 	unsigned int value, tmp;
 	long i, ret;
 
-	lock_kernel();
-	if (request = PTRACE_TRACEME) {
-		ret = ptrace_traceme();
-		goto out;
-	}
-
-	child = ptrace_get_task_struct(pid);
-	if (IS_ERR(child)) {
-		ret = PTR_ERR(child);
-		goto out;
-	}
-
-	if (request = PTRACE_ATTACH) {
-		ret = sys_ptrace(request, pid, addr, data);
-		goto out_tsk;
-	}
-
-	ret = ptrace_check_attach(child, request = PTRACE_KILL);
-	if (ret < 0)
-		goto out_tsk;
-
 	switch (request) {
-	      case PTRACE_PEEKTEXT:
-	      case PTRACE_PEEKDATA:	/* read word at location addr */
+	case PTRACE_PEEKTEXT:
+	case PTRACE_PEEKDATA:	/* read word at location addr */
 		ret = ia32_peek(child, addr, &value);
-		if (ret = 0)
+		if (ret != 0)
 			ret = put_user(value, (unsigned int __user *) compat_ptr(data));
 		else
 			ret = -EIO;
-		goto out_tsk;
-
-	      case PTRACE_POKETEXT:
-	      case PTRACE_POKEDATA:	/* write the word at location addr */
+		break;
+	case PTRACE_POKETEXT:
+	case PTRACE_POKEDATA:	/* write the word at location addr */
 		ret = ia32_poke(child, addr, data);
-		goto out_tsk;
-
-	      case PTRACE_PEEKUSR:	/* read word at addr in USER area */
+		break;
+	case PTRACE_PEEKUSR:	/* read word at addr in USER area */
 		ret = -EIO;
 		if ((addr & 3) || addr > 17*sizeof(int))
 			break;
@@ -1618,8 +1594,7 @@ sys32_ptrace (int request, pid_t pid, un
 		if (!put_user(tmp, (unsigned int __user *) compat_ptr(data)))
 			ret = 0;
 		break;
-
-	      case PTRACE_POKEUSR:	/* write word at addr in USER area */
+	case PTRACE_POKEUSR:	/* write word at addr in USER area */
 		ret = -EIO;
 		if ((addr & 3) || addr > 17*sizeof(int))
 			break;
@@ -1627,8 +1602,7 @@ sys32_ptrace (int request, pid_t pid, un
 		putreg(child, addr, data);
 		ret = 0;
 		break;
-
-	      case IA32_PTRACE_GETREGS:
+	case IA32_PTRACE_GETREGS:
 		if (!access_ok(VERIFY_WRITE, compat_ptr(data), 17*sizeof(int))) {
 			ret = -EIO;
 			break;
@@ -1639,8 +1613,7 @@ sys32_ptrace (int request, pid_t pid, un
 		}
 		ret = 0;
 		break;
-
-	      case IA32_PTRACE_SETREGS:
+	case IA32_PTRACE_SETREGS:
 		if (!access_ok(VERIFY_READ, compat_ptr(data), 17*sizeof(int))) {
 			ret = -EIO;
 			break;
@@ -1652,48 +1625,30 @@ sys32_ptrace (int request, pid_t pid, un
 		}
 		ret = 0;
 		break;
-
-	      case IA32_PTRACE_GETFPREGS:
+	case IA32_PTRACE_GETFPREGS:
 		ret = save_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
 					compat_ptr(data));
 		break;
-
-	      case IA32_PTRACE_GETFPXREGS:
+	case IA32_PTRACE_GETFPXREGS:
 		ret = save_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
 					 compat_ptr(data));
 		break;
-
-	      case IA32_PTRACE_SETFPREGS:
+	case IA32_PTRACE_SETFPREGS:
 		ret = restore_ia32_fpstate(child, (struct ia32_user_i387_struct __user *)
 					   compat_ptr(data));
 		break;
-
-	      case IA32_PTRACE_SETFPXREGS:
+	case IA32_PTRACE_SETFPXREGS:
 		ret = restore_ia32_fpxstate(child, (struct ia32_user_fxsr_struct __user *)
 					    compat_ptr(data));
 		break;
-
-	      case PTRACE_GETEVENTMSG:   
+	case PTRACE_GETEVENTMSG:
 		ret = put_user(child->ptrace_message, (unsigned int __user *) compat_ptr(data));
 		break;
-
-	      case PTRACE_SYSCALL:	/* continue, stop after next syscall */
-	      case PTRACE_CONT:		/* restart after signal. */
-	      case PTRACE_KILL:
-	      case PTRACE_SINGLESTEP:	/* execute chile for one instruction */
-	      case PTRACE_DETACH:	/* detach a process */
-		ret = sys_ptrace(request, pid, addr, data);
-		break;
-
-	      default:
-		ret = ptrace_request(child, request, addr, data);
+	default:
+		ret = compat_ptrace_request(child, request, addr, data);
 		break;
-
 	}
-  out_tsk:
-	put_task_struct(child);
-  out:
-	unlock_kernel();
+
 	return ret;
 }
 
Index: linux-2.6/arch/ia64/include/asm/ptrace.h
=================================--- linux-2.6.orig/arch/ia64/include/asm/ptrace.h	2008-09-01 09:40:34.000000000 -0300
+++ linux-2.6/arch/ia64/include/asm/ptrace.h	2008-09-01 09:41:05.000000000 -0300
@@ -319,6 +319,8 @@ struct switch_stack {
   #define arch_has_block_step()   (1)
   extern void user_enable_block_step(struct task_struct *);
 
+#define __ARCH_WANT_COMPAT_SYS_PTRACE
+
 #endif /* !__KERNEL__ */
 
 /* pt_all_user_regs is used for PTRACE_GETREGS PTRACE_SETREGS */

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

* Re: [PATCH] ia64: use generic compat_sys_ptrace
  2008-09-01 16:19 [PATCH] ia64: use generic compat_sys_ptrace Christoph Hellwig
@ 2008-10-17 17:25 ` Christoph Hellwig
  2008-10-17 17:45 ` Luck, Tony
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2008-10-17 17:25 UTC (permalink / raw)
  To: linux-ia64

On Mon, Sep 01, 2008 at 06:19:18PM +0200, Christoph Hellwig wrote:
> By using the generic compat_sys_ptrace we can remove lots of boilerplate
> code.

ping?  Also for the other compat patches.


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

* RE: [PATCH] ia64: use generic compat_sys_ptrace
  2008-09-01 16:19 [PATCH] ia64: use generic compat_sys_ptrace Christoph Hellwig
  2008-10-17 17:25 ` Christoph Hellwig
@ 2008-10-17 17:45 ` Luck, Tony
  2008-10-17 20:15 ` Luck, Tony
  2008-10-17 20:18 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Luck, Tony @ 2008-10-17 17:45 UTC (permalink / raw)
  To: linux-ia64

>> By using the generic compat_sys_ptrace we can remove lots of boilerplate
>> code.
>
> ping?  Also for the other compat patches.

Excellent timing for a reminder ... I'm pulling stuff together now
ready for a "please pull" soon.

-Tony

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

* RE: [PATCH] ia64: use generic compat_sys_ptrace
  2008-09-01 16:19 [PATCH] ia64: use generic compat_sys_ptrace Christoph Hellwig
  2008-10-17 17:25 ` Christoph Hellwig
  2008-10-17 17:45 ` Luck, Tony
@ 2008-10-17 20:15 ` Luck, Tony
  2008-10-17 20:18 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Luck, Tony @ 2008-10-17 20:15 UTC (permalink / raw)
  To: linux-ia64

Lots of overlap between your patch for this and
part 4 of Shaohua Li's utrace preparation patch
series:

http://marc.info/?l=linux-ia64&m\x122172423100433&w=2


I've taken Shaohua's patch.  We can work out later
whether any bits that you did got missed.


Your sys32_pipe and sys32_pause patches are now both
in my tree.

-Tony

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

* Re: [PATCH] ia64: use generic compat_sys_ptrace
  2008-09-01 16:19 [PATCH] ia64: use generic compat_sys_ptrace Christoph Hellwig
                   ` (2 preceding siblings ...)
  2008-10-17 20:15 ` Luck, Tony
@ 2008-10-17 20:18 ` Christoph Hellwig
  3 siblings, 0 replies; 5+ messages in thread
From: Christoph Hellwig @ 2008-10-17 20:18 UTC (permalink / raw)
  To: linux-ia64

On Fri, Oct 17, 2008 at 01:15:29PM -0700, Luck, Tony wrote:
> Lots of overlap between your patch for this and
> part 4 of Shaohua Li's utrace preparation patch
> series:
> 
> http://marc.info/?l=linux-ia64&m\x122172423100433&w=2
> 
> 
> I've taken Shaohua's patch.  We can work out later
> whether any bits that you did got missed.

That patch looks like it's strictly a superset of mine.  Which ins some
ways is a rather bad thing, and it's stuff that should be in a few
individual patches merged into a single large one.

But at least this should take care of the last per-arch compat ptrace
implementation.

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

end of thread, other threads:[~2008-10-17 20:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-09-01 16:19 [PATCH] ia64: use generic compat_sys_ptrace Christoph Hellwig
2008-10-17 17:25 ` Christoph Hellwig
2008-10-17 17:45 ` Luck, Tony
2008-10-17 20:15 ` Luck, Tony
2008-10-17 20:18 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox