trap_user.c 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /*
  2. * Copyright (C) 2002 Jeff Dike (jdike@karaya.com)
  3. * Licensed under the GPL
  4. */
  5. #include <stdlib.h>
  6. #include <errno.h>
  7. #include <signal.h>
  8. #include "sysdep/ptrace.h"
  9. #include "sysdep/sigcontext.h"
  10. #include "signal_user.h"
  11. #include "user_util.h"
  12. #include "kern_util.h"
  13. #include "task.h"
  14. #include "tt.h"
  15. void sig_handler_common_tt(int sig, void *sc_ptr)
  16. {
  17. struct sigcontext *sc = sc_ptr;
  18. struct tt_regs save_regs, *r;
  19. struct signal_info *info;
  20. int save_errno = errno, is_user;
  21. /* This is done because to allow SIGSEGV to be delivered inside a SEGV
  22. * handler. This can happen in copy_user, and if SEGV is disabled,
  23. * the process will die.
  24. */
  25. if(sig == SIGSEGV)
  26. change_sig(SIGSEGV, 1);
  27. r = &TASK_REGS(get_current())->tt;
  28. if ( sig == SIGFPE || sig == SIGSEGV ||
  29. sig == SIGBUS || sig == SIGILL ||
  30. sig == SIGTRAP ) {
  31. GET_FAULTINFO_FROM_SC(r->faultinfo, sc);
  32. }
  33. save_regs = *r;
  34. is_user = user_context(SC_SP(sc));
  35. r->sc = sc;
  36. if(sig != SIGUSR2)
  37. r->syscall = -1;
  38. info = &sig_info[sig];
  39. if(!info->is_irq) unblock_signals();
  40. (*info->handler)(sig, (union uml_pt_regs *) r);
  41. if(is_user){
  42. interrupt_end();
  43. block_signals();
  44. set_user_mode(NULL);
  45. }
  46. *r = save_regs;
  47. errno = save_errno;
  48. }
  49. /*
  50. * Overrides for Emacs so that we follow Linus's tabbing style.
  51. * Emacs will notice this stuff at the end of the file and automatically
  52. * adjust the settings for this buffer only. This must remain at the end
  53. * of the file.
  54. * ---------------------------------------------------------------------------
  55. * Local variables:
  56. * c-file-style: "linux"
  57. * End:
  58. */