From: Bodo Stroesser This patch changes stub_segv_handler for i386 (and s390 later) to simplify it and save some syscalls. My previous patch already left SIGSEGV unmasked while stub_segv_handler is running. Now, we do no longer mask *any* signals if stub_segv_handler runs. SIG(RT)ALRM already is handled by wait_stub_done(), the other signals (SIGIO, SIGWINCH) must not happen. stub_segv_handler for i386 (and s390) now stop *inside* stub_segv_handler using "int3" and do no longer call sigreturn. For this, SIGUSR1 no longer should be blocked. So i386 (and s390) set: #define ARCH_STUB_SEGV_MASK_SIGNAL -1 while x86_64 sets #define ARCH_STUB_SEGV_MASK_SIGNAL SIGUSR1 Thus, x86_64 further uses sigreturn at the end of its stub_segv_handler to avoid the RCX problem. As soon as that problem is solved, x86_64 also might stop using "int3". Using the change, we no longer need to care about correct stack pointer for sigreturn, which would cause some nasty code on s390. Signed-off-by: Bodo Stroesser --- diff -puN arch/um/os-Linux/skas/process.c~tune-stub_segv_handler arch/um/os-Linux/skas/process.c --- linux-2.6.12-rc4/arch/um/os-Linux/skas/process.c~tune-stub_segv_handler 2005-07-15 14:12:15.240075682 +0200 +++ linux-2.6.12-rc4-root/arch/um/os-Linux/skas/process.c 2005-07-15 14:12:15.252071977 +0200 @@ -183,8 +183,7 @@ static int userspace_tramp(void *stack) set_sigstack((void *) UML_CONFIG_STUB_DATA, page_size()); set_handler(SIGSEGV, (void *) v, SA_ONSTACK | SA_NOMASK, - SIGIO, SIGWINCH, SIGALRM, SIGVTALRM, - SIGUSR1, -1); + ARCH_STUB_SEGV_MASK_SIGNAL, -1); } os_stop_process(os_getpid()); diff -puN arch/um/sys-i386/stub_segv.c~tune-stub_segv_handler arch/um/sys-i386/stub_segv.c --- linux-2.6.12-rc4/arch/um/sys-i386/stub_segv.c~tune-stub_segv_handler 2005-07-15 14:12:15.242075065 +0200 +++ linux-2.6.12-rc4-root/arch/um/sys-i386/stub_segv.c 2005-07-15 14:13:17.652802252 +0200 @@ -19,13 +19,8 @@ stub_segv_handler(int sig) GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA), sc); - __asm__("movl %0, %%eax ; int $0x80": : "g" (__NR_getpid)); - __asm__("movl %%eax, %%ebx ; movl %0, %%eax ; movl %1, %%ecx ;" - "int $0x80": : "g" (__NR_kill), "g" (SIGUSR1)); - /* Load pointer to sigcontext into esp, since we need to leave - * the stack in its original form when we do the sigreturn here, by - * hand. + /* Our work is done, just stop the handler. + * Registers will be restored later, if userspace() restarts us. */ - __asm__("mov %0,%%esp ; movl %1, %%eax ; " - "int $0x80" : : "a" (sc), "g" (__NR_sigreturn)); + __asm__("int3"); } diff -puN arch/um/include/sysdep-i386/faultinfo.h~tune-stub_segv_handler arch/um/include/sysdep-i386/faultinfo.h --- linux-2.6.12-rc4/arch/um/include/sysdep-i386/faultinfo.h~tune-stub_segv_handler 2005-07-15 14:12:15.245074138 +0200 +++ linux-2.6.12-rc4-root/arch/um/include/sysdep-i386/faultinfo.h 2005-07-15 14:12:15.253071669 +0200 @@ -26,4 +26,6 @@ struct faultinfo { #define PTRACE_FULL_FAULTINFO 0 +#define ARCH_STUB_SEGV_MASK_SIGNAL -1 + #endif diff -puN arch/um/include/sysdep-x86_64/faultinfo.h~tune-stub_segv_handler arch/um/include/sysdep-x86_64/faultinfo.h --- linux-2.6.12-rc4/arch/um/include/sysdep-x86_64/faultinfo.h~tune-stub_segv_handler 2005-07-15 14:12:15.247073521 +0200 +++ linux-2.6.12-rc4-root/arch/um/include/sysdep-x86_64/faultinfo.h 2005-07-15 14:12:15.253071669 +0200 @@ -26,4 +26,6 @@ struct faultinfo { #define PTRACE_FULL_FAULTINFO 1 +#define ARCH_STUB_SEGV_MASK_SIGNAL SIGUSR1 + #endif _