Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (C) 2002 - 2003 Jeff Dike (jdike@addtoit.com) |
| 3 | * Licensed under the GPL |
| 4 | */ |
| 5 | |
| 6 | #include <signal.h> |
| 7 | #include <errno.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 "sigcontext.h" |
| 14 | |
| 15 | void sig_handler_common_skas(int sig, void *sc_ptr) |
| 16 | { |
| 17 | struct sigcontext *sc = sc_ptr; |
| 18 | struct skas_regs *r; |
| 19 | struct signal_info *info; |
| 20 | int save_errno = errno; |
| 21 | int save_user; |
| 22 | |
| 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 | |
| 31 | r = &TASK_REGS(get_current())->skas; |
| 32 | save_user = r->is_user; |
| 33 | r->is_user = 0; |
| 34 | r->fault_addr = SC_FAULT_ADDR(sc); |
| 35 | r->fault_type = SC_FAULT_TYPE(sc); |
| 36 | r->trap_type = SC_TRAP_TYPE(sc); |
| 37 | |
| 38 | change_sig(SIGUSR1, 1); |
| 39 | info = &sig_info[sig]; |
| 40 | if(!info->is_irq) unblock_signals(); |
| 41 | |
| 42 | (*info->handler)(sig, (union uml_pt_regs *) r); |
| 43 | |
| 44 | errno = save_errno; |
| 45 | r->is_user = save_user; |
| 46 | } |
| 47 | |
| 48 | void user_signal(int sig, union uml_pt_regs *regs) |
| 49 | { |
| 50 | struct signal_info *info; |
| 51 | |
| 52 | regs->skas.is_user = 1; |
| 53 | regs->skas.fault_addr = 0; |
| 54 | regs->skas.fault_type = 0; |
| 55 | regs->skas.trap_type = 0; |
| 56 | info = &sig_info[sig]; |
| 57 | (*info->handler)(sig, regs); |
| 58 | |
| 59 | unblock_signals(); |
| 60 | } |
| 61 | |
| 62 | /* |
| 63 | * Overrides for Emacs so that we follow Linus's tabbing style. |
| 64 | * Emacs will notice this stuff at the end of the file and automatically |
| 65 | * adjust the settings for this buffer only. This must remain at the end |
| 66 | * of the file. |
| 67 | * --------------------------------------------------------------------------- |
| 68 | * Local variables: |
| 69 | * c-file-style: "linux" |
| 70 | * End: |
| 71 | */ |