stub_segv.c 975 B

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