um: switch stub_segv_handler to SA_SIGINFO variant, get rid of magic crap in there
authorAl Viro <viro@ftp.linux.org.uk>
Thu, 18 Aug 2011 19:04:09 +0000 (20:04 +0100)
committerRichard Weinberger <richard@nod.at>
Wed, 2 Nov 2011 13:14:54 +0000 (14:14 +0100)
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Richard Weinberger <richard@nod.at>
arch/um/os-Linux/skas/process.c
arch/um/sys-x86/Makefile
arch/um/sys-x86/shared/sysdep/stub.h
arch/um/sys-x86/shared/sysdep/stub_32.h
arch/um/sys-x86/shared/sysdep/stub_64.h
arch/um/sys-x86/stub_segv.c [new file with mode: 0644]
arch/um/sys-x86/stub_segv_32.c [deleted file]
arch/um/sys-x86/stub_segv_64.c [deleted file]

index 2a72bfcd7aba3a4cec88a9c56d43425be6239b75..f481d745e231671826538fc66cc5fadfe6d53b7e 100644 (file)
@@ -255,8 +255,8 @@ static int userspace_tramp(void *stack)
 
                set_sigstack((void *) STUB_DATA, UM_KERN_PAGE_SIZE);
                sigemptyset(&sa.sa_mask);
-               sa.sa_flags = SA_ONSTACK | SA_NODEFER;
-               sa.sa_handler = (void *) v;
+               sa.sa_flags = SA_ONSTACK | SA_NODEFER | SA_SIGINFO;
+               sa.sa_sigaction = (void *) v;
                sa.sa_restorer = NULL;
                if (sigaction(SIGSEGV, &sa, NULL) < 0) {
                        printk(UM_KERN_ERR "userspace_tramp - setting SIGSEGV "
index 671de0b45dd87c29235dfa7cd208d298aa4b7f2f..81ab3484a430a740994f9eb8ba4b4fdb92854c3b 100644 (file)
@@ -10,7 +10,7 @@ endif
 
 obj-y = bug.o bugs_$(BITS).o delay_$(BITS).o fault.o ksyms.o ldt.o \
        ptrace_$(BITS).o ptrace_user.o setjmp_$(BITS).o signal_$(BITS).o \
-       stub_$(BITS).o stub_segv_$(BITS).o syscalls_$(BITS).o \
+       stub_$(BITS).o stub_segv.o syscalls_$(BITS).o \
        sys_call_table_$(BITS).o sysrq_$(BITS).o tls_$(BITS).o mem_$(BITS).o
 
 ifeq ($(CONFIG_X86_32),y)
index 13f523a3fcfaad2319496cc96b15454a57c56c84..bd161e300102c7a37cd8d6f9892ce3947fe62cc7 100644 (file)
@@ -1,5 +1,14 @@
+#include <asm/unistd.h>
+#include <sys/mman.h>
+#include <signal.h>
+#include "as-layout.h"
+#include "stub-data.h"
+
 #ifdef __i386__
 #include "stub_32.h"
 #else
 #include "stub_64.h"
 #endif
+
+extern void stub_segv_handler(int, siginfo_t *, void *);
+extern void stub_clone_handler(void);
index cca14d4ddf528ec126502c5cb884242b6c36f464..51fd256c75f00f8f268f171f50336fa2db8437bc 100644 (file)
@@ -6,14 +6,7 @@
 #ifndef __SYSDEP_STUB_H
 #define __SYSDEP_STUB_H
 
-#include <sys/mman.h>
 #include <asm/ptrace.h>
-#include <asm/unistd.h>
-#include "as-layout.h"
-#include "stub-data.h"
-
-extern void stub_segv_handler(int sig);
-extern void stub_clone_handler(void);
 
 #define STUB_SYSCALL_RET EAX
 #define STUB_MMAP_NR __NR_mmap2
index 922a5702c8d827be4a661a9fd075adc447847aa1..994df93c5ed34b712c416fe95e0e18779d7426ef 100644 (file)
@@ -6,14 +6,7 @@
 #ifndef __SYSDEP_STUB_H
 #define __SYSDEP_STUB_H
 
-#include <sys/mman.h>
-#include <asm/unistd.h>
 #include <sysdep/ptrace_user.h>
-#include "as-layout.h"
-#include "stub-data.h"
-
-extern void stub_segv_handler(int sig);
-extern void stub_clone_handler(void);
 
 #define STUB_SYSCALL_RET PT_INDEX(RAX)
 #define STUB_MMAP_NR __NR_mmap
diff --git a/arch/um/sys-x86/stub_segv.c b/arch/um/sys-x86/stub_segv.c
new file mode 100644 (file)
index 0000000..f62771c
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
+ * Licensed under the GPL
+ */
+
+#include "sysdep/stub.h"
+#include "sysdep/faultinfo.h"
+#include "sysdep/sigcontext.h"
+
+void __attribute__ ((__section__ (".__syscall_stub")))
+stub_segv_handler(int sig, siginfo_t *info, void *p)
+{
+       struct ucontext *uc = p;
+
+       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA),
+                             &uc->uc_mcontext);
+       trap_myself();
+}
+
diff --git a/arch/um/sys-x86/stub_segv_32.c b/arch/um/sys-x86/stub_segv_32.c
deleted file mode 100644 (file)
index 28ccf73..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-/*
- * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
- * Licensed under the GPL
- */
-
-#include "sysdep/stub.h"
-#include "sysdep/sigcontext.h"
-
-void __attribute__ ((__section__ (".__syscall_stub")))
-stub_segv_handler(int sig)
-{
-       struct sigcontext *sc = (struct sigcontext *) (&sig + 1);
-
-       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), sc);
-
-       trap_myself();
-}
diff --git a/arch/um/sys-x86/stub_segv_64.c b/arch/um/sys-x86/stub_segv_64.c
deleted file mode 100644 (file)
index ced051a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/*
- * Copyright (C) 2004 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
- * Licensed under the GPL
- */
-
-#include <signal.h>
-#include "as-layout.h"
-#include "sysdep/stub.h"
-#include "sysdep/faultinfo.h"
-#include "sysdep/sigcontext.h"
-
-void __attribute__ ((__section__ (".__syscall_stub")))
-stub_segv_handler(int sig)
-{
-       struct ucontext *uc;
-
-       __asm__ __volatile__("movq %%rdx, %0" : "=g" (uc) :);
-       GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA),
-                             &uc->uc_mcontext);
-       trap_myself();
-}
-