[uml-devel] [PATCH] UML utrace support, step 1

2007-02-20 Thread Jeff Dike
Below is the first step in your Fix-Your-Broken-Arch-HOWTO for UML.

Do you want incremental patches as I go along, or replacement ones?

BTW, UML runs on the utrace in -mm (i.e. utrace on the host), which it
didn't with several Fedora kernels.

Jeff

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



The first step in making the utrace arch changes for UML.  It builds
and runs now, but ptrace is broken.

Signed-off-by: Jeff Dike <[EMAIL PROTECTED]>
--
 arch/um/kernel/exec.c   |1 
 arch/um/kernel/process.c|6 
 arch/um/kernel/ptrace.c |  333 +---
 arch/um/kernel/signal.c |5 
 arch/um/kernel/skas/syscall.c   |4 
 arch/um/sys-i386/signal.c   |4 
 include/asm-um/ptrace-generic.h |3 
 include/asm-um/tracehook.h  |   66 +++
 8 files changed, 115 insertions(+), 307 deletions(-)

Index: linux-2.6.18-mm/arch/um/kernel/exec.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/exec.c  2007-02-20 16:18:07.0 
-0500
+++ linux-2.6.18-mm/arch/um/kernel/exec.c   2007-02-20 16:18:50.0 
-0500
@@ -51,7 +51,6 @@ static long execve1(char *file, char __u
 error = do_execve(file, argv, env, ¤t->thread.regs);
 if (error == 0){
task_lock(current);
-current->ptrace &= ~PT_DTRACE;
 #ifdef SUBARCH_EXECVE1
SUBARCH_EXECVE1(¤t->thread.regs.regs);
 #endif
Index: linux-2.6.18-mm/arch/um/kernel/process.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/process.c   2007-02-20 
16:18:07.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/process.c2007-02-20 16:18:50.0 
-0500
@@ -458,11 +458,11 @@ int singlestepping(void * t)
 {
struct task_struct *task = t ? t : current;
 
-   if ( ! (task->ptrace & PT_DTRACE) )
-   return(0);
+   if (!test_thread_flag(TIF_SINGLESTEP))
+   return 0;
 
if (task->thread.singlestep_syscall)
-   return(1);
+   return 1;
 
return 2;
 }
Index: linux-2.6.18-mm/arch/um/kernel/ptrace.c
===
--- linux-2.6.18-mm.orig/arch/um/kernel/ptrace.c2007-02-20 
16:18:07.0 -0500
+++ linux-2.6.18-mm/arch/um/kernel/ptrace.c 2007-02-20 16:18:50.0 
-0500
@@ -3,261 +3,29 @@
  * Licensed under the GPL
  */
 
-#include "linux/sched.h"
-#include "linux/mm.h"
-#include "linux/errno.h"
-#include "linux/smp_lock.h"
-#include "linux/security.h"
-#include "linux/ptrace.h"
-#include "linux/audit.h"
-#ifdef CONFIG_PROC_MM
-#include "linux/proc_mm.h"
-#endif
-#include "asm/ptrace.h"
-#include "asm/uaccess.h"
-#include "kern_util.h"
-#include "skas_ptrace.h"
-#include "sysdep/ptrace.h"
-#include "os.h"
-
-static inline void set_singlestepping(struct task_struct *child, int on)
+#include 
+#include 
+#include 
+#include 
+#include 
+
+const struct utrace_regset_view utrace_um_native = {
+   .name   = "um",
+   .e_machine  = ELF_ARCH,
+   .regsets= NULL,
+   .n  = 0,
+};
+EXPORT_SYMBOL_GPL(utrace_um_native);
+
+int arch_ptrace(long *req, struct task_struct *child,
+   struct utrace_attached_engine *engine,
+   unsigned long addr, unsigned long data, long *val)
 {
-if (on)
-child->ptrace |= PT_DTRACE;
-else
-child->ptrace &= ~PT_DTRACE;
-child->thread.singlestep_syscall = 0;
-
-#ifdef SUBARCH_SET_SINGLESTEPPING
-SUBARCH_SET_SINGLESTEPPING(child, on);
-#endif
+   return -ENOSYS;
 }
 
-/*
- * Called by kernel/ptrace.c when detaching..
- */
-void ptrace_disable(struct task_struct *child)
-{ 
-set_singlestepping(child,0);
-}
-
-extern int peek_user(struct task_struct * child, long addr, long data);
-extern int poke_user(struct task_struct * child, long addr, long data);
-
-long arch_ptrace(struct task_struct *child, long request, long addr, long data)
-{
-   int i, ret;
-   unsigned long __user *p = (void __user *)(unsigned long)data;
-
-   switch (request) {
-   /* when I and D space are separate, these will need to be 
fixed. */
-   case PTRACE_PEEKTEXT: /* read word at location addr. */ 
-   case PTRACE_PEEKDATA: {
-   unsigned long tmp;
-   int copied;
-
-   ret = -EIO;
-   copied = access_process_vm(child, addr, &tmp, sizeof(tmp), 0);
-   if (copied != sizeof(tmp))
-   break;
-   ret = put_user(tmp, p);
-   break;
-   }
-
-   /* read the word at location addr in the USER area. */
-case PTRACE_PEEKUSR:
-ret = peek_user(child, addr, data);
-break;
-
-   /* when I and D space are separate, this will have to b

[uml-devel] [patch 09/21] x86_64: fix 2.6.18 regression - PTRACE_OLDSETOPTIONS should be accepted

2007-02-20 Thread Greg KH
-stable review patch.  If anyone has any objections, please let us know.

--

Also PTRACE_OLDSETOPTIONS should be accepted, as done by kernel/ptrace.c and
forced by binary compatibility. UML/32bit breaks because of this - since it is 
wise
enough to use PTRACE_OLDSETOPTIONS to be binary compatible with 2.4 host
kernels.

Until 2.6.17 (commit f0f2d6536e3515b5b1b7ae97dc8f176860c8c2ce) we had:

   default:
return sys_ptrace(request, pid, addr, data);

Instead here we have:
case PTRACE_GET_THREAD_AREA:
case ...:
return sys_ptrace(request, pid, addr, data);

default:
return -EINVAL;

This change was a style change - when a case is added, it must be explicitly
tested this way. In this case, not enough testing was done.

Cc: Andi Kleen <[EMAIL PROTECTED]>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
 arch/x86_64/ia32/ptrace32.c |1 +
 1 file changed, 1 insertion(+)

--- linux-2.6.19.4.orig/arch/x86_64/ia32/ptrace32.c
+++ linux-2.6.19.4/arch/x86_64/ia32/ptrace32.c
@@ -243,6 +243,7 @@ asmlinkage long sys32_ptrace(long reques
case PTRACE_SINGLESTEP:
case PTRACE_DETACH:
case PTRACE_SYSCALL:
+   case PTRACE_OLDSETOPTIONS:
case PTRACE_SETOPTIONS:
case PTRACE_SET_THREAD_AREA:
case PTRACE_GET_THREAD_AREA:

--

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


[uml-devel] [patch 18/18] x86_64: fix 2.6.18 regression - PTRACE_OLDSETOPTIONS should be accepted

2007-02-20 Thread Greg KH
-stable review patch.  If anyone has any objections, please let us know.

--
From: "Paolo 'Blaisorblade' Giarrusso" <[EMAIL PROTECTED]>

Also PTRACE_OLDSETOPTIONS should be accepted, as done by kernel/ptrace.c and
forced by binary compatibility. UML/32bit breaks because of this - since it is 
wise
enough to use PTRACE_OLDSETOPTIONS to be binary compatible with 2.4 host
kernels.

Until 2.6.17 (commit f0f2d6536e3515b5b1b7ae97dc8f176860c8c2ce) we had:

   default:
return sys_ptrace(request, pid, addr, data);

Instead here we have:
case PTRACE_GET_THREAD_AREA:
case ...:
return sys_ptrace(request, pid, addr, data);

default:
return -EINVAL;

This change was a style change - when a case is added, it must be explicitly
tested this way. In this case, not enough testing was done.

Cc: Andi Kleen <[EMAIL PROTECTED]>
Signed-off-by: Paolo 'Blaisorblade' Giarrusso <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>

---
 arch/x86_64/ia32/ptrace32.c |1 +
 1 file changed, 1 insertion(+)

--- linux-2.6.18.7.orig/arch/x86_64/ia32/ptrace32.c
+++ linux-2.6.18.7/arch/x86_64/ia32/ptrace32.c
@@ -239,6 +239,7 @@ asmlinkage long sys32_ptrace(long reques
case PTRACE_SINGLESTEP:
case PTRACE_DETACH:
case PTRACE_SYSCALL:
+   case PTRACE_OLDSETOPTIONS:
case PTRACE_SETOPTIONS:
return sys_ptrace(request, pid, addr, data); 
 

--

-
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
___
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel