stub_segv.c 869 B

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