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