Skip to contentSkip to conversation

alpha: convert to generic sys_ptrace

PATCH In review Christoph Hellwig 2 participants 5 messages Sep 8, 2007 – Sep 17, 2007

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 alpha: convert to generic sys_ptrace

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 :)

arch/alpha/kernel/ptrace.c +8 -37
Index: linux-2.6/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 @@ 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 */
+		force_successful_syscall_return();
 		ret = get_reg(child, addr);
 		DBG(DBG_MEM, ("peek $%ld->%#lx\n", addr, ret));
 		break;
@@ -353,7 +327,7 @@ do_sys_ptrace(long request, long pid, lo
 		/* make sure single-step breakpoint is gone. */
 		ptrace_cancel_bpt(child);
 		wake_up_process(child);
-		goto out;
+		break;
 
 	case PTRACE_SINGLESTEP:  /* execute single instruction. */
 		ret = -EIO;
@@ -366,20 +340,17 @@ do_sys_ptrace(long request, long pid, lo
 		wake_up_process(child);
 		/* give it a chance to run. */
 		ret = 0;
-		goto out;
+		break;
 
 	case PTRACE_DETACH:	 /* detach a process that was attached. */
 		ret = ptrace_detach(child, data);
-		goto out;
+		break;
 
 	default:
 		ret = ptrace_request(child, request, addr, data);
-		goto out;
+		break;
 	}
- out:
-	put_task_struct(child);
- out_notsk:
-	unlock_kernel();
+
 	return ret;
 }
 
arch/alpha/kernel/entry.S +0 -9
Index: linux-2.6/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:
include/asm-alpha/ptrace.h +0 -2
Index: linux-2.6/include/asm-alpha/ptrace.h
===================================================================
@@ -68,8 +68,6 @@ struct switch_stack {
 
 #ifdef __KERNEL__
 
-#define __ARCH_SYS_PTRACE	1
-
 #define user_mode(regs) (((regs)->ps & 8) != 0)
 #define instruction_pointer(regs) ((regs)->pc)
 #define profile_pc(regs) instruction_pointer(regs)
#1 lore raw
Quoted 5 lines · On Sat, 8 Sep 2007 21:12:57 +0200 Christoph Hellwig <[email protected]> wrote:

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 :)

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(-)
arch/alpha/kernel/entry.S renamed from arch/alpha/kernel/entry.S~alpha-convert-to-generic-sys_ptrace +0 -9
diff -puN arch/alpha/kernel/entry.S~alpha-convert-to-generic-sys_ptrace 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:
arch/alpha/kernel/ptrace.c renamed from arch/alpha/kernel/ptrace.c~alpha-convert-to-generic-sys_ptrace +6 -36

80 lines not on this page · raw message

include/asm-alpha/ptrace.h renamed from include/asm-alpha/ptrace.h~alpha-convert-to-generic-sys_ptrace +0 -2
diff -puN include/asm-alpha/ptrace.h~alpha-convert-to-generic-sys_ptrace include/asm-alpha/ptrace.h
@@ -68,8 +68,6 @@ struct switch_stack {
 
 #ifdef __KERNEL__
 
-#define __ARCH_SYS_PTRACE	1
-
 #define user_mode(regs) (((regs)->ps & 8) != 0)
 #define instruction_pointer(regs) ((regs)->pc)
 #define profile_pc(regs) instruction_pointer(regs)

_

#2 lore raw
Quoted 10 lines · Andrew Morton
Quoted 5 lines · On Sat, 8 Sep 2007 21:12:57 +0200 Christoph Hellwig <[email protected]> wrote:

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 :)

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

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..

#3 lore raw
Quoted 9 lines · On Sat, 15 Sep 2007 10:14:37 +0200 Christoph Hellwig <[email protected]> wrote:
Quoted 8 lines · Andrew Morton
Quoted 5 lines · On Sat, 8 Sep 2007 21:12:57 +0200 Christoph Hellwig <[email protected]> wrote:

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 :)

Quoted 7 lines
Quoted 2 lines

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

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..

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 2.6.23:

quote-fix-infinite-loop.patch
spi_mpc83xx-hang-fix.patch drivers-edac-fix-printk-level-down-to-debug-from-emerg.patch drivers-edac-fix-e752x-correct-return-code.patch bcm1480-serial-build-fix.patch pnp-remove-smcf010-quirk.patch md-fix-some-bugs-with-growing-raid5-raid6-arrays.patch mntput-called-before-dput-in-afs.patch fix-dac960-driver-on-machines-which-dont-support-64-bit-dma.patch fix-dac960-driver-on-machines-which-dont-support-64-bit-dma-fix.patch documentation-00-index-notice-ecryptfstxt-moved.patch h8-300-fix-misnamed-config_blkdev_reserve_address-kconfig-variable.patch rtc-v3020-fixes.patch
ptr_align.patch fix-typo-in-documentation-submittingpatches.patch futex_compat-fix-list-traversal-bugs.patch tty-termios-locking-functions-break-with-new-termios.patch restore-call_usermodehelper_pipe-behaviour.patch fix-select-on-proc-files-without-poll.patch m68knommu-add-missing-syscalls.patch intel_agp-fix-stolen-mem-range-on-g33.patch intel_agp-fix-gtt-map-size-on-g33.patch bug-in-at91-mci-suspend-routines.patch leases-can-be-hidden-by-flocks.patch fix-no_sync_cmos_clock-logic-inversion-in-kernel-time-ntpc.patch revert-highmem-catch-illegal-nesting.patch slub-accurately-compare-debug-flags-during-slab-cache-merge.patch intel-fb-pixel-clock-calculation-fix.patch fix-serial_core_console-driver-dependencies.patch timekeeping-prevent-time-going-backwards-on-resume.patch timekeeping-prevent-time-going-backwards-on-resume-v2.patch uml-use-correct-type-in-blkgetsize-ioctl.patch atyfb-force-29mhz-xtal-on-g3-powerbooks.patch sparc64-and-others-fix-tty_ioctlc-build.patch lguest-fix-guest-crash-when-config_x86_use_3dnow=y.patch leds-add-include-linux-spinlock_typesh-to.patch fix-failure-to-resume-from-initrds.patch fix-uts-corruption-during-cloneclone_newuts.patch fix-build-with-config_compat=y-and-config_block=n.patch rtc-ds1742c-should-use-resource_size_t-for-base-address.patch rtc-rtc-ds1553c-should-use-resource_size_t-for-base.patch mspec-handle-shrinking-virtual-memory-areas.patch

#4 lore raw
Quoted 2 lines · Andrew Morton

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 2.6.23:

Yeah, things seem to be in better shape now.