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 | |
Jeff Dike | 17d4697 | 2005-11-21 21:32:09 -0800 | [diff] [blame] | 6 | #include <signal.h> |
| 7 | #include <sys/select.h> /* The only way I can see to get sigset_t */ |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 8 | #include <asm/unistd.h> |
Jeff Dike | 54ae36f | 2007-10-16 01:27:33 -0700 | [diff] [blame] | 9 | #include "as-layout.h" |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 10 | #include "uml-config.h" |
Jeff Dike | 17d4697 | 2005-11-21 21:32:09 -0800 | [diff] [blame] | 11 | #include "sysdep/stub.h" |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 12 | #include "sysdep/sigcontext.h" |
| 13 | #include "sysdep/faultinfo.h" |
| 14 | |
| 15 | void __attribute__ ((__section__ (".__syscall_stub"))) |
| 16 | stub_segv_handler(int sig) |
| 17 | { |
| 18 | struct sigcontext *sc = (struct sigcontext *) (&sig + 1); |
Jeff Dike | 17d4697 | 2005-11-21 21:32:09 -0800 | [diff] [blame] | 19 | int pid; |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 20 | |
Jeff Dike | 54ae36f | 2007-10-16 01:27:33 -0700 | [diff] [blame] | 21 | GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), sc); |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 22 | |
Jeff Dike | 17d4697 | 2005-11-21 21:32:09 -0800 | [diff] [blame] | 23 | pid = stub_syscall0(__NR_getpid); |
| 24 | stub_syscall2(__NR_kill, pid, SIGUSR1); |
| 25 | |
Bodo Stroesser | 9057e9d | 2005-07-28 21:16:06 -0700 | [diff] [blame] | 26 | /* Load pointer to sigcontext into esp, since we need to leave |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 27 | * the stack in its original form when we do the sigreturn here, by |
| 28 | * hand. |
| 29 | */ |
Jeff Dike | fb30d64 | 2006-04-18 22:21:44 -0700 | [diff] [blame] | 30 | __asm__ __volatile__("mov %0,%%esp ; movl %1, %%eax ; " |
| 31 | "int $0x80" : : "a" (sc), "g" (__NR_sigreturn)); |
Jeff Dike | d67b569 | 2005-07-07 17:56:49 -0700 | [diff] [blame] | 32 | } |