trap_user.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. if (segv)
  52. get_skas_faultinfo(pid, &regs->skas.faultinfo);
  53. info = &sig_info[sig];
  54. (*info->handler)(sig, regs);
  55. unblock_signals();
  56. }
  57. /*
  58. * Overrides for Emacs so that we follow Linus's tabbing style.
  59. * Emacs will notice this stuff at the end of the file and automatically
  60. * adjust the settings for this buffer only. This must remain at the end
  61. * of the file.
  62. * ---------------------------------------------------------------------------
  63. * Local variables:
  64. * c-file-style: "linux"
  65. * End:
  66. */