blob: b3999cb76bfd2eb004ba5f8be32fec82e38beeeb [file] [log] [blame]
Jeff Diked67b5692005-07-07 17:56:49 -07001/*
2 * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
3 * Licensed under the GPL
4 */
5
Jeff Dike17d46972005-11-21 21:32:09 -08006#include <signal.h>
7#include <sys/select.h> /* The only way I can see to get sigset_t */
Jeff Diked67b5692005-07-07 17:56:49 -07008#include <asm/unistd.h>
Jeff Dike54ae36f2007-10-16 01:27:33 -07009#include "as-layout.h"
Jeff Diked67b5692005-07-07 17:56:49 -070010#include "uml-config.h"
Jeff Dike17d46972005-11-21 21:32:09 -080011#include "sysdep/stub.h"
Jeff Diked67b5692005-07-07 17:56:49 -070012#include "sysdep/sigcontext.h"
13#include "sysdep/faultinfo.h"
14
15void __attribute__ ((__section__ (".__syscall_stub")))
16stub_segv_handler(int sig)
17{
18 struct sigcontext *sc = (struct sigcontext *) (&sig + 1);
Jeff Dike17d46972005-11-21 21:32:09 -080019 int pid;
Jeff Diked67b5692005-07-07 17:56:49 -070020
Jeff Dike54ae36f2007-10-16 01:27:33 -070021 GET_FAULTINFO_FROM_SC(*((struct faultinfo *) STUB_DATA), sc);
Jeff Diked67b5692005-07-07 17:56:49 -070022
Jeff Dike17d46972005-11-21 21:32:09 -080023 pid = stub_syscall0(__NR_getpid);
24 stub_syscall2(__NR_kill, pid, SIGUSR1);
25
Bodo Stroesser9057e9d2005-07-28 21:16:06 -070026 /* Load pointer to sigcontext into esp, since we need to leave
Jeff Diked67b5692005-07-07 17:56:49 -070027 * the stack in its original form when we do the sigreturn here, by
28 * hand.
29 */
Jeff Dikefb30d642006-04-18 22:21:44 -070030 __asm__ __volatile__("mov %0,%%esp ; movl %1, %%eax ; "
31 "int $0x80" : : "a" (sc), "g" (__NR_sigreturn));
Jeff Diked67b5692005-07-07 17:56:49 -070032}