| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: linux_trap.c,v 1.8 2009/11/21 03:11:01 rmind Exp $ */ | | 1 | /* $NetBSD: linux_trap.c,v 1.9 2010/01/13 15:31:47 njoly Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2001 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Christos Zoulas. | | 8 | * by Christos Zoulas. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -24,27 +24,27 @@ | | | @@ -24,27 +24,27 @@ |
24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 24 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 25 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 26 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 27 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 28 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
29 | * POSSIBILITY OF SUCH DAMAGE. | | 29 | * POSSIBILITY OF SUCH DAMAGE. |
30 | */ | | 30 | */ |
31 | | | 31 | |
32 | /* | | 32 | /* |
33 | * 386 Trap and System call handling | | 33 | * 386 Trap and System call handling |
34 | */ | | 34 | */ |
35 | | | 35 | |
36 | #include <sys/cdefs.h> | | 36 | #include <sys/cdefs.h> |
37 | __KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.8 2009/11/21 03:11:01 rmind Exp $"); | | 37 | __KERNEL_RCSID(0, "$NetBSD: linux_trap.c,v 1.9 2010/01/13 15:31:47 njoly Exp $"); |
38 | | | 38 | |
39 | #include <sys/param.h> | | 39 | #include <sys/param.h> |
40 | #include <sys/systm.h> | | 40 | #include <sys/systm.h> |
41 | #include <sys/proc.h> | | 41 | #include <sys/proc.h> |
42 | #include <sys/sa.h> | | 42 | #include <sys/sa.h> |
43 | #include <sys/savar.h> | | 43 | #include <sys/savar.h> |
44 | #include <sys/acct.h> | | 44 | #include <sys/acct.h> |
45 | #include <sys/kernel.h> | | 45 | #include <sys/kernel.h> |
46 | #include <sys/signal.h> | | 46 | #include <sys/signal.h> |
47 | #include <sys/signalvar.h> | | 47 | #include <sys/signalvar.h> |
48 | #include <sys/syscall.h> | | 48 | #include <sys/syscall.h> |
49 | | | 49 | |
50 | #include <uvm/uvm_extern.h> | | 50 | #include <uvm/uvm_extern.h> |
| @@ -115,44 +115,42 @@ static const int linux_x86_vec_to_sig[] | | | @@ -115,44 +115,42 @@ static const int linux_x86_vec_to_sig[] |
115 | SIGSEGV, /* 8 LINUX_T_DOUBLE_FAULT */ | | 115 | SIGSEGV, /* 8 LINUX_T_DOUBLE_FAULT */ |
116 | SIGFPE, /* 9 LINUX_T_COPROC_SEG_OVERRUN */ | | 116 | SIGFPE, /* 9 LINUX_T_COPROC_SEG_OVERRUN */ |
117 | SIGSEGV, /* 10 LINUX_T_INVALID_TSS */ | | 117 | SIGSEGV, /* 10 LINUX_T_INVALID_TSS */ |
118 | SIGBUS, /* 11 LINUX_T_SEG_NOT_PRESENT */ | | 118 | SIGBUS, /* 11 LINUX_T_SEG_NOT_PRESENT */ |
119 | SIGBUS, /* 12 LINUX_T_STACK_SEG_FAULT */ | | 119 | SIGBUS, /* 12 LINUX_T_STACK_SEG_FAULT */ |
120 | SIGSEGV, /* 13 LINUX_T_GENERAL_PROT_FAULT */ | | 120 | SIGSEGV, /* 13 LINUX_T_GENERAL_PROT_FAULT */ |
121 | SIGSEGV, /* 14 LINUX_T_PAGE_FAULT */ | | 121 | SIGSEGV, /* 14 LINUX_T_PAGE_FAULT */ |
122 | /*resv*/SIGSEGV, /* 15 LINUX_T_SPURIOUS_INTERRUPT */ | | 122 | /*resv*/SIGSEGV, /* 15 LINUX_T_SPURIOUS_INTERRUPT */ |
123 | SIGFPE, /* 16 LINUX_T_COPROC_ERROR */ | | 123 | SIGFPE, /* 16 LINUX_T_COPROC_ERROR */ |
124 | SIGSEGV, /* 17 LINUX_T_ALIGN_CHECK */ | | 124 | SIGSEGV, /* 17 LINUX_T_ALIGN_CHECK */ |
125 | SIGSEGV /* 18 LINUX_T_MACHINE_CHECK */ | | 125 | SIGSEGV /* 18 LINUX_T_MACHINE_CHECK */ |
126 | }; | | 126 | }; |
127 | | | 127 | |
128 | #define ASIZE(a) (sizeof(a) / sizeof(a[0])) | | | |
129 | | | | |
130 | void | | 128 | void |
131 | linux_trapsignal(struct lwp *l, ksiginfo_t *ksi) | | 129 | linux_trapsignal(struct lwp *l, ksiginfo_t *ksi) |
132 | { | | 130 | { |
133 | | | 131 | |
134 | switch (ksi->ksi_signo) { | | 132 | switch (ksi->ksi_signo) { |
135 | case SIGILL: | | 133 | case SIGILL: |
136 | case SIGTRAP: | | 134 | case SIGTRAP: |
137 | case SIGIOT: | | 135 | case SIGIOT: |
138 | case SIGBUS: | | 136 | case SIGBUS: |
139 | case SIGFPE: | | 137 | case SIGFPE: |
140 | case SIGSEGV: | | 138 | case SIGSEGV: |
141 | KASSERT(KSI_TRAP_P(ksi)); | | 139 | KASSERT(KSI_TRAP_P(ksi)); |
142 | if (ksi->ksi_trap < ASIZE(trapno_to_x86_vec)) { | | 140 | if (ksi->ksi_trap < __arraycount(trapno_to_x86_vec)) { |
143 | ksiginfo_t nksi = *ksi; | | 141 | ksiginfo_t nksi = *ksi; |
144 | nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap]; | | 142 | nksi.ksi_trap = trapno_to_x86_vec[ksi->ksi_trap]; |
145 | if (nksi.ksi_trap < ASIZE(linux_x86_vec_to_sig)) { | | 143 | if (nksi.ksi_trap < __arraycount(linux_x86_vec_to_sig)) { |
146 | nksi.ksi_signo | | 144 | nksi.ksi_signo |
147 | = linux_x86_vec_to_sig[nksi.ksi_trap]; | | 145 | = linux_x86_vec_to_sig[nksi.ksi_trap]; |
148 | } else { | | 146 | } else { |
149 | uprintf("Unhandled sig type %d\n", | | 147 | uprintf("Unhandled sig type %d\n", |
150 | ksi->ksi_trap); | | 148 | ksi->ksi_trap); |
151 | } | | 149 | } |
152 | ksi = &nksi; | | 150 | ksi = &nksi; |
153 | } else { | | 151 | } else { |
154 | uprintf("Unhandled trap type %d\n", ksi->ksi_trap); | | 152 | uprintf("Unhandled trap type %d\n", ksi->ksi_trap); |
155 | } | | 153 | } |
156 | /*FALLTHROUGH*/ | | 154 | /*FALLTHROUGH*/ |
157 | default: | | 155 | default: |
158 | trapsignal(l, ksi); | | 156 | trapsignal(l, ksi); |