]> 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 5178eba9afa54fa779ab3af327e82259768d7fbf..46f613975c199ebc2a323b14c399074190c9cd3f 100644 (file)
 #include <sys/time.h>
 #include <sys/wait.h>
 #include <sys/mman.h>
+#include <sys/resource.h>
 #include <asm/unistd.h>
 #include <asm/page.h>
 #include <sys/types.h>
-#include "user_util.h"
 #include "kern_util.h"
 #include "user.h"
 #include "signal_kern.h"
@@ -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;
@@ -329,8 +338,32 @@ static void __init check_ptrace(void)
 
 extern void check_tmpexec(void);
 
-void os_early_checks(void)
+static void __init check_coredump_limit(void)
+{
+       struct rlimit lim;
+       int err = getrlimit(RLIMIT_CORE, &lim);
+
+       if(err){
+               perror("Getting core dump limit");
+               return;
+       }
+
+       printf("Core dump limits :\n\tsoft - ");
+       if(lim.rlim_cur == RLIM_INFINITY)
+               printf("NONE\n");
+       else printf("%lu\n", lim.rlim_cur);
+
+       printf("\thard - ");
+       if(lim.rlim_max == RLIM_INFINITY)
+               printf("NONE\n");
+       else printf("%lu\n", lim.rlim_max);
+}
+
+void __init os_early_checks(void)
 {
+       /* Print out the core dump limits early */
+       check_coredump_limit();
+
        check_ptrace();
 
        /* Need to check this early because mmapping happens before the
@@ -528,148 +561,3 @@ int __init parse_iomem(char *str, int *add)
  out:
        return 1;
 }
-
-
-/* Changed during early boot */
-int pty_output_sigio = 0;
-int pty_close_sigio = 0;
-
-/* Used as a flag during SIGIO testing early in boot */
-static volatile int got_sigio = 0;
-
-static void __init handler(int sig)
-{
-       got_sigio = 1;
-}
-
-struct openpty_arg {
-       int master;
-       int slave;
-       int err;
-};
-
-static void openpty_cb(void *arg)
-{
-       struct openpty_arg *info = arg;
-
-       info->err = 0;
-       if(openpty(&info->master, &info->slave, NULL, NULL, NULL))
-               info->err = -errno;
-}
-
-static int async_pty(int master, int slave)
-{
-       int flags;
-
-       flags = fcntl(master, F_GETFL);
-       if(flags < 0)
-               return -errno;
-
-       if((fcntl(master, F_SETFL, flags | O_NONBLOCK | O_ASYNC) < 0) ||
-          (fcntl(master, F_SETOWN, os_getpid()) < 0))
-               return -errno;
-
-       if((fcntl(slave, F_SETFL, flags | O_NONBLOCK) < 0))
-               return -errno;
-
-       return(0);
-}
-
-static void __init check_one_sigio(void (*proc)(int, int))
-{
-       struct sigaction old, new;
-       struct openpty_arg pty = { .master = -1, .slave = -1 };
-       int master, slave, err;
-
-       initial_thread_cb(openpty_cb, &pty);
-       if(pty.err){
-               printk("openpty failed, errno = %d\n", -pty.err);
-               return;
-       }
-
-       master = pty.master;
-       slave = pty.slave;
-
-       if((master == -1) || (slave == -1)){
-               printk("openpty failed to allocate a pty\n");
-               return;
-       }
-
-       /* Not now, but complain so we now where we failed. */
-       err = raw(master);
-       if (err < 0)
-               panic("check_sigio : __raw failed, errno = %d\n", -err);
-
-       err = async_pty(master, slave);
-       if(err < 0)
-               panic("tty_fds : sigio_async failed, err = %d\n", -err);
-
-       if(sigaction(SIGIO, NULL, &old) < 0)
-               panic("check_sigio : sigaction 1 failed, errno = %d\n", errno);
-       new = old;
-       new.sa_handler = handler;
-       if(sigaction(SIGIO, &new, NULL) < 0)
-               panic("check_sigio : sigaction 2 failed, errno = %d\n", errno);
-
-       got_sigio = 0;
-       (*proc)(master, slave);
-
-       close(master);
-       close(slave);
-
-       if(sigaction(SIGIO, &old, NULL) < 0)
-               panic("check_sigio : sigaction 3 failed, errno = %d\n", errno);
-}
-
-static void tty_output(int master, int slave)
-{
-       int n;
-       char buf[512];
-
-       printk("Checking that host ptys support output SIGIO...");
-
-       memset(buf, 0, sizeof(buf));
-
-       while(os_write_file(master, buf, sizeof(buf)) > 0) ;
-       if(errno != EAGAIN)
-               panic("check_sigio : write failed, errno = %d\n", errno);
-       while(((n = os_read_file(slave, buf, sizeof(buf))) > 0) && !got_sigio) ;
-
-       if(got_sigio){
-               printk("Yes\n");
-               pty_output_sigio = 1;
-       }
-       else if(n == -EAGAIN) printk("No, enabling workaround\n");
-       else panic("check_sigio : read failed, err = %d\n", n);
-}
-
-static void tty_close(int master, int slave)
-{
-       printk("Checking that host ptys support SIGIO on close...");
-
-       close(slave);
-       if(got_sigio){
-               printk("Yes\n");
-               pty_close_sigio = 1;
-       }
-       else printk("No, enabling workaround\n");
-}
-
-void __init check_sigio(void)
-{
-       if((os_access("/dev/ptmx", OS_ACC_R_OK) < 0) &&
-          (os_access("/dev/ptyp0", OS_ACC_R_OK) < 0)){
-               printk("No pseudo-terminals available - skipping pty SIGIO "
-                      "check\n");
-               return;
-       }
-       check_one_sigio(tty_output);
-       check_one_sigio(tty_close);
-}
-
-void os_check_bugs(void)
-{
-       check_ptrace();
-       check_sigio();
-}
-