]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/um/os-Linux/start_up.c
Pull sbs into release branch
[linux-2.6-omap-h63xx.git] / arch / um / os-Linux / start_up.c
index 79471f85eb8963d79654484fa3af9fd50aa5908b..46f613975c199ebc2a323b14c399074190c9cd3f 100644 (file)
@@ -107,11 +107,12 @@ static int start_ptraced_child(void **stack_out)
        unsigned long sp;
        int pid, n, status;
 
-       stack = mmap(NULL, PAGE_SIZE, PROT_READ | PROT_WRITE | PROT_EXEC,
+       stack = mmap(NULL, UM_KERN_PAGE_SIZE,
+                    PROT_READ | PROT_WRITE | PROT_EXEC,
                     MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
        if(stack == MAP_FAILED)
                fatal_perror("check_ptrace : mmap failed");
-       sp = (unsigned long) stack + PAGE_SIZE - sizeof(void *);
+       sp = (unsigned long) stack + UM_KERN_PAGE_SIZE - sizeof(void *);
        pid = clone(ptrace_child, (void *) sp, SIGCHLD, NULL);
        if(pid < 0)
                fatal_perror("start_ptraced_child : clone failed");
@@ -144,9 +145,7 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode,
                int exit_with = WEXITSTATUS(status);
                if (exit_with == 2)
                        non_fatal("check_ptrace : child exited with status 2. "
-                                 "Serious trouble happening! Try updating "
-                                 "your host skas patch!\nDisabling SYSEMU "
-                                 "support.");
+                                 "\nDisabling SYSEMU support.\n");
                non_fatal("check_ptrace : child exited with exitcode %d, while "
                          "expecting %d; status 0x%x\n", exit_with,
                          exitcode, status);
@@ -155,7 +154,7 @@ static int stop_ptraced_child(int pid, void *stack, int exitcode,
                ret = -1;
        }
 
-       if(munmap(stack, PAGE_SIZE) < 0)
+       if(munmap(stack, UM_KERN_PAGE_SIZE) < 0)
                fatal_perror("check_ptrace : munmap failed");
        return ret;
 }
@@ -209,6 +208,7 @@ __uml_setup("nosysemu", nosysemu_cmd_param,
 static void __init check_sysemu(void)
 {
        void *stack;
+       unsigned long regs[MAX_REG_NR];
        int pid, n, status, count=0;
 
        non_fatal("Checking syscall emulation patch for ptrace...");
@@ -225,11 +225,20 @@ static void __init check_sysemu(void)
                fatal("check_sysemu : expected SIGTRAP, got status = %d",
                      status);
 
-       n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET,
-                  os_getpid());
-       if(n < 0)
-               fatal_perror("check_sysemu : failed to modify system call "
-                            "return");
+       if(ptrace(PTRACE_GETREGS, pid, 0, regs) < 0)
+               fatal_perror("check_sysemu : PTRACE_GETREGS failed");
+       if(PT_SYSCALL_NR(regs) != __NR_getpid){
+               non_fatal("check_sysemu got system call number %d, "
+                         "expected %d...", PT_SYSCALL_NR(regs), __NR_getpid);
+               goto fail;
+       }
+
+       n = ptrace(PTRACE_POKEUSR, pid, PT_SYSCALL_RET_OFFSET, os_getpid());
+       if(n < 0){
+               non_fatal("check_sysemu : failed to modify system call "
+                         "return");
+               goto fail;
+       }
 
        if (stop_ptraced_child(pid, stack, 0, 0) < 0)
                goto fail_stopped;