Merge ../to-linus-stable/
[pandora-kernel.git] / arch / um / sys-x86_64 / stub_segv.c
1 /*
2  * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3  * Licensed under the GPL
4  */
5
6 #include <signal.h>
7 #include <linux/compiler.h>
8 #include <asm/unistd.h>
9 #include "uml-config.h"
10 #include "sysdep/sigcontext.h"
11 #include "sysdep/faultinfo.h"
12
13 void __attribute__ ((__section__ (".__syscall_stub")))
14 stub_segv_handler(int sig)
15 {
16         struct ucontext *uc;
17
18         __asm__("movq %%rdx, %0" : "=g" (uc) :);
19         GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
20                               &uc->uc_mcontext);
21
22         __asm__("movq %0, %%rax ; syscall": : "g" (__NR_getpid));
23         __asm__("movq %%rax, %%rdi ; movq %0, %%rax ; movq %1, %%rsi ;"
24                 "syscall": : "g" (__NR_kill), "g" (SIGUSR1));
25         /* Two popqs to restore the stack to the state just before entering
26          * the handler, one pops the return address, the other pops the frame
27          * pointer.
28          */
29         __asm__("popq %%rax ; popq %%rax ; movq %0, %%rax ; syscall" : : "g"
30                 (__NR_rt_sigreturn));
31 }