root / cpu-exec.c @ 3e11db9a
History | View | Annotate | Download (33.2 kB)
1 | 7d13299d | bellard | /*
|
---|---|---|---|
2 | 7d13299d | bellard | * i386 emulator main execution loop
|
3 | 7d13299d | bellard | *
|
4 | 7d13299d | bellard | * Copyright (c) 2003 Fabrice Bellard
|
5 | 7d13299d | bellard | *
|
6 | 3ef693a0 | bellard | * This library is free software; you can redistribute it and/or
|
7 | 3ef693a0 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | 3ef693a0 | bellard | * License as published by the Free Software Foundation; either
|
9 | 3ef693a0 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | 7d13299d | bellard | *
|
11 | 3ef693a0 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | 3ef693a0 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | 3ef693a0 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | 3ef693a0 | bellard | * Lesser General Public License for more details.
|
15 | 7d13299d | bellard | *
|
16 | 3ef693a0 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 3ef693a0 | bellard | * License along with this library; if not, write to the Free Software
|
18 | 3ef693a0 | bellard | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
19 | 7d13299d | bellard | */
|
20 | e4533c7a | bellard | #include "config.h" |
21 | 93ac68bc | bellard | #include "exec.h" |
22 | 956034d7 | bellard | #include "disas.h" |
23 | 7d13299d | bellard | |
24 | fbf9eeb3 | bellard | #if !defined(CONFIG_SOFTMMU)
|
25 | fbf9eeb3 | bellard | #undef EAX
|
26 | fbf9eeb3 | bellard | #undef ECX
|
27 | fbf9eeb3 | bellard | #undef EDX
|
28 | fbf9eeb3 | bellard | #undef EBX
|
29 | fbf9eeb3 | bellard | #undef ESP
|
30 | fbf9eeb3 | bellard | #undef EBP
|
31 | fbf9eeb3 | bellard | #undef ESI
|
32 | fbf9eeb3 | bellard | #undef EDI
|
33 | fbf9eeb3 | bellard | #undef EIP
|
34 | fbf9eeb3 | bellard | #include <signal.h> |
35 | fbf9eeb3 | bellard | #include <sys/ucontext.h> |
36 | fbf9eeb3 | bellard | #endif
|
37 | fbf9eeb3 | bellard | |
38 | 36bdbe54 | bellard | int tb_invalidated_flag;
|
39 | 36bdbe54 | bellard | |
40 | dc99065b | bellard | //#define DEBUG_EXEC
|
41 | 9de5e440 | bellard | //#define DEBUG_SIGNAL
|
42 | 7d13299d | bellard | |
43 | 93ac68bc | bellard | #if defined(TARGET_ARM) || defined(TARGET_SPARC)
|
44 | e4533c7a | bellard | /* XXX: unify with i386 target */
|
45 | e4533c7a | bellard | void cpu_loop_exit(void) |
46 | e4533c7a | bellard | { |
47 | e4533c7a | bellard | longjmp(env->jmp_env, 1);
|
48 | e4533c7a | bellard | } |
49 | e4533c7a | bellard | #endif
|
50 | e4533c7a | bellard | |
51 | fbf9eeb3 | bellard | /* exit the current TB from a signal handler. The host registers are
|
52 | fbf9eeb3 | bellard | restored in a state compatible with the CPU emulator
|
53 | fbf9eeb3 | bellard | */
|
54 | fbf9eeb3 | bellard | void cpu_resume_from_signal(CPUState *env1, void *puc) |
55 | fbf9eeb3 | bellard | { |
56 | fbf9eeb3 | bellard | #if !defined(CONFIG_SOFTMMU)
|
57 | fbf9eeb3 | bellard | struct ucontext *uc = puc;
|
58 | fbf9eeb3 | bellard | #endif
|
59 | fbf9eeb3 | bellard | |
60 | fbf9eeb3 | bellard | env = env1; |
61 | fbf9eeb3 | bellard | |
62 | fbf9eeb3 | bellard | /* XXX: restore cpu registers saved in host registers */
|
63 | fbf9eeb3 | bellard | |
64 | fbf9eeb3 | bellard | #if !defined(CONFIG_SOFTMMU)
|
65 | fbf9eeb3 | bellard | if (puc) {
|
66 | fbf9eeb3 | bellard | /* XXX: use siglongjmp ? */
|
67 | fbf9eeb3 | bellard | sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
|
68 | fbf9eeb3 | bellard | } |
69 | fbf9eeb3 | bellard | #endif
|
70 | fbf9eeb3 | bellard | longjmp(env->jmp_env, 1);
|
71 | fbf9eeb3 | bellard | } |
72 | fbf9eeb3 | bellard | |
73 | 7d13299d | bellard | /* main execution loop */
|
74 | 7d13299d | bellard | |
75 | e4533c7a | bellard | int cpu_exec(CPUState *env1)
|
76 | 7d13299d | bellard | { |
77 | e4533c7a | bellard | int saved_T0, saved_T1, saved_T2;
|
78 | e4533c7a | bellard | CPUState *saved_env; |
79 | 04369ff2 | bellard | #ifdef reg_EAX
|
80 | 04369ff2 | bellard | int saved_EAX;
|
81 | 04369ff2 | bellard | #endif
|
82 | 04369ff2 | bellard | #ifdef reg_ECX
|
83 | 04369ff2 | bellard | int saved_ECX;
|
84 | 04369ff2 | bellard | #endif
|
85 | 04369ff2 | bellard | #ifdef reg_EDX
|
86 | 04369ff2 | bellard | int saved_EDX;
|
87 | 04369ff2 | bellard | #endif
|
88 | 04369ff2 | bellard | #ifdef reg_EBX
|
89 | 04369ff2 | bellard | int saved_EBX;
|
90 | 04369ff2 | bellard | #endif
|
91 | 04369ff2 | bellard | #ifdef reg_ESP
|
92 | 04369ff2 | bellard | int saved_ESP;
|
93 | 04369ff2 | bellard | #endif
|
94 | 04369ff2 | bellard | #ifdef reg_EBP
|
95 | 04369ff2 | bellard | int saved_EBP;
|
96 | 04369ff2 | bellard | #endif
|
97 | 04369ff2 | bellard | #ifdef reg_ESI
|
98 | 04369ff2 | bellard | int saved_ESI;
|
99 | 04369ff2 | bellard | #endif
|
100 | 04369ff2 | bellard | #ifdef reg_EDI
|
101 | 04369ff2 | bellard | int saved_EDI;
|
102 | 04369ff2 | bellard | #endif
|
103 | 8c6939c0 | bellard | #ifdef __sparc__
|
104 | 8c6939c0 | bellard | int saved_i7, tmp_T0;
|
105 | 8c6939c0 | bellard | #endif
|
106 | 68a79315 | bellard | int code_gen_size, ret, interrupt_request;
|
107 | 7d13299d | bellard | void (*gen_func)(void); |
108 | 9de5e440 | bellard | TranslationBlock *tb, **ptb; |
109 | dab2ed99 | bellard | uint8_t *tc_ptr, *cs_base, *pc; |
110 | 6dbad63e | bellard | unsigned int flags; |
111 | 8c6939c0 | bellard | |
112 | 7d13299d | bellard | /* first we save global registers */
|
113 | 7d13299d | bellard | saved_T0 = T0; |
114 | 7d13299d | bellard | saved_T1 = T1; |
115 | e4533c7a | bellard | saved_T2 = T2; |
116 | 7d13299d | bellard | saved_env = env; |
117 | 7d13299d | bellard | env = env1; |
118 | e4533c7a | bellard | #ifdef __sparc__
|
119 | e4533c7a | bellard | /* we also save i7 because longjmp may not restore it */
|
120 | e4533c7a | bellard | asm volatile ("mov %%i7, %0" : "=r" (saved_i7)); |
121 | e4533c7a | bellard | #endif
|
122 | e4533c7a | bellard | |
123 | e4533c7a | bellard | #if defined(TARGET_I386)
|
124 | 04369ff2 | bellard | #ifdef reg_EAX
|
125 | 04369ff2 | bellard | saved_EAX = EAX; |
126 | 04369ff2 | bellard | EAX = env->regs[R_EAX]; |
127 | 04369ff2 | bellard | #endif
|
128 | 04369ff2 | bellard | #ifdef reg_ECX
|
129 | 04369ff2 | bellard | saved_ECX = ECX; |
130 | 04369ff2 | bellard | ECX = env->regs[R_ECX]; |
131 | 04369ff2 | bellard | #endif
|
132 | 04369ff2 | bellard | #ifdef reg_EDX
|
133 | 04369ff2 | bellard | saved_EDX = EDX; |
134 | 04369ff2 | bellard | EDX = env->regs[R_EDX]; |
135 | 04369ff2 | bellard | #endif
|
136 | 04369ff2 | bellard | #ifdef reg_EBX
|
137 | 04369ff2 | bellard | saved_EBX = EBX; |
138 | 04369ff2 | bellard | EBX = env->regs[R_EBX]; |
139 | 04369ff2 | bellard | #endif
|
140 | 04369ff2 | bellard | #ifdef reg_ESP
|
141 | 04369ff2 | bellard | saved_ESP = ESP; |
142 | 04369ff2 | bellard | ESP = env->regs[R_ESP]; |
143 | 04369ff2 | bellard | #endif
|
144 | 04369ff2 | bellard | #ifdef reg_EBP
|
145 | 04369ff2 | bellard | saved_EBP = EBP; |
146 | 04369ff2 | bellard | EBP = env->regs[R_EBP]; |
147 | 04369ff2 | bellard | #endif
|
148 | 04369ff2 | bellard | #ifdef reg_ESI
|
149 | 04369ff2 | bellard | saved_ESI = ESI; |
150 | 04369ff2 | bellard | ESI = env->regs[R_ESI]; |
151 | 04369ff2 | bellard | #endif
|
152 | 04369ff2 | bellard | #ifdef reg_EDI
|
153 | 04369ff2 | bellard | saved_EDI = EDI; |
154 | 04369ff2 | bellard | EDI = env->regs[R_EDI]; |
155 | 04369ff2 | bellard | #endif
|
156 | 7d13299d | bellard | |
157 | 9de5e440 | bellard | /* put eflags in CPU temporary format */
|
158 | fc2b4c48 | bellard | CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); |
159 | fc2b4c48 | bellard | DF = 1 - (2 * ((env->eflags >> 10) & 1)); |
160 | 9de5e440 | bellard | CC_OP = CC_OP_EFLAGS; |
161 | fc2b4c48 | bellard | env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); |
162 | e4533c7a | bellard | #elif defined(TARGET_ARM)
|
163 | e4533c7a | bellard | { |
164 | e4533c7a | bellard | unsigned int psr; |
165 | e4533c7a | bellard | psr = env->cpsr; |
166 | e4533c7a | bellard | env->CF = (psr >> 29) & 1; |
167 | e4533c7a | bellard | env->NZF = (psr & 0xc0000000) ^ 0x40000000; |
168 | e4533c7a | bellard | env->VF = (psr << 3) & 0x80000000; |
169 | e4533c7a | bellard | env->cpsr = psr & ~0xf0000000;
|
170 | e4533c7a | bellard | } |
171 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
172 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
173 | e4533c7a | bellard | #else
|
174 | e4533c7a | bellard | #error unsupported target CPU
|
175 | e4533c7a | bellard | #endif
|
176 | 3fb2ded1 | bellard | env->exception_index = -1;
|
177 | 9d27abd9 | bellard | |
178 | 7d13299d | bellard | /* prepare setjmp context for exception handling */
|
179 | 3fb2ded1 | bellard | for(;;) {
|
180 | 3fb2ded1 | bellard | if (setjmp(env->jmp_env) == 0) { |
181 | ee8b7021 | bellard | env->current_tb = NULL;
|
182 | 3fb2ded1 | bellard | /* if an exception is pending, we execute it here */
|
183 | 3fb2ded1 | bellard | if (env->exception_index >= 0) { |
184 | 3fb2ded1 | bellard | if (env->exception_index >= EXCP_INTERRUPT) {
|
185 | 3fb2ded1 | bellard | /* exit request from the cpu execution loop */
|
186 | 3fb2ded1 | bellard | ret = env->exception_index; |
187 | 3fb2ded1 | bellard | break;
|
188 | 3fb2ded1 | bellard | } else if (env->user_mode_only) { |
189 | 3fb2ded1 | bellard | /* if user mode only, we simulate a fake exception
|
190 | 3fb2ded1 | bellard | which will be hanlded outside the cpu execution
|
191 | 3fb2ded1 | bellard | loop */
|
192 | 83479e77 | bellard | #if defined(TARGET_I386)
|
193 | 3fb2ded1 | bellard | do_interrupt_user(env->exception_index, |
194 | 3fb2ded1 | bellard | env->exception_is_int, |
195 | 3fb2ded1 | bellard | env->error_code, |
196 | 3fb2ded1 | bellard | env->exception_next_eip); |
197 | 83479e77 | bellard | #endif
|
198 | 3fb2ded1 | bellard | ret = env->exception_index; |
199 | 3fb2ded1 | bellard | break;
|
200 | 3fb2ded1 | bellard | } else {
|
201 | 83479e77 | bellard | #if defined(TARGET_I386)
|
202 | 3fb2ded1 | bellard | /* simulate a real cpu exception. On i386, it can
|
203 | 3fb2ded1 | bellard | trigger new exceptions, but we do not handle
|
204 | 3fb2ded1 | bellard | double or triple faults yet. */
|
205 | 3fb2ded1 | bellard | do_interrupt(env->exception_index, |
206 | 3fb2ded1 | bellard | env->exception_is_int, |
207 | 3fb2ded1 | bellard | env->error_code, |
208 | d05e66d2 | bellard | env->exception_next_eip, 0);
|
209 | ce09776b | bellard | #elif defined(TARGET_PPC)
|
210 | ce09776b | bellard | do_interrupt(env); |
211 | 83479e77 | bellard | #endif
|
212 | 3fb2ded1 | bellard | } |
213 | 3fb2ded1 | bellard | env->exception_index = -1;
|
214 | 3fb2ded1 | bellard | } |
215 | 3fb2ded1 | bellard | T0 = 0; /* force lookup of first TB */ |
216 | 3fb2ded1 | bellard | for(;;) {
|
217 | 8c6939c0 | bellard | #ifdef __sparc__
|
218 | 3fb2ded1 | bellard | /* g1 can be modified by some libc? functions */
|
219 | 3fb2ded1 | bellard | tmp_T0 = T0; |
220 | 8c6939c0 | bellard | #endif
|
221 | 68a79315 | bellard | interrupt_request = env->interrupt_request; |
222 | 2e255c6b | bellard | if (__builtin_expect(interrupt_request, 0)) { |
223 | 68a79315 | bellard | #if defined(TARGET_I386)
|
224 | 68a79315 | bellard | /* if hardware interrupt pending, we execute it */
|
225 | 68a79315 | bellard | if ((interrupt_request & CPU_INTERRUPT_HARD) &&
|
226 | 3f337316 | bellard | (env->eflags & IF_MASK) && |
227 | 3f337316 | bellard | !(env->hflags & HF_INHIBIT_IRQ_MASK)) { |
228 | 68a79315 | bellard | int intno;
|
229 | fbf9eeb3 | bellard | env->interrupt_request &= ~CPU_INTERRUPT_HARD; |
230 | a541f297 | bellard | intno = cpu_get_pic_interrupt(env); |
231 | f193c797 | bellard | if (loglevel & CPU_LOG_TB_IN_ASM) {
|
232 | 68a79315 | bellard | fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
|
233 | 68a79315 | bellard | } |
234 | d05e66d2 | bellard | do_interrupt(intno, 0, 0, 0, 1); |
235 | 907a5b26 | bellard | /* ensure that no TB jump will be modified as
|
236 | 907a5b26 | bellard | the program flow was changed */
|
237 | 907a5b26 | bellard | #ifdef __sparc__
|
238 | 907a5b26 | bellard | tmp_T0 = 0;
|
239 | 907a5b26 | bellard | #else
|
240 | 907a5b26 | bellard | T0 = 0;
|
241 | 907a5b26 | bellard | #endif
|
242 | 68a79315 | bellard | } |
243 | ce09776b | bellard | #elif defined(TARGET_PPC)
|
244 | 9fddaa0c | bellard | #if 0
|
245 | 9fddaa0c | bellard | if ((interrupt_request & CPU_INTERRUPT_RESET)) {
|
246 | 9fddaa0c | bellard | cpu_ppc_reset(env);
|
247 | 9fddaa0c | bellard | }
|
248 | 9fddaa0c | bellard | #endif
|
249 | 9fddaa0c | bellard | if (msr_ee != 0) { |
250 | ce09776b | bellard | if ((interrupt_request & CPU_INTERRUPT_HARD)) {
|
251 | 9fddaa0c | bellard | /* Raise it */
|
252 | 9fddaa0c | bellard | env->exception_index = EXCP_EXTERNAL; |
253 | 9fddaa0c | bellard | env->error_code = 0;
|
254 | ce09776b | bellard | do_interrupt(env); |
255 | ce09776b | bellard | env->interrupt_request &= ~CPU_INTERRUPT_HARD; |
256 | 9fddaa0c | bellard | } else if ((interrupt_request & CPU_INTERRUPT_TIMER)) { |
257 | 9fddaa0c | bellard | /* Raise it */
|
258 | 9fddaa0c | bellard | env->exception_index = EXCP_DECR; |
259 | 9fddaa0c | bellard | env->error_code = 0;
|
260 | 9fddaa0c | bellard | do_interrupt(env); |
261 | 9fddaa0c | bellard | env->interrupt_request &= ~CPU_INTERRUPT_TIMER; |
262 | 9fddaa0c | bellard | } |
263 | ce09776b | bellard | } |
264 | 68a79315 | bellard | #endif
|
265 | bf3e8bf1 | bellard | if (interrupt_request & CPU_INTERRUPT_EXITTB) {
|
266 | bf3e8bf1 | bellard | env->interrupt_request &= ~CPU_INTERRUPT_EXITTB; |
267 | bf3e8bf1 | bellard | /* ensure that no TB jump will be modified as
|
268 | bf3e8bf1 | bellard | the program flow was changed */
|
269 | bf3e8bf1 | bellard | #ifdef __sparc__
|
270 | bf3e8bf1 | bellard | tmp_T0 = 0;
|
271 | bf3e8bf1 | bellard | #else
|
272 | bf3e8bf1 | bellard | T0 = 0;
|
273 | bf3e8bf1 | bellard | #endif
|
274 | bf3e8bf1 | bellard | } |
275 | 68a79315 | bellard | if (interrupt_request & CPU_INTERRUPT_EXIT) {
|
276 | 68a79315 | bellard | env->interrupt_request &= ~CPU_INTERRUPT_EXIT; |
277 | 68a79315 | bellard | env->exception_index = EXCP_INTERRUPT; |
278 | 68a79315 | bellard | cpu_loop_exit(); |
279 | 68a79315 | bellard | } |
280 | 3fb2ded1 | bellard | } |
281 | 7d13299d | bellard | #ifdef DEBUG_EXEC
|
282 | f193c797 | bellard | if (loglevel & CPU_LOG_EXEC) {
|
283 | e4533c7a | bellard | #if defined(TARGET_I386)
|
284 | 3fb2ded1 | bellard | /* restore flags in standard format */
|
285 | 3fb2ded1 | bellard | env->regs[R_EAX] = EAX; |
286 | 3fb2ded1 | bellard | env->regs[R_EBX] = EBX; |
287 | 3fb2ded1 | bellard | env->regs[R_ECX] = ECX; |
288 | 3fb2ded1 | bellard | env->regs[R_EDX] = EDX; |
289 | 3fb2ded1 | bellard | env->regs[R_ESI] = ESI; |
290 | 3fb2ded1 | bellard | env->regs[R_EDI] = EDI; |
291 | 3fb2ded1 | bellard | env->regs[R_EBP] = EBP; |
292 | 3fb2ded1 | bellard | env->regs[R_ESP] = ESP; |
293 | 3fb2ded1 | bellard | env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); |
294 | 68a79315 | bellard | cpu_x86_dump_state(env, logfile, X86_DUMP_CCOP); |
295 | 3fb2ded1 | bellard | env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C); |
296 | e4533c7a | bellard | #elif defined(TARGET_ARM)
|
297 | 1b21b62a | bellard | env->cpsr = compute_cpsr(); |
298 | 3fb2ded1 | bellard | cpu_arm_dump_state(env, logfile, 0);
|
299 | 1b21b62a | bellard | env->cpsr &= ~0xf0000000;
|
300 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
301 | 93a40ea9 | bellard | cpu_sparc_dump_state (env, logfile, 0);
|
302 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
303 | 67867308 | bellard | cpu_ppc_dump_state(env, logfile, 0);
|
304 | e4533c7a | bellard | #else
|
305 | e4533c7a | bellard | #error unsupported target CPU
|
306 | e4533c7a | bellard | #endif
|
307 | 3fb2ded1 | bellard | } |
308 | 7d13299d | bellard | #endif
|
309 | 3f337316 | bellard | /* we record a subset of the CPU state. It will
|
310 | 3f337316 | bellard | always be the same before a given translated block
|
311 | 3f337316 | bellard | is executed. */
|
312 | e4533c7a | bellard | #if defined(TARGET_I386)
|
313 | 2e255c6b | bellard | flags = env->hflags; |
314 | 3f337316 | bellard | flags |= (env->eflags & (IOPL_MASK | TF_MASK | VM_MASK)); |
315 | 3fb2ded1 | bellard | cs_base = env->segs[R_CS].base; |
316 | 3fb2ded1 | bellard | pc = cs_base + env->eip; |
317 | e4533c7a | bellard | #elif defined(TARGET_ARM)
|
318 | 3fb2ded1 | bellard | flags = 0;
|
319 | 3fb2ded1 | bellard | cs_base = 0;
|
320 | 3fb2ded1 | bellard | pc = (uint8_t *)env->regs[15];
|
321 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
322 | 67867308 | bellard | flags = 0;
|
323 | ce09776b | bellard | cs_base = (uint8_t *)env->npc; |
324 | 67867308 | bellard | pc = (uint8_t *) env->pc; |
325 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
326 | 67867308 | bellard | flags = 0;
|
327 | 67867308 | bellard | cs_base = 0;
|
328 | 67867308 | bellard | pc = (uint8_t *)env->nip; |
329 | e4533c7a | bellard | #else
|
330 | e4533c7a | bellard | #error unsupported CPU
|
331 | e4533c7a | bellard | #endif
|
332 | 3fb2ded1 | bellard | tb = tb_find(&ptb, (unsigned long)pc, (unsigned long)cs_base, |
333 | 3fb2ded1 | bellard | flags); |
334 | d4e8164f | bellard | if (!tb) {
|
335 | 1376847f | bellard | TranslationBlock **ptb1; |
336 | 1376847f | bellard | unsigned int h; |
337 | 1376847f | bellard | target_ulong phys_pc, phys_page1, phys_page2, virt_page2; |
338 | 1376847f | bellard | |
339 | 1376847f | bellard | |
340 | 3fb2ded1 | bellard | spin_lock(&tb_lock); |
341 | 1376847f | bellard | |
342 | 1376847f | bellard | tb_invalidated_flag = 0;
|
343 | 1376847f | bellard | |
344 | 1376847f | bellard | /* find translated block using physical mappings */
|
345 | 1376847f | bellard | phys_pc = get_phys_addr_code(env, (unsigned long)pc); |
346 | 1376847f | bellard | phys_page1 = phys_pc & TARGET_PAGE_MASK; |
347 | 1376847f | bellard | phys_page2 = -1;
|
348 | 1376847f | bellard | h = tb_phys_hash_func(phys_pc); |
349 | 1376847f | bellard | ptb1 = &tb_phys_hash[h]; |
350 | 1376847f | bellard | for(;;) {
|
351 | 1376847f | bellard | tb = *ptb1; |
352 | 1376847f | bellard | if (!tb)
|
353 | 1376847f | bellard | goto not_found;
|
354 | 1376847f | bellard | if (tb->pc == (unsigned long)pc && |
355 | 1376847f | bellard | tb->page_addr[0] == phys_page1 &&
|
356 | 1376847f | bellard | tb->cs_base == (unsigned long)cs_base && |
357 | 1376847f | bellard | tb->flags == flags) { |
358 | 1376847f | bellard | /* check next page if needed */
|
359 | b516f85c | bellard | if (tb->page_addr[1] != -1) { |
360 | b516f85c | bellard | virt_page2 = ((unsigned long)pc & TARGET_PAGE_MASK) + |
361 | b516f85c | bellard | TARGET_PAGE_SIZE; |
362 | 1376847f | bellard | phys_page2 = get_phys_addr_code(env, virt_page2); |
363 | 1376847f | bellard | if (tb->page_addr[1] == phys_page2) |
364 | 1376847f | bellard | goto found;
|
365 | 1376847f | bellard | } else {
|
366 | 1376847f | bellard | goto found;
|
367 | 1376847f | bellard | } |
368 | 1376847f | bellard | } |
369 | 1376847f | bellard | ptb1 = &tb->phys_hash_next; |
370 | 1376847f | bellard | } |
371 | 1376847f | bellard | not_found:
|
372 | 3fb2ded1 | bellard | /* if no translated code available, then translate it now */
|
373 | d4e8164f | bellard | tb = tb_alloc((unsigned long)pc); |
374 | 3fb2ded1 | bellard | if (!tb) {
|
375 | 3fb2ded1 | bellard | /* flush must be done */
|
376 | b453b70b | bellard | tb_flush(env); |
377 | 3fb2ded1 | bellard | /* cannot fail at this point */
|
378 | 3fb2ded1 | bellard | tb = tb_alloc((unsigned long)pc); |
379 | 3fb2ded1 | bellard | /* don't forget to invalidate previous TB info */
|
380 | 3fb2ded1 | bellard | ptb = &tb_hash[tb_hash_func((unsigned long)pc)]; |
381 | 3fb2ded1 | bellard | T0 = 0;
|
382 | 3fb2ded1 | bellard | } |
383 | 3fb2ded1 | bellard | tc_ptr = code_gen_ptr; |
384 | 3fb2ded1 | bellard | tb->tc_ptr = tc_ptr; |
385 | 3fb2ded1 | bellard | tb->cs_base = (unsigned long)cs_base; |
386 | 3fb2ded1 | bellard | tb->flags = flags; |
387 | facc68be | bellard | cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size); |
388 | 1376847f | bellard | code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1)); |
389 | 1376847f | bellard | |
390 | 1376847f | bellard | /* check next page if needed */
|
391 | 1376847f | bellard | virt_page2 = ((unsigned long)pc + tb->size - 1) & TARGET_PAGE_MASK; |
392 | 1376847f | bellard | phys_page2 = -1;
|
393 | 1376847f | bellard | if (((unsigned long)pc & TARGET_PAGE_MASK) != virt_page2) { |
394 | 1376847f | bellard | phys_page2 = get_phys_addr_code(env, virt_page2); |
395 | 1376847f | bellard | } |
396 | 1376847f | bellard | tb_link_phys(tb, phys_pc, phys_page2); |
397 | 1376847f | bellard | |
398 | 1376847f | bellard | found:
|
399 | 36bdbe54 | bellard | if (tb_invalidated_flag) {
|
400 | 36bdbe54 | bellard | /* as some TB could have been invalidated because
|
401 | 36bdbe54 | bellard | of memory exceptions while generating the code, we
|
402 | 36bdbe54 | bellard | must recompute the hash index here */
|
403 | 36bdbe54 | bellard | ptb = &tb_hash[tb_hash_func((unsigned long)pc)]; |
404 | 36bdbe54 | bellard | while (*ptb != NULL) |
405 | 36bdbe54 | bellard | ptb = &(*ptb)->hash_next; |
406 | 36bdbe54 | bellard | T0 = 0;
|
407 | 36bdbe54 | bellard | } |
408 | 1376847f | bellard | /* we add the TB in the virtual pc hash table */
|
409 | 3fb2ded1 | bellard | *ptb = tb; |
410 | 3fb2ded1 | bellard | tb->hash_next = NULL;
|
411 | 3fb2ded1 | bellard | tb_link(tb); |
412 | 25eb4484 | bellard | spin_unlock(&tb_lock); |
413 | 9de5e440 | bellard | } |
414 | 9d27abd9 | bellard | #ifdef DEBUG_EXEC
|
415 | f193c797 | bellard | if (loglevel & CPU_LOG_EXEC) {
|
416 | 3fb2ded1 | bellard | fprintf(logfile, "Trace 0x%08lx [0x%08lx] %s\n",
|
417 | 3fb2ded1 | bellard | (long)tb->tc_ptr, (long)tb->pc, |
418 | 3fb2ded1 | bellard | lookup_symbol((void *)tb->pc));
|
419 | 3fb2ded1 | bellard | } |
420 | 9d27abd9 | bellard | #endif
|
421 | 8c6939c0 | bellard | #ifdef __sparc__
|
422 | 3fb2ded1 | bellard | T0 = tmp_T0; |
423 | 8c6939c0 | bellard | #endif
|
424 | facc68be | bellard | /* see if we can patch the calling TB. */
|
425 | bf3e8bf1 | bellard | if (T0 != 0 |
426 | bf3e8bf1 | bellard | #if defined(TARGET_I386) && defined(USE_CODE_COPY)
|
427 | bf3e8bf1 | bellard | && (tb->cflags & CF_CODE_COPY) == |
428 | bf3e8bf1 | bellard | (((TranslationBlock *)(T0 & ~3))->cflags & CF_CODE_COPY)
|
429 | bf3e8bf1 | bellard | #endif
|
430 | bf3e8bf1 | bellard | ) { |
431 | 3fb2ded1 | bellard | spin_lock(&tb_lock); |
432 | 3fb2ded1 | bellard | tb_add_jump((TranslationBlock *)(T0 & ~3), T0 & 3, tb); |
433 | 97eb5b14 | bellard | #if defined(USE_CODE_COPY)
|
434 | 97eb5b14 | bellard | /* propagates the FP use info */
|
435 | 97eb5b14 | bellard | ((TranslationBlock *)(T0 & ~3))->cflags |=
|
436 | 97eb5b14 | bellard | (tb->cflags & CF_FP_USED); |
437 | 97eb5b14 | bellard | #endif
|
438 | 3fb2ded1 | bellard | spin_unlock(&tb_lock); |
439 | 3fb2ded1 | bellard | } |
440 | 3fb2ded1 | bellard | tc_ptr = tb->tc_ptr; |
441 | 83479e77 | bellard | env->current_tb = tb; |
442 | 3fb2ded1 | bellard | /* execute the generated code */
|
443 | 3fb2ded1 | bellard | gen_func = (void *)tc_ptr;
|
444 | 8c6939c0 | bellard | #if defined(__sparc__)
|
445 | 3fb2ded1 | bellard | __asm__ __volatile__("call %0\n\t"
|
446 | 3fb2ded1 | bellard | "mov %%o7,%%i0"
|
447 | 3fb2ded1 | bellard | : /* no outputs */
|
448 | 3fb2ded1 | bellard | : "r" (gen_func)
|
449 | 3fb2ded1 | bellard | : "i0", "i1", "i2", "i3", "i4", "i5"); |
450 | 8c6939c0 | bellard | #elif defined(__arm__)
|
451 | 3fb2ded1 | bellard | asm volatile ("mov pc, %0\n\t" |
452 | 3fb2ded1 | bellard | ".global exec_loop\n\t"
|
453 | 3fb2ded1 | bellard | "exec_loop:\n\t"
|
454 | 3fb2ded1 | bellard | : /* no outputs */
|
455 | 3fb2ded1 | bellard | : "r" (gen_func)
|
456 | 3fb2ded1 | bellard | : "r1", "r2", "r3", "r8", "r9", "r10", "r12", "r14"); |
457 | bf3e8bf1 | bellard | #elif defined(TARGET_I386) && defined(USE_CODE_COPY)
|
458 | bf3e8bf1 | bellard | { |
459 | bf3e8bf1 | bellard | if (!(tb->cflags & CF_CODE_COPY)) {
|
460 | 97eb5b14 | bellard | if ((tb->cflags & CF_FP_USED) && env->native_fp_regs) {
|
461 | 97eb5b14 | bellard | save_native_fp_state(env); |
462 | 97eb5b14 | bellard | } |
463 | bf3e8bf1 | bellard | gen_func(); |
464 | bf3e8bf1 | bellard | } else {
|
465 | 97eb5b14 | bellard | if ((tb->cflags & CF_FP_USED) && !env->native_fp_regs) {
|
466 | 97eb5b14 | bellard | restore_native_fp_state(env); |
467 | 97eb5b14 | bellard | } |
468 | bf3e8bf1 | bellard | /* we work with native eflags */
|
469 | bf3e8bf1 | bellard | CC_SRC = cc_table[CC_OP].compute_all(); |
470 | bf3e8bf1 | bellard | CC_OP = CC_OP_EFLAGS; |
471 | bf3e8bf1 | bellard | asm(".globl exec_loop\n" |
472 | bf3e8bf1 | bellard | "\n"
|
473 | bf3e8bf1 | bellard | "debug1:\n"
|
474 | bf3e8bf1 | bellard | " pushl %%ebp\n"
|
475 | bf3e8bf1 | bellard | " fs movl %10, %9\n"
|
476 | bf3e8bf1 | bellard | " fs movl %11, %%eax\n"
|
477 | bf3e8bf1 | bellard | " andl $0x400, %%eax\n"
|
478 | bf3e8bf1 | bellard | " fs orl %8, %%eax\n"
|
479 | bf3e8bf1 | bellard | " pushl %%eax\n"
|
480 | bf3e8bf1 | bellard | " popf\n"
|
481 | bf3e8bf1 | bellard | " fs movl %%esp, %12\n"
|
482 | bf3e8bf1 | bellard | " fs movl %0, %%eax\n"
|
483 | bf3e8bf1 | bellard | " fs movl %1, %%ecx\n"
|
484 | bf3e8bf1 | bellard | " fs movl %2, %%edx\n"
|
485 | bf3e8bf1 | bellard | " fs movl %3, %%ebx\n"
|
486 | bf3e8bf1 | bellard | " fs movl %4, %%esp\n"
|
487 | bf3e8bf1 | bellard | " fs movl %5, %%ebp\n"
|
488 | bf3e8bf1 | bellard | " fs movl %6, %%esi\n"
|
489 | bf3e8bf1 | bellard | " fs movl %7, %%edi\n"
|
490 | bf3e8bf1 | bellard | " fs jmp *%9\n"
|
491 | bf3e8bf1 | bellard | "exec_loop:\n"
|
492 | bf3e8bf1 | bellard | " fs movl %%esp, %4\n"
|
493 | bf3e8bf1 | bellard | " fs movl %12, %%esp\n"
|
494 | bf3e8bf1 | bellard | " fs movl %%eax, %0\n"
|
495 | bf3e8bf1 | bellard | " fs movl %%ecx, %1\n"
|
496 | bf3e8bf1 | bellard | " fs movl %%edx, %2\n"
|
497 | bf3e8bf1 | bellard | " fs movl %%ebx, %3\n"
|
498 | bf3e8bf1 | bellard | " fs movl %%ebp, %5\n"
|
499 | bf3e8bf1 | bellard | " fs movl %%esi, %6\n"
|
500 | bf3e8bf1 | bellard | " fs movl %%edi, %7\n"
|
501 | bf3e8bf1 | bellard | " pushf\n"
|
502 | bf3e8bf1 | bellard | " popl %%eax\n"
|
503 | bf3e8bf1 | bellard | " movl %%eax, %%ecx\n"
|
504 | bf3e8bf1 | bellard | " andl $0x400, %%ecx\n"
|
505 | bf3e8bf1 | bellard | " shrl $9, %%ecx\n"
|
506 | bf3e8bf1 | bellard | " andl $0x8d5, %%eax\n"
|
507 | bf3e8bf1 | bellard | " fs movl %%eax, %8\n"
|
508 | bf3e8bf1 | bellard | " movl $1, %%eax\n"
|
509 | bf3e8bf1 | bellard | " subl %%ecx, %%eax\n"
|
510 | bf3e8bf1 | bellard | " fs movl %%eax, %11\n"
|
511 | bf3e8bf1 | bellard | " fs movl %9, %%ebx\n" /* get T0 value */ |
512 | bf3e8bf1 | bellard | " popl %%ebp\n"
|
513 | bf3e8bf1 | bellard | : |
514 | bf3e8bf1 | bellard | : "m" (*(uint8_t *)offsetof(CPUState, regs[0])), |
515 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[1])), |
516 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[2])), |
517 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[3])), |
518 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[4])), |
519 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[5])), |
520 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[6])), |
521 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, regs[7])), |
522 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, cc_src)),
|
523 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, tmp0)),
|
524 | bf3e8bf1 | bellard | "a" (gen_func),
|
525 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, df)),
|
526 | bf3e8bf1 | bellard | "m" (*(uint8_t *)offsetof(CPUState, saved_esp))
|
527 | bf3e8bf1 | bellard | : "%ecx", "%edx" |
528 | bf3e8bf1 | bellard | ); |
529 | bf3e8bf1 | bellard | } |
530 | bf3e8bf1 | bellard | } |
531 | ae228531 | bellard | #else
|
532 | 3fb2ded1 | bellard | gen_func(); |
533 | ae228531 | bellard | #endif
|
534 | 83479e77 | bellard | env->current_tb = NULL;
|
535 | 4cbf74b6 | bellard | /* reset soft MMU for next block (it can currently
|
536 | 4cbf74b6 | bellard | only be set by a memory fault) */
|
537 | 4cbf74b6 | bellard | #if defined(TARGET_I386) && !defined(CONFIG_SOFTMMU)
|
538 | 3f337316 | bellard | if (env->hflags & HF_SOFTMMU_MASK) {
|
539 | 3f337316 | bellard | env->hflags &= ~HF_SOFTMMU_MASK; |
540 | 4cbf74b6 | bellard | /* do not allow linking to another block */
|
541 | 4cbf74b6 | bellard | T0 = 0;
|
542 | 4cbf74b6 | bellard | } |
543 | 4cbf74b6 | bellard | #endif
|
544 | 3fb2ded1 | bellard | } |
545 | 3fb2ded1 | bellard | } else {
|
546 | 7d13299d | bellard | } |
547 | 3fb2ded1 | bellard | } /* for(;;) */
|
548 | 3fb2ded1 | bellard | |
549 | 7d13299d | bellard | |
550 | e4533c7a | bellard | #if defined(TARGET_I386)
|
551 | 97eb5b14 | bellard | #if defined(USE_CODE_COPY)
|
552 | 97eb5b14 | bellard | if (env->native_fp_regs) {
|
553 | 97eb5b14 | bellard | save_native_fp_state(env); |
554 | 97eb5b14 | bellard | } |
555 | 97eb5b14 | bellard | #endif
|
556 | 9de5e440 | bellard | /* restore flags in standard format */
|
557 | fc2b4c48 | bellard | env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK); |
558 | 9de5e440 | bellard | |
559 | 7d13299d | bellard | /* restore global registers */
|
560 | 04369ff2 | bellard | #ifdef reg_EAX
|
561 | 04369ff2 | bellard | EAX = saved_EAX; |
562 | 04369ff2 | bellard | #endif
|
563 | 04369ff2 | bellard | #ifdef reg_ECX
|
564 | 04369ff2 | bellard | ECX = saved_ECX; |
565 | 04369ff2 | bellard | #endif
|
566 | 04369ff2 | bellard | #ifdef reg_EDX
|
567 | 04369ff2 | bellard | EDX = saved_EDX; |
568 | 04369ff2 | bellard | #endif
|
569 | 04369ff2 | bellard | #ifdef reg_EBX
|
570 | 04369ff2 | bellard | EBX = saved_EBX; |
571 | 04369ff2 | bellard | #endif
|
572 | 04369ff2 | bellard | #ifdef reg_ESP
|
573 | 04369ff2 | bellard | ESP = saved_ESP; |
574 | 04369ff2 | bellard | #endif
|
575 | 04369ff2 | bellard | #ifdef reg_EBP
|
576 | 04369ff2 | bellard | EBP = saved_EBP; |
577 | 04369ff2 | bellard | #endif
|
578 | 04369ff2 | bellard | #ifdef reg_ESI
|
579 | 04369ff2 | bellard | ESI = saved_ESI; |
580 | 04369ff2 | bellard | #endif
|
581 | 04369ff2 | bellard | #ifdef reg_EDI
|
582 | 04369ff2 | bellard | EDI = saved_EDI; |
583 | 04369ff2 | bellard | #endif
|
584 | e4533c7a | bellard | #elif defined(TARGET_ARM)
|
585 | 1b21b62a | bellard | env->cpsr = compute_cpsr(); |
586 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
587 | 67867308 | bellard | #elif defined(TARGET_PPC)
|
588 | e4533c7a | bellard | #else
|
589 | e4533c7a | bellard | #error unsupported target CPU
|
590 | e4533c7a | bellard | #endif
|
591 | 8c6939c0 | bellard | #ifdef __sparc__
|
592 | 8c6939c0 | bellard | asm volatile ("mov %0, %%i7" : : "r" (saved_i7)); |
593 | 8c6939c0 | bellard | #endif
|
594 | 7d13299d | bellard | T0 = saved_T0; |
595 | 7d13299d | bellard | T1 = saved_T1; |
596 | e4533c7a | bellard | T2 = saved_T2; |
597 | 7d13299d | bellard | env = saved_env; |
598 | 7d13299d | bellard | return ret;
|
599 | 7d13299d | bellard | } |
600 | 6dbad63e | bellard | |
601 | fbf9eeb3 | bellard | /* must only be called from the generated code as an exception can be
|
602 | fbf9eeb3 | bellard | generated */
|
603 | fbf9eeb3 | bellard | void tb_invalidate_page_range(target_ulong start, target_ulong end)
|
604 | fbf9eeb3 | bellard | { |
605 | dc5d0b3d | bellard | /* XXX: cannot enable it yet because it yields to MMU exception
|
606 | dc5d0b3d | bellard | where NIP != read address on PowerPC */
|
607 | dc5d0b3d | bellard | #if 0
|
608 | fbf9eeb3 | bellard | target_ulong phys_addr;
|
609 | fbf9eeb3 | bellard | phys_addr = get_phys_addr_code(env, start);
|
610 | fbf9eeb3 | bellard | tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0);
|
611 | dc5d0b3d | bellard | #endif
|
612 | fbf9eeb3 | bellard | } |
613 | fbf9eeb3 | bellard | |
614 | 1a18c71b | bellard | #if defined(TARGET_I386) && defined(CONFIG_USER_ONLY)
|
615 | e4533c7a | bellard | |
616 | 6dbad63e | bellard | void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector) |
617 | 6dbad63e | bellard | { |
618 | 6dbad63e | bellard | CPUX86State *saved_env; |
619 | 6dbad63e | bellard | |
620 | 6dbad63e | bellard | saved_env = env; |
621 | 6dbad63e | bellard | env = s; |
622 | a412ac57 | bellard | if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) { |
623 | a513fe19 | bellard | selector &= 0xffff;
|
624 | 2e255c6b | bellard | cpu_x86_load_seg_cache(env, seg_reg, selector, |
625 | 2e255c6b | bellard | (uint8_t *)(selector << 4), 0xffff, 0); |
626 | a513fe19 | bellard | } else {
|
627 | b453b70b | bellard | load_seg(seg_reg, selector); |
628 | a513fe19 | bellard | } |
629 | 6dbad63e | bellard | env = saved_env; |
630 | 6dbad63e | bellard | } |
631 | 9de5e440 | bellard | |
632 | d0a1ffc9 | bellard | void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32) |
633 | d0a1ffc9 | bellard | { |
634 | d0a1ffc9 | bellard | CPUX86State *saved_env; |
635 | d0a1ffc9 | bellard | |
636 | d0a1ffc9 | bellard | saved_env = env; |
637 | d0a1ffc9 | bellard | env = s; |
638 | d0a1ffc9 | bellard | |
639 | d0a1ffc9 | bellard | helper_fsave(ptr, data32); |
640 | d0a1ffc9 | bellard | |
641 | d0a1ffc9 | bellard | env = saved_env; |
642 | d0a1ffc9 | bellard | } |
643 | d0a1ffc9 | bellard | |
644 | d0a1ffc9 | bellard | void cpu_x86_frstor(CPUX86State *s, uint8_t *ptr, int data32) |
645 | d0a1ffc9 | bellard | { |
646 | d0a1ffc9 | bellard | CPUX86State *saved_env; |
647 | d0a1ffc9 | bellard | |
648 | d0a1ffc9 | bellard | saved_env = env; |
649 | d0a1ffc9 | bellard | env = s; |
650 | d0a1ffc9 | bellard | |
651 | d0a1ffc9 | bellard | helper_frstor(ptr, data32); |
652 | d0a1ffc9 | bellard | |
653 | d0a1ffc9 | bellard | env = saved_env; |
654 | d0a1ffc9 | bellard | } |
655 | d0a1ffc9 | bellard | |
656 | e4533c7a | bellard | #endif /* TARGET_I386 */ |
657 | e4533c7a | bellard | |
658 | 67b915a5 | bellard | #if !defined(CONFIG_SOFTMMU)
|
659 | 67b915a5 | bellard | |
660 | 3fb2ded1 | bellard | #if defined(TARGET_I386)
|
661 | 3fb2ded1 | bellard | |
662 | b56dad1c | bellard | /* 'pc' is the host PC at which the exception was raised. 'address' is
|
663 | fd6ce8f6 | bellard | the effective address of the memory exception. 'is_write' is 1 if a
|
664 | fd6ce8f6 | bellard | write caused the exception and otherwise 0'. 'old_set' is the
|
665 | fd6ce8f6 | bellard | signal set which should be restored */
|
666 | 2b413144 | bellard | static inline int handle_cpu_signal(unsigned long pc, unsigned long address, |
667 | bf3e8bf1 | bellard | int is_write, sigset_t *old_set,
|
668 | bf3e8bf1 | bellard | void *puc)
|
669 | 9de5e440 | bellard | { |
670 | a513fe19 | bellard | TranslationBlock *tb; |
671 | a513fe19 | bellard | int ret;
|
672 | 68a79315 | bellard | |
673 | 83479e77 | bellard | if (cpu_single_env)
|
674 | 83479e77 | bellard | env = cpu_single_env; /* XXX: find a correct solution for multithread */
|
675 | fd6ce8f6 | bellard | #if defined(DEBUG_SIGNAL)
|
676 | bf3e8bf1 | bellard | qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
|
677 | bf3e8bf1 | bellard | pc, address, is_write, *(unsigned long *)old_set); |
678 | 9de5e440 | bellard | #endif
|
679 | 25eb4484 | bellard | /* XXX: locking issue */
|
680 | fbf9eeb3 | bellard | if (is_write && page_unprotect(address, pc, puc)) {
|
681 | fd6ce8f6 | bellard | return 1; |
682 | fd6ce8f6 | bellard | } |
683 | fbf9eeb3 | bellard | |
684 | 3fb2ded1 | bellard | /* see if it is an MMU fault */
|
685 | 93a40ea9 | bellard | ret = cpu_x86_handle_mmu_fault(env, address, is_write, |
686 | 93a40ea9 | bellard | ((env->hflags & HF_CPL_MASK) == 3), 0); |
687 | 3fb2ded1 | bellard | if (ret < 0) |
688 | 3fb2ded1 | bellard | return 0; /* not an MMU fault */ |
689 | 3fb2ded1 | bellard | if (ret == 0) |
690 | 3fb2ded1 | bellard | return 1; /* the MMU fault was handled without causing real CPU fault */ |
691 | 3fb2ded1 | bellard | /* now we have a real cpu fault */
|
692 | a513fe19 | bellard | tb = tb_find_pc(pc); |
693 | a513fe19 | bellard | if (tb) {
|
694 | 9de5e440 | bellard | /* the PC is inside the translated code. It means that we have
|
695 | 9de5e440 | bellard | a virtual CPU fault */
|
696 | bf3e8bf1 | bellard | cpu_restore_state(tb, env, pc, puc); |
697 | 3fb2ded1 | bellard | } |
698 | 4cbf74b6 | bellard | if (ret == 1) { |
699 | 3fb2ded1 | bellard | #if 0
|
700 | 4cbf74b6 | bellard | printf("PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\n",
|
701 | 4cbf74b6 | bellard | env->eip, env->cr[2], env->error_code);
|
702 | 3fb2ded1 | bellard | #endif
|
703 | 4cbf74b6 | bellard | /* we restore the process signal mask as the sigreturn should
|
704 | 4cbf74b6 | bellard | do it (XXX: use sigsetjmp) */
|
705 | 4cbf74b6 | bellard | sigprocmask(SIG_SETMASK, old_set, NULL);
|
706 | 4cbf74b6 | bellard | raise_exception_err(EXCP0E_PAGE, env->error_code); |
707 | 4cbf74b6 | bellard | } else {
|
708 | 4cbf74b6 | bellard | /* activate soft MMU for this block */
|
709 | 3f337316 | bellard | env->hflags |= HF_SOFTMMU_MASK; |
710 | fbf9eeb3 | bellard | cpu_resume_from_signal(env, puc); |
711 | 4cbf74b6 | bellard | } |
712 | 3fb2ded1 | bellard | /* never comes here */
|
713 | 3fb2ded1 | bellard | return 1; |
714 | 3fb2ded1 | bellard | } |
715 | 3fb2ded1 | bellard | |
716 | e4533c7a | bellard | #elif defined(TARGET_ARM)
|
717 | 3fb2ded1 | bellard | static inline int handle_cpu_signal(unsigned long pc, unsigned long address, |
718 | bf3e8bf1 | bellard | int is_write, sigset_t *old_set,
|
719 | bf3e8bf1 | bellard | void *puc)
|
720 | 3fb2ded1 | bellard | { |
721 | 3fb2ded1 | bellard | /* XXX: do more */
|
722 | 3fb2ded1 | bellard | return 0; |
723 | 3fb2ded1 | bellard | } |
724 | 93ac68bc | bellard | #elif defined(TARGET_SPARC)
|
725 | 93ac68bc | bellard | static inline int handle_cpu_signal(unsigned long pc, unsigned long address, |
726 | bf3e8bf1 | bellard | int is_write, sigset_t *old_set,
|
727 | bf3e8bf1 | bellard | void *puc)
|
728 | 93ac68bc | bellard | { |
729 | b453b70b | bellard | /* XXX: locking issue */
|
730 | fbf9eeb3 | bellard | if (is_write && page_unprotect(address, pc, puc)) {
|
731 | b453b70b | bellard | return 1; |
732 | b453b70b | bellard | } |
733 | b453b70b | bellard | return 0; |
734 | 93ac68bc | bellard | } |
735 | 67867308 | bellard | #elif defined (TARGET_PPC)
|
736 | 67867308 | bellard | static inline int handle_cpu_signal(unsigned long pc, unsigned long address, |
737 | bf3e8bf1 | bellard | int is_write, sigset_t *old_set,
|
738 | bf3e8bf1 | bellard | void *puc)
|
739 | 67867308 | bellard | { |
740 | 67867308 | bellard | TranslationBlock *tb; |
741 | ce09776b | bellard | int ret;
|
742 | 67867308 | bellard | |
743 | ce09776b | bellard | #if 1 |
744 | 67867308 | bellard | if (cpu_single_env)
|
745 | 67867308 | bellard | env = cpu_single_env; /* XXX: find a correct solution for multithread */
|
746 | 67867308 | bellard | #endif
|
747 | 67867308 | bellard | #if defined(DEBUG_SIGNAL)
|
748 | 67867308 | bellard | printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
|
749 | 67867308 | bellard | pc, address, is_write, *(unsigned long *)old_set); |
750 | 67867308 | bellard | #endif
|
751 | 67867308 | bellard | /* XXX: locking issue */
|
752 | fbf9eeb3 | bellard | if (is_write && page_unprotect(address, pc, puc)) {
|
753 | 67867308 | bellard | return 1; |
754 | 67867308 | bellard | } |
755 | 67867308 | bellard | |
756 | ce09776b | bellard | /* see if it is an MMU fault */
|
757 | 7f957d28 | bellard | ret = cpu_ppc_handle_mmu_fault(env, address, is_write, msr_pr, 0);
|
758 | ce09776b | bellard | if (ret < 0) |
759 | ce09776b | bellard | return 0; /* not an MMU fault */ |
760 | ce09776b | bellard | if (ret == 0) |
761 | ce09776b | bellard | return 1; /* the MMU fault was handled without causing real CPU fault */ |
762 | ce09776b | bellard | |
763 | 67867308 | bellard | /* now we have a real cpu fault */
|
764 | 67867308 | bellard | tb = tb_find_pc(pc); |
765 | 67867308 | bellard | if (tb) {
|
766 | 67867308 | bellard | /* the PC is inside the translated code. It means that we have
|
767 | 67867308 | bellard | a virtual CPU fault */
|
768 | bf3e8bf1 | bellard | cpu_restore_state(tb, env, pc, puc); |
769 | 67867308 | bellard | } |
770 | ce09776b | bellard | if (ret == 1) { |
771 | 67867308 | bellard | #if 0
|
772 | ce09776b | bellard | printf("PF exception: NIP=0x%08x error=0x%x %p\n",
|
773 | ce09776b | bellard | env->nip, env->error_code, tb);
|
774 | 67867308 | bellard | #endif
|
775 | 67867308 | bellard | /* we restore the process signal mask as the sigreturn should
|
776 | 67867308 | bellard | do it (XXX: use sigsetjmp) */
|
777 | bf3e8bf1 | bellard | sigprocmask(SIG_SETMASK, old_set, NULL);
|
778 | 9fddaa0c | bellard | do_raise_exception_err(env->exception_index, env->error_code); |
779 | ce09776b | bellard | } else {
|
780 | ce09776b | bellard | /* activate soft MMU for this block */
|
781 | fbf9eeb3 | bellard | cpu_resume_from_signal(env, puc); |
782 | ce09776b | bellard | } |
783 | 67867308 | bellard | /* never comes here */
|
784 | 67867308 | bellard | return 1; |
785 | 67867308 | bellard | } |
786 | e4533c7a | bellard | #else
|
787 | e4533c7a | bellard | #error unsupported target CPU
|
788 | e4533c7a | bellard | #endif
|
789 | 9de5e440 | bellard | |
790 | 2b413144 | bellard | #if defined(__i386__)
|
791 | 2b413144 | bellard | |
792 | bf3e8bf1 | bellard | #if defined(USE_CODE_COPY)
|
793 | bf3e8bf1 | bellard | static void cpu_send_trap(unsigned long pc, int trap, |
794 | bf3e8bf1 | bellard | struct ucontext *uc)
|
795 | bf3e8bf1 | bellard | { |
796 | bf3e8bf1 | bellard | TranslationBlock *tb; |
797 | bf3e8bf1 | bellard | |
798 | bf3e8bf1 | bellard | if (cpu_single_env)
|
799 | bf3e8bf1 | bellard | env = cpu_single_env; /* XXX: find a correct solution for multithread */
|
800 | bf3e8bf1 | bellard | /* now we have a real cpu fault */
|
801 | bf3e8bf1 | bellard | tb = tb_find_pc(pc); |
802 | bf3e8bf1 | bellard | if (tb) {
|
803 | bf3e8bf1 | bellard | /* the PC is inside the translated code. It means that we have
|
804 | bf3e8bf1 | bellard | a virtual CPU fault */
|
805 | bf3e8bf1 | bellard | cpu_restore_state(tb, env, pc, uc); |
806 | bf3e8bf1 | bellard | } |
807 | bf3e8bf1 | bellard | sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
|
808 | bf3e8bf1 | bellard | raise_exception_err(trap, env->error_code); |
809 | bf3e8bf1 | bellard | } |
810 | bf3e8bf1 | bellard | #endif
|
811 | bf3e8bf1 | bellard | |
812 | e4533c7a | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
813 | e4533c7a | bellard | void *puc)
|
814 | 9de5e440 | bellard | { |
815 | 9de5e440 | bellard | struct ucontext *uc = puc;
|
816 | 9de5e440 | bellard | unsigned long pc; |
817 | bf3e8bf1 | bellard | int trapno;
|
818 | 97eb5b14 | bellard | |
819 | d691f669 | bellard | #ifndef REG_EIP
|
820 | d691f669 | bellard | /* for glibc 2.1 */
|
821 | fd6ce8f6 | bellard | #define REG_EIP EIP
|
822 | fd6ce8f6 | bellard | #define REG_ERR ERR
|
823 | fd6ce8f6 | bellard | #define REG_TRAPNO TRAPNO
|
824 | d691f669 | bellard | #endif
|
825 | fc2b4c48 | bellard | pc = uc->uc_mcontext.gregs[REG_EIP]; |
826 | bf3e8bf1 | bellard | trapno = uc->uc_mcontext.gregs[REG_TRAPNO]; |
827 | bf3e8bf1 | bellard | #if defined(TARGET_I386) && defined(USE_CODE_COPY)
|
828 | bf3e8bf1 | bellard | if (trapno == 0x00 || trapno == 0x05) { |
829 | bf3e8bf1 | bellard | /* send division by zero or bound exception */
|
830 | bf3e8bf1 | bellard | cpu_send_trap(pc, trapno, uc); |
831 | bf3e8bf1 | bellard | return 1; |
832 | bf3e8bf1 | bellard | } else
|
833 | bf3e8bf1 | bellard | #endif
|
834 | bf3e8bf1 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
835 | bf3e8bf1 | bellard | trapno == 0xe ?
|
836 | bf3e8bf1 | bellard | (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0, |
837 | bf3e8bf1 | bellard | &uc->uc_sigmask, puc); |
838 | 2b413144 | bellard | } |
839 | 2b413144 | bellard | |
840 | bc51c5c9 | bellard | #elif defined(__x86_64__)
|
841 | bc51c5c9 | bellard | |
842 | bc51c5c9 | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
843 | bc51c5c9 | bellard | void *puc)
|
844 | bc51c5c9 | bellard | { |
845 | bc51c5c9 | bellard | struct ucontext *uc = puc;
|
846 | bc51c5c9 | bellard | unsigned long pc; |
847 | bc51c5c9 | bellard | |
848 | bc51c5c9 | bellard | pc = uc->uc_mcontext.gregs[REG_RIP]; |
849 | bc51c5c9 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
850 | bc51c5c9 | bellard | uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe ?
|
851 | bc51c5c9 | bellard | (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0, |
852 | bc51c5c9 | bellard | &uc->uc_sigmask, puc); |
853 | bc51c5c9 | bellard | } |
854 | bc51c5c9 | bellard | |
855 | 83fb7adf | bellard | #elif defined(__powerpc__)
|
856 | 2b413144 | bellard | |
857 | 83fb7adf | bellard | /***********************************************************************
|
858 | 83fb7adf | bellard | * signal context platform-specific definitions
|
859 | 83fb7adf | bellard | * From Wine
|
860 | 83fb7adf | bellard | */
|
861 | 83fb7adf | bellard | #ifdef linux
|
862 | 83fb7adf | bellard | /* All Registers access - only for local access */
|
863 | 83fb7adf | bellard | # define REG_sig(reg_name, context) ((context)->uc_mcontext.regs->reg_name)
|
864 | 83fb7adf | bellard | /* Gpr Registers access */
|
865 | 83fb7adf | bellard | # define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], context)
|
866 | 83fb7adf | bellard | # define IAR_sig(context) REG_sig(nip, context) /* Program counter */ |
867 | 83fb7adf | bellard | # define MSR_sig(context) REG_sig(msr, context) /* Machine State Register (Supervisor) */ |
868 | 83fb7adf | bellard | # define CTR_sig(context) REG_sig(ctr, context) /* Count register */ |
869 | 83fb7adf | bellard | # define XER_sig(context) REG_sig(xer, context) /* User's integer exception register */ |
870 | 83fb7adf | bellard | # define LR_sig(context) REG_sig(link, context) /* Link register */ |
871 | 83fb7adf | bellard | # define CR_sig(context) REG_sig(ccr, context) /* Condition register */ |
872 | 83fb7adf | bellard | /* Float Registers access */
|
873 | 83fb7adf | bellard | # define FLOAT_sig(reg_num, context) (((double*)((char*)((context)->uc_mcontext.regs+48*4)))[reg_num]) |
874 | 83fb7adf | bellard | # define FPSCR_sig(context) (*(int*)((char*)((context)->uc_mcontext.regs+(48+32*2)*4))) |
875 | 83fb7adf | bellard | /* Exception Registers access */
|
876 | 83fb7adf | bellard | # define DAR_sig(context) REG_sig(dar, context)
|
877 | 83fb7adf | bellard | # define DSISR_sig(context) REG_sig(dsisr, context)
|
878 | 83fb7adf | bellard | # define TRAP_sig(context) REG_sig(trap, context)
|
879 | 83fb7adf | bellard | #endif /* linux */ |
880 | 83fb7adf | bellard | |
881 | 83fb7adf | bellard | #ifdef __APPLE__
|
882 | 83fb7adf | bellard | # include <sys/ucontext.h> |
883 | 83fb7adf | bellard | typedef struct ucontext SIGCONTEXT; |
884 | 83fb7adf | bellard | /* All Registers access - only for local access */
|
885 | 83fb7adf | bellard | # define REG_sig(reg_name, context) ((context)->uc_mcontext->ss.reg_name)
|
886 | 83fb7adf | bellard | # define FLOATREG_sig(reg_name, context) ((context)->uc_mcontext->fs.reg_name)
|
887 | 83fb7adf | bellard | # define EXCEPREG_sig(reg_name, context) ((context)->uc_mcontext->es.reg_name)
|
888 | 83fb7adf | bellard | # define VECREG_sig(reg_name, context) ((context)->uc_mcontext->vs.reg_name)
|
889 | 83fb7adf | bellard | /* Gpr Registers access */
|
890 | 83fb7adf | bellard | # define GPR_sig(reg_num, context) REG_sig(r##reg_num, context) |
891 | 83fb7adf | bellard | # define IAR_sig(context) REG_sig(srr0, context) /* Program counter */ |
892 | 83fb7adf | bellard | # define MSR_sig(context) REG_sig(srr1, context) /* Machine State Register (Supervisor) */ |
893 | 83fb7adf | bellard | # define CTR_sig(context) REG_sig(ctr, context)
|
894 | 83fb7adf | bellard | # define XER_sig(context) REG_sig(xer, context) /* Link register */ |
895 | 83fb7adf | bellard | # define LR_sig(context) REG_sig(lr, context) /* User's integer exception register */ |
896 | 83fb7adf | bellard | # define CR_sig(context) REG_sig(cr, context) /* Condition register */ |
897 | 83fb7adf | bellard | /* Float Registers access */
|
898 | 83fb7adf | bellard | # define FLOAT_sig(reg_num, context) FLOATREG_sig(fpregs[reg_num], context)
|
899 | 83fb7adf | bellard | # define FPSCR_sig(context) ((double)FLOATREG_sig(fpscr, context)) |
900 | 83fb7adf | bellard | /* Exception Registers access */
|
901 | 83fb7adf | bellard | # define DAR_sig(context) EXCEPREG_sig(dar, context) /* Fault registers for coredump */ |
902 | 83fb7adf | bellard | # define DSISR_sig(context) EXCEPREG_sig(dsisr, context)
|
903 | 83fb7adf | bellard | # define TRAP_sig(context) EXCEPREG_sig(exception, context) /* number of powerpc exception taken */ |
904 | 83fb7adf | bellard | #endif /* __APPLE__ */ |
905 | 83fb7adf | bellard | |
906 | d1d9f421 | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
907 | e4533c7a | bellard | void *puc)
|
908 | 2b413144 | bellard | { |
909 | 25eb4484 | bellard | struct ucontext *uc = puc;
|
910 | 25eb4484 | bellard | unsigned long pc; |
911 | 25eb4484 | bellard | int is_write;
|
912 | 25eb4484 | bellard | |
913 | 83fb7adf | bellard | pc = IAR_sig(uc); |
914 | 25eb4484 | bellard | is_write = 0;
|
915 | 25eb4484 | bellard | #if 0
|
916 | 25eb4484 | bellard | /* ppc 4xx case */
|
917 | 83fb7adf | bellard | if (DSISR_sig(uc) & 0x00800000)
|
918 | 25eb4484 | bellard | is_write = 1;
|
919 | 25eb4484 | bellard | #else
|
920 | 83fb7adf | bellard | if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000)) |
921 | 25eb4484 | bellard | is_write = 1;
|
922 | 25eb4484 | bellard | #endif
|
923 | 25eb4484 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
924 | bf3e8bf1 | bellard | is_write, &uc->uc_sigmask, puc); |
925 | 2b413144 | bellard | } |
926 | 2b413144 | bellard | |
927 | 2f87c607 | bellard | #elif defined(__alpha__)
|
928 | 2f87c607 | bellard | |
929 | e4533c7a | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
930 | 2f87c607 | bellard | void *puc)
|
931 | 2f87c607 | bellard | { |
932 | 2f87c607 | bellard | struct ucontext *uc = puc;
|
933 | 2f87c607 | bellard | uint32_t *pc = uc->uc_mcontext.sc_pc; |
934 | 2f87c607 | bellard | uint32_t insn = *pc; |
935 | 2f87c607 | bellard | int is_write = 0; |
936 | 2f87c607 | bellard | |
937 | 8c6939c0 | bellard | /* XXX: need kernel patch to get write flag faster */
|
938 | 2f87c607 | bellard | switch (insn >> 26) { |
939 | 2f87c607 | bellard | case 0x0d: // stw |
940 | 2f87c607 | bellard | case 0x0e: // stb |
941 | 2f87c607 | bellard | case 0x0f: // stq_u |
942 | 2f87c607 | bellard | case 0x24: // stf |
943 | 2f87c607 | bellard | case 0x25: // stg |
944 | 2f87c607 | bellard | case 0x26: // sts |
945 | 2f87c607 | bellard | case 0x27: // stt |
946 | 2f87c607 | bellard | case 0x2c: // stl |
947 | 2f87c607 | bellard | case 0x2d: // stq |
948 | 2f87c607 | bellard | case 0x2e: // stl_c |
949 | 2f87c607 | bellard | case 0x2f: // stq_c |
950 | 2f87c607 | bellard | is_write = 1;
|
951 | 2f87c607 | bellard | } |
952 | 2f87c607 | bellard | |
953 | 2f87c607 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
954 | bf3e8bf1 | bellard | is_write, &uc->uc_sigmask, puc); |
955 | 2f87c607 | bellard | } |
956 | 8c6939c0 | bellard | #elif defined(__sparc__)
|
957 | 8c6939c0 | bellard | |
958 | e4533c7a | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
959 | e4533c7a | bellard | void *puc)
|
960 | 8c6939c0 | bellard | { |
961 | 8c6939c0 | bellard | uint32_t *regs = (uint32_t *)(info + 1);
|
962 | 8c6939c0 | bellard | void *sigmask = (regs + 20); |
963 | 8c6939c0 | bellard | unsigned long pc; |
964 | 8c6939c0 | bellard | int is_write;
|
965 | 8c6939c0 | bellard | uint32_t insn; |
966 | 8c6939c0 | bellard | |
967 | 8c6939c0 | bellard | /* XXX: is there a standard glibc define ? */
|
968 | 8c6939c0 | bellard | pc = regs[1];
|
969 | 8c6939c0 | bellard | /* XXX: need kernel patch to get write flag faster */
|
970 | 8c6939c0 | bellard | is_write = 0;
|
971 | 8c6939c0 | bellard | insn = *(uint32_t *)pc; |
972 | 8c6939c0 | bellard | if ((insn >> 30) == 3) { |
973 | 8c6939c0 | bellard | switch((insn >> 19) & 0x3f) { |
974 | 8c6939c0 | bellard | case 0x05: // stb |
975 | 8c6939c0 | bellard | case 0x06: // sth |
976 | 8c6939c0 | bellard | case 0x04: // st |
977 | 8c6939c0 | bellard | case 0x07: // std |
978 | 8c6939c0 | bellard | case 0x24: // stf |
979 | 8c6939c0 | bellard | case 0x27: // stdf |
980 | 8c6939c0 | bellard | case 0x25: // stfsr |
981 | 8c6939c0 | bellard | is_write = 1;
|
982 | 8c6939c0 | bellard | break;
|
983 | 8c6939c0 | bellard | } |
984 | 8c6939c0 | bellard | } |
985 | 8c6939c0 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
986 | bf3e8bf1 | bellard | is_write, sigmask, NULL);
|
987 | 8c6939c0 | bellard | } |
988 | 8c6939c0 | bellard | |
989 | 8c6939c0 | bellard | #elif defined(__arm__)
|
990 | 8c6939c0 | bellard | |
991 | e4533c7a | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
992 | e4533c7a | bellard | void *puc)
|
993 | 8c6939c0 | bellard | { |
994 | 8c6939c0 | bellard | struct ucontext *uc = puc;
|
995 | 8c6939c0 | bellard | unsigned long pc; |
996 | 8c6939c0 | bellard | int is_write;
|
997 | 8c6939c0 | bellard | |
998 | 8c6939c0 | bellard | pc = uc->uc_mcontext.gregs[R15]; |
999 | 8c6939c0 | bellard | /* XXX: compute is_write */
|
1000 | 8c6939c0 | bellard | is_write = 0;
|
1001 | 8c6939c0 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
1002 | 8c6939c0 | bellard | is_write, |
1003 | 8c6939c0 | bellard | &uc->uc_sigmask); |
1004 | 8c6939c0 | bellard | } |
1005 | 8c6939c0 | bellard | |
1006 | 38e584a0 | bellard | #elif defined(__mc68000)
|
1007 | 38e584a0 | bellard | |
1008 | 38e584a0 | bellard | int cpu_signal_handler(int host_signum, struct siginfo *info, |
1009 | 38e584a0 | bellard | void *puc)
|
1010 | 38e584a0 | bellard | { |
1011 | 38e584a0 | bellard | struct ucontext *uc = puc;
|
1012 | 38e584a0 | bellard | unsigned long pc; |
1013 | 38e584a0 | bellard | int is_write;
|
1014 | 38e584a0 | bellard | |
1015 | 38e584a0 | bellard | pc = uc->uc_mcontext.gregs[16];
|
1016 | 38e584a0 | bellard | /* XXX: compute is_write */
|
1017 | 38e584a0 | bellard | is_write = 0;
|
1018 | 38e584a0 | bellard | return handle_cpu_signal(pc, (unsigned long)info->si_addr, |
1019 | 38e584a0 | bellard | is_write, |
1020 | bf3e8bf1 | bellard | &uc->uc_sigmask, puc); |
1021 | 38e584a0 | bellard | } |
1022 | 38e584a0 | bellard | |
1023 | 9de5e440 | bellard | #else
|
1024 | 2b413144 | bellard | |
1025 | 3fb2ded1 | bellard | #error host CPU specific signal handler needed
|
1026 | 2b413144 | bellard | |
1027 | 9de5e440 | bellard | #endif
|
1028 | 67b915a5 | bellard | |
1029 | 67b915a5 | bellard | #endif /* !defined(CONFIG_SOFTMMU) */ |