trap.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * Copyright (C) 2002 - 2007 Jeff Dike (jdike@{addtoit,linux.intel}.com)
  3. * Licensed under the GPL
  4. */
  5. #if 0
  6. #include "kern_util.h"
  7. #include "skas.h"
  8. #include "ptrace_user.h"
  9. #include "sysdep/ptrace_user.h"
  10. #endif
  11. #include <errno.h>
  12. #include <signal.h>
  13. #include "sysdep/ptrace.h"
  14. #include "kern_constants.h"
  15. #include "as-layout.h"
  16. #include "os.h"
  17. #include "sigcontext.h"
  18. #include "task.h"
  19. static struct uml_pt_regs ksig_regs[UM_NR_CPUS];
  20. void sig_handler_common_skas(int sig, void *sc_ptr)
  21. {
  22. struct sigcontext *sc = sc_ptr;
  23. struct uml_pt_regs *r;
  24. void (*handler)(int, struct uml_pt_regs *);
  25. int save_user, save_errno = errno;
  26. /*
  27. * This is done because to allow SIGSEGV to be delivered inside a SEGV
  28. * handler. This can happen in copy_user, and if SEGV is disabled,
  29. * the process will die.
  30. * XXX Figure out why this is better than SA_NODEFER
  31. */
  32. if (sig == SIGSEGV) {
  33. change_sig(SIGSEGV, 1);
  34. /*
  35. * For segfaults, we want the data from the
  36. * sigcontext. In this case, we don't want to mangle
  37. * the process registers, so use a static set of
  38. * registers. For other signals, the process
  39. * registers are OK.
  40. */
  41. r = &ksig_regs[cpu()];
  42. copy_sc(r, sc_ptr);
  43. }
  44. else r = TASK_REGS(get_current());
  45. save_user = r->is_user;
  46. r->is_user = 0;
  47. if ((sig == SIGFPE) || (sig == SIGSEGV) || (sig == SIGBUS) ||
  48. (sig == SIGILL) || (sig == SIGTRAP))
  49. GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
  50. change_sig(SIGUSR1, 1);
  51. handler = sig_info[sig];
  52. /* unblock SIGVTALRM, SIGIO if sig isn't IRQ signal */
  53. if ((sig != SIGIO) && (sig != SIGWINCH) && (sig != SIGVTALRM))
  54. unblock_signals();
  55. handler(sig, r);
  56. errno = save_errno;
  57. r->is_user = save_user;
  58. }