trap_user.c 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com)
  3. * Licensed under the GPL
  4. */
  5. #include <signal.h>
  6. #include <errno.h>
  7. #include "signal_user.h"
  8. #include "user_util.h"
  9. #include "kern_util.h"
  10. #include "task.h"
  11. #include "sigcontext.h"
  12. #include "skas.h"
  13. #include "ptrace_user.h"
  14. #include "sysdep/ptrace.h"
  15. #include "sysdep/ptrace_user.h"
  16. void sig_handler_common_skas(int sig, void *sc_ptr)
  17. {
  18. struct sigcontext *sc = sc_ptr;
  19. struct skas_regs *r;
  20. struct signal_info *info;
  21. int save_errno = errno;
  22. int save_user;
  23. /* This is done because to allow SIGSEGV to be delivered inside a SEGV
  24. * handler. This can happen in copy_user, and if SEGV is disabled,
  25. * the process will die.
  26. * XXX Figure out why this is better than SA_NODEFER
  27. */
  28. if(sig == SIGSEGV)
  29. change_sig(SIGSEGV, 1);
  30. r = &TASK_REGS(get_current())->skas;
  31. save_user = r->is_user;
  32. r->is_user = 0;
  33. if ( sig == SIGFPE || sig == SIGSEGV ||
  34. sig == SIGBUS || sig == SIGILL ||
  35. sig == SIGTRAP ) {
  36. GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
  37. }
  38. change_sig(SIGUSR1, 1);
  39. info = &sig_info[sig];
  40. if(!info->is_irq) unblock_signals();
  41. (*info->handler)(sig, (union uml_pt_regs *) r);
  42. errno = save_errno;
  43. r->is_user = save_user;
  44. }
  45. extern int ptrace_faultinfo;
  46. void user_signal(int sig, union uml_pt_regs *regs, int pid)
  47. {
  48. struct signal_info *info;
  49. int segv = ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
  50. (sig == SIGILL) || (sig == SIGTRAP));
  51. regs->skas.is_user = 1;
  52. if (segv)
  53. get_skas_faultinfo(pid, &regs->skas.faultinfo);
  54. info = &sig_info[sig];
  55. (*info->handler)(sig, regs);
  56. unblock_signals();
  57. }
  58. /*
  59. * Overrides for Emacs so that we follow Linus's tabbing style.
  60. * Emacs will notice this stuff at the end of the file and automatically
  61. * adjust the settings for this buffer only. This must remain at the end
  62. * of the file.
  63. * ---------------------------------------------------------------------------
  64. * Local variables:
  65. * c-file-style: "linux"
  66. * End:
  67. */