trap_user.c 1.4 KB

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