X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fum%2Fos-Linux%2Fprocess.c;fp=arch%2Fum%2Fos-Linux%2Fprocess.c;h=a0afd106f41e723425e85649eebe7cab6ca853fb;hb=64ba3f394c830ec48a1c31b53dcae312c56f1604;hp=c8bf7727666258d23c7aec8de67d7bcbff440bcf;hpb=be1e6109ac94a859551f8e1774eb9a8469fe055c;p=linux-2.6.git diff --git a/arch/um/os-Linux/process.c b/arch/um/os-Linux/process.c index c8bf77276..a0afd106f 100644 --- a/arch/um/os-Linux/process.c +++ b/arch/um/os-Linux/process.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include "ptrace_user.h" #include "os.h" #include "user.h" @@ -21,7 +21,6 @@ #include "kern_util.h" #include "longjmp.h" #include "skas_ptrace.h" -#include "kern_constants.h" #define ARBITRARY_ADDR -1 #define FAILURE_PID -1 @@ -143,7 +142,7 @@ void os_usr1_process(int pid) int os_getpid(void) { - return syscall(__NR_getpid); + return(syscall(__NR_getpid)); } int os_getpgrp(void) @@ -187,55 +186,6 @@ int os_unmap_memory(void *addr, int len) return(0); } -#ifndef MADV_REMOVE -#define MADV_REMOVE KERNEL_MADV_REMOVE -#endif - -int os_drop_memory(void *addr, int length) -{ - int err; - - err = madvise(addr, length, MADV_REMOVE); - if(err < 0) - err = -errno; - return err; -} - -int can_drop_memory(void) -{ - void *addr; - int fd, ok = 0; - - printk("Checking host MADV_REMOVE support..."); - fd = create_mem_file(UM_KERN_PAGE_SIZE); - if(fd < 0){ - printk("Creating test memory file failed, err = %d\n", -fd); - goto out; - } - - addr = mmap64(NULL, UM_KERN_PAGE_SIZE, PROT_READ | PROT_WRITE, - MAP_SHARED, fd, 0); - if(addr == MAP_FAILED){ - printk("Mapping test memory file failed, err = %d\n", -errno); - goto out_close; - } - - if(madvise(addr, UM_KERN_PAGE_SIZE, MADV_REMOVE) != 0){ - printk("MADV_REMOVE failed, err = %d\n", -errno); - goto out_unmap; - } - - printk("OK\n"); - ok = 1; - -out_unmap: - munmap(addr, UM_KERN_PAGE_SIZE); -out_close: - close(fd); -out: - return ok; -} - void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) { int flags = 0, pages; @@ -248,35 +198,36 @@ void init_new_thread_stack(void *sig_stack, void (*usr1_handler)(int)) if(usr1_handler) set_handler(SIGUSR1, usr1_handler, flags, -1); } -void init_new_thread_signals(void) +void init_new_thread_signals(int altstack) { - set_handler(SIGSEGV, (__sighandler_t) sig_handler, SA_ONSTACK, + int flags = altstack ? SA_ONSTACK : 0; + + set_handler(SIGSEGV, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); - set_handler(SIGTRAP, (__sighandler_t) sig_handler, SA_ONSTACK, + set_handler(SIGTRAP, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); - set_handler(SIGFPE, (__sighandler_t) sig_handler, SA_ONSTACK, + set_handler(SIGFPE, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); - set_handler(SIGILL, (__sighandler_t) sig_handler, SA_ONSTACK, + set_handler(SIGILL, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); - set_handler(SIGBUS, (__sighandler_t) sig_handler, SA_ONSTACK, + set_handler(SIGBUS, (__sighandler_t) sig_handler, flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); set_handler(SIGUSR2, (__sighandler_t) sig_handler, - SA_ONSTACK, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, - -1); + flags, SIGUSR1, SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, -1); signal(SIGHUP, SIG_IGN); - init_irq_signals(1); + init_irq_signals(altstack); } int run_kernel_thread(int (*fn)(void *), void *arg, void **jmp_ptr) { - jmp_buf buf; - int n; + sigjmp_buf buf; + int n, enable; *jmp_ptr = &buf; - n = UML_SETJMP(&buf); + n = UML_SIGSETJMP(&buf, enable); if(n != 0) - return n; + return(n); (*fn)(arg); - return 0; + return(0); }