Re: [PATCH] alpha: convert to generic sys_ptrace

Previous thread: Linux 2.4.36-pre1 by Willy Tarreau on Saturday, September 8, 2007 - 11:46 am. (1 message)

Next thread: Linux 2.6.20.19 by Willy Tarreau on Saturday, September 8, 2007 - 12:41 pm. (2 messages)
From: Christoph Hellwig
Date: Saturday, September 8, 2007 - 12:12 pm

This patch converts alpha to the generic sys_ptrace.  We use
force_successful_syscall_return to avoid having to pass the pt_regs
pointer down to the function.  I think the removal of the assemly
stub is correct, but I could only compile-test this patch, so please
give it a spin before commiting :)


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

Index: linux-2.6/arch/alpha/kernel/ptrace.c
===================================================================
--- linux-2.6.orig/arch/alpha/kernel/ptrace.c	2007-09-08 20:23:22.000000000 +0200
+++ linux-2.6/arch/alpha/kernel/ptrace.c	2007-09-08 20:52:32.000000000 +0200
@@ -260,38 +260,12 @@ void ptrace_disable(struct task_struct *
 	ptrace_cancel_bpt(child);
 }
 
-asmlinkage long
-do_sys_ptrace(long request, long pid, long addr, long data,
-	      struct pt_regs *regs)
+long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 {
-	struct task_struct *child;
 	unsigned long tmp;
 	size_t copied;
 	long ret;
 
-	lock_kernel();
-	DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
-		      request, pid, addr, data));
-	if (request == PTRACE_TRACEME) {
-		ret = ptrace_traceme();
-		goto out_notsk;
-	}
-
-	child = ptrace_get_task_struct(pid);
-	if (IS_ERR(child)) {
-		ret = PTR_ERR(child);
-		goto out_notsk;
-	}
-
-	if (request == PTRACE_ATTACH) {
-		ret = ptrace_attach(child);
-		goto out;
-	}
-
-	ret = ptrace_check_attach(child, request == PTRACE_KILL);
-	if (ret < 0)
-		goto out;
-
 	switch (request) {
 	/* When I and D space are separate, these will need to be fixed.  */
 	case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -301,13 +275,13 @@ do_sys_ptrace(long request, long pid, lo
 		if (copied != sizeof(tmp))
 			break;
 		
-		regs->r0 = 0;	/* special return: no errors */
+		force_successful_syscall_return();
 		ret = tmp;
 		break;
 
 	/* Read register number ADDR. */
 	case PTRACE_PEEKUSR:
-		regs->r0 = 0;	/* special return: no errors ...
From: Andrew Morton
Date: Saturday, September 15, 2007 - 1:11 am

Needed a bit of massaging due to consolidate-ptrace_detach.patch but
it still compiles:

 arch/alpha/kernel/entry.S  |    9 -------
 arch/alpha/kernel/ptrace.c |   42 +++++------------------------------
 include/asm-alpha/ptrace.h |    2 -
 3 files changed, 6 insertions(+), 47 deletions(-)

diff -puN arch/alpha/kernel/entry.S~alpha-convert-to-generic-sys_ptrace arch/alpha/kernel/entry.S
--- a/arch/alpha/kernel/entry.S~alpha-convert-to-generic-sys_ptrace
+++ a/arch/alpha/kernel/entry.S
@@ -917,15 +917,6 @@ sys_pipe:
 .end sys_pipe
 
 	.align	4
-	.globl	sys_ptrace
-	.ent	sys_ptrace
-sys_ptrace:
-	.prologue 0
-	mov	$sp, $20
-	jmp	$31, do_sys_ptrace
-.end sys_ptrace
-
-	.align	4
 	.globl	sys_execve
 	.ent	sys_execve
 sys_execve:
diff -puN arch/alpha/kernel/ptrace.c~alpha-convert-to-generic-sys_ptrace arch/alpha/kernel/ptrace.c
--- a/arch/alpha/kernel/ptrace.c~alpha-convert-to-generic-sys_ptrace
+++ a/arch/alpha/kernel/ptrace.c
@@ -260,38 +260,12 @@ void ptrace_disable(struct task_struct *
 	ptrace_cancel_bpt(child);
 }
 
-asmlinkage long
-do_sys_ptrace(long request, long pid, long addr, long data,
-	      struct pt_regs *regs)
+long arch_ptrace(struct task_struct *child, long request, long addr, long data)
 {
-	struct task_struct *child;
 	unsigned long tmp;
 	size_t copied;
 	long ret;
 
-	lock_kernel();
-	DBG(DBG_MEM, ("request=%ld pid=%ld addr=0x%lx data=0x%lx\n",
-		      request, pid, addr, data));
-	if (request == PTRACE_TRACEME) {
-		ret = ptrace_traceme();
-		goto out_notsk;
-	}
-
-	child = ptrace_get_task_struct(pid);
-	if (IS_ERR(child)) {
-		ret = PTR_ERR(child);
-		goto out_notsk;
-	}
-
-	if (request == PTRACE_ATTACH) {
-		ret = ptrace_attach(child);
-		goto out;
-	}
-
-	ret = ptrace_check_attach(child, request == PTRACE_KILL);
-	if (ret < 0)
-		goto out;
-
 	switch (request) {
 	/* When I and D space are separate, these will need to be fixed.  */
 	case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -301,13 +275,13 @@ ...
From: Christoph Hellwig
Date: Saturday, September 15, 2007 - 1:14 am

Btw,does alpha actually build for you sucessfully?  While I could get
the ptrace bits to compile 2.6.23-rc doesn't actually finish the build
for me due to missing syscalls and the brainded -Werror flag making this
fatal..

-

From: Andrew Morton
Date: Saturday, September 15, 2007 - 1:36 am

I just did a successful gcc-4.1.0 alpha allmodconfig build with 2.6.23-rc5
plus 44 patches which are in or are targetted for ...
From: Christoph Hellwig
Date: Monday, September 17, 2007 - 6:08 am

Yeah, things seem to be in better shape now.

-

Previous thread: