trap_user.c 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 "sysdep/ptrace.h"
  8. #include "signal_user.h"
  9. #include "user_util.h"
  10. #include "kern_util.h"
  11. #include "task.h"
  12. #include "sigcontext.h"
  13. void sig_handler_common_skas(int sig, void *sc_ptr)
  14. {
  15. struct sigcontext *sc = sc_ptr;
  16. struct skas_regs *r;
  17. struct signal_info *info;
  18. int save_errno = errno;
  19. int save_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. * XXX Figure out why this is better than SA_NODEFER
  24. */
  25. if(sig == SIGSEGV)
  26. change_sig(SIGSEGV, 1);
  27. r = &TASK_REGS(get_current())->skas;
  28. save_user = r->is_user;
  29. r->is_user = 0;
  30. r->fault_addr = SC_FAULT_ADDR(sc);
  31. r->fault_type = SC_FAULT_TYPE(sc);
  32. r->trap_type = SC_TRAP_TYPE(sc);
  33. change_sig(SIGUSR1, 1);
  34. info = &sig_info[sig];
  35. if(!info->is_irq) unblock_signals();
  36. (*info->handler)(sig, (union uml_pt_regs *) r);
  37. errno = save_errno;
  38. r->is_user = save_user;
  39. }
  40. void user_signal(int sig, union uml_pt_regs *regs)
  41. {
  42. struct signal_info *info;
  43. regs->skas.is_user = 1;
  44. regs->skas.fault_addr = 0;
  45. regs->skas.fault_type = 0;
  46. regs->skas.trap_type = 0;
  47. info = &sig_info[sig];
  48. (*info->handler)(sig, regs);
  49. unblock_signals();
  50. }
  51. /*
  52. * Overrides for Emacs so that we follow Linus's tabbing style.
  53. * Emacs will notice this stuff at the end of the file and automatically
  54. * adjust the settings for this buffer only. This must remain at the end
  55. * of the file.
  56. * ---------------------------------------------------------------------------
  57. * Local variables:
  58. * c-file-style: "linux"
  59. * End:
  60. */