stub_segv.c 893 B

123456789101112131415161718192021222324252627282930
  1. /*
  2. * Copyright (C) 2004 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include <signal.h>
  6. #include <asm/sigcontext.h>
  7. #include <asm/unistd.h>
  8. #include "uml-config.h"
  9. #include "sysdep/sigcontext.h"
  10. #include "sysdep/faultinfo.h"
  11. void __attribute__ ((__section__ (".__syscall_stub")))
  12. stub_segv_handler(int sig)
  13. {
  14. struct sigcontext *sc = (struct sigcontext *) (&sig + 1);
  15. GET_FAULTINFO_FROM_SC(*((struct faultinfo *) UML_CONFIG_STUB_DATA),
  16. sc);
  17. __asm__("movl %0, %%eax ; int $0x80": : "g" (__NR_getpid));
  18. __asm__("movl %%eax, %%ebx ; movl %0, %%eax ; movl %1, %%ecx ;"
  19. "int $0x80": : "g" (__NR_kill), "g" (SIGUSR1));
  20. /* Load pointer to sigcontext into esp, since we need to leave
  21. * the stack in its original form when we do the sigreturn here, by
  22. * hand.
  23. */
  24. __asm__("mov %0,%%esp ; movl %1, %%eax ; "
  25. "int $0x80" : : "a" (sc), "g" (__NR_sigreturn));
  26. }