Skip to contentSkip to conversation

ia64: use generic compat_sys_ptrace

PATCH In review Christoph Hellwig 2 participants 5 messages Sep 1, 2008 – Oct 17, 2008

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ia64: use generic compat_sys_ptrace

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

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 */

#1 lore raw
Quoted 2 lines · Christoph Hellwig

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

ping? Also for the other compat patches.

#2 lore raw
In reply to Christoph Hellwig
Quoted 4 lines
Quoted 2 lines

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

#4 lore raw
In reply to Christoph Hellwig
Quoted 9 lines · Tony

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