blob: 1ec49c2d6a3faec83718ece3cbabc9a41dd65564 [file] [log] [blame]
bellard7d132992003-03-06 23:23:54 +00001/*
2 * i386 emulator main execution loop
3 *
bellard66321a12005-04-06 20:47:48 +00004 * Copyright (c) 2003-2005 Fabrice Bellard
bellard7d132992003-03-06 23:23:54 +00005 *
bellard3ef693a2003-03-23 20:17:16 +00006 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
bellard7d132992003-03-06 23:23:54 +000010 *
bellard3ef693a2003-03-23 20:17:16 +000011 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
bellard7d132992003-03-06 23:23:54 +000015 *
bellard3ef693a2003-03-23 20:17:16 +000016 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
bellard7d132992003-03-06 23:23:54 +000019 */
bellarde4533c72003-06-15 19:51:39 +000020#include "config.h"
bellard93ac68b2003-09-30 20:57:29 +000021#include "exec.h"
bellard956034d2003-04-29 20:40:53 +000022#include "disas.h"
bellard7d132992003-03-06 23:23:54 +000023
bellardfbf9eeb2004-04-25 21:21:33 +000024#if !defined(CONFIG_SOFTMMU)
25#undef EAX
26#undef ECX
27#undef EDX
28#undef EBX
29#undef ESP
30#undef EBP
31#undef ESI
32#undef EDI
33#undef EIP
34#include <signal.h>
35#include <sys/ucontext.h>
36#endif
37
bellard36bdbe52003-11-19 22:12:02 +000038int tb_invalidated_flag;
39
bellarddc990652003-03-19 00:00:28 +000040//#define DEBUG_EXEC
bellard9de5e442003-03-23 16:49:39 +000041//#define DEBUG_SIGNAL
bellard7d132992003-03-06 23:23:54 +000042
bellard93ac68b2003-09-30 20:57:29 +000043#if defined(TARGET_ARM) || defined(TARGET_SPARC)
bellarde4533c72003-06-15 19:51:39 +000044/* XXX: unify with i386 target */
45void cpu_loop_exit(void)
46{
47 longjmp(env->jmp_env, 1);
48}
49#endif
bellard34751872005-07-02 14:31:34 +000050#ifndef TARGET_SPARC
51#define reg_T2
52#endif
bellarde4533c72003-06-15 19:51:39 +000053
bellardfbf9eeb2004-04-25 21:21:33 +000054/* exit the current TB from a signal handler. The host registers are
55 restored in a state compatible with the CPU emulator
56 */
57void cpu_resume_from_signal(CPUState *env1, void *puc)
58{
59#if !defined(CONFIG_SOFTMMU)
60 struct ucontext *uc = puc;
61#endif
62
63 env = env1;
64
65 /* XXX: restore cpu registers saved in host registers */
66
67#if !defined(CONFIG_SOFTMMU)
68 if (puc) {
69 /* XXX: use siglongjmp ? */
70 sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
71 }
72#endif
73 longjmp(env->jmp_env, 1);
74}
75
bellard8a40a182005-11-20 10:35:40 +000076
77static TranslationBlock *tb_find_slow(target_ulong pc,
78 target_ulong cs_base,
79 unsigned int flags)
80{
81 TranslationBlock *tb, **ptb1;
82 int code_gen_size;
83 unsigned int h;
84 target_ulong phys_pc, phys_page1, phys_page2, virt_page2;
85 uint8_t *tc_ptr;
86
87 spin_lock(&tb_lock);
88
89 tb_invalidated_flag = 0;
90
91 regs_to_env(); /* XXX: do it just before cpu_gen_code() */
92
93 /* find translated block using physical mappings */
94 phys_pc = get_phys_addr_code(env, pc);
95 phys_page1 = phys_pc & TARGET_PAGE_MASK;
96 phys_page2 = -1;
97 h = tb_phys_hash_func(phys_pc);
98 ptb1 = &tb_phys_hash[h];
99 for(;;) {
100 tb = *ptb1;
101 if (!tb)
102 goto not_found;
103 if (tb->pc == pc &&
104 tb->page_addr[0] == phys_page1 &&
105 tb->cs_base == cs_base &&
106 tb->flags == flags) {
107 /* check next page if needed */
108 if (tb->page_addr[1] != -1) {
109 virt_page2 = (pc & TARGET_PAGE_MASK) +
110 TARGET_PAGE_SIZE;
111 phys_page2 = get_phys_addr_code(env, virt_page2);
112 if (tb->page_addr[1] == phys_page2)
113 goto found;
114 } else {
115 goto found;
116 }
117 }
118 ptb1 = &tb->phys_hash_next;
119 }
120 not_found:
121 /* if no translated code available, then translate it now */
122 tb = tb_alloc(pc);
123 if (!tb) {
124 /* flush must be done */
125 tb_flush(env);
126 /* cannot fail at this point */
127 tb = tb_alloc(pc);
128 /* don't forget to invalidate previous TB info */
bellard15388002005-12-19 01:42:32 +0000129 tb_invalidated_flag = 1;
bellard8a40a182005-11-20 10:35:40 +0000130 }
131 tc_ptr = code_gen_ptr;
132 tb->tc_ptr = tc_ptr;
133 tb->cs_base = cs_base;
134 tb->flags = flags;
135 cpu_gen_code(env, tb, CODE_GEN_MAX_SIZE, &code_gen_size);
136 code_gen_ptr = (void *)(((unsigned long)code_gen_ptr + code_gen_size + CODE_GEN_ALIGN - 1) & ~(CODE_GEN_ALIGN - 1));
137
138 /* check next page if needed */
139 virt_page2 = (pc + tb->size - 1) & TARGET_PAGE_MASK;
140 phys_page2 = -1;
141 if ((pc & TARGET_PAGE_MASK) != virt_page2) {
142 phys_page2 = get_phys_addr_code(env, virt_page2);
143 }
144 tb_link_phys(tb, phys_pc, phys_page2);
145
146 found:
bellard8a40a182005-11-20 10:35:40 +0000147 /* we add the TB in the virtual pc hash table */
148 env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)] = tb;
149 spin_unlock(&tb_lock);
150 return tb;
151}
152
153static inline TranslationBlock *tb_find_fast(void)
154{
155 TranslationBlock *tb;
156 target_ulong cs_base, pc;
157 unsigned int flags;
158
159 /* we record a subset of the CPU state. It will
160 always be the same before a given translated block
161 is executed. */
162#if defined(TARGET_I386)
163 flags = env->hflags;
164 flags |= (env->eflags & (IOPL_MASK | TF_MASK | VM_MASK));
165 cs_base = env->segs[R_CS].base;
166 pc = cs_base + env->eip;
167#elif defined(TARGET_ARM)
168 flags = env->thumb | (env->vfp.vec_len << 1)
bellardb5ff1b32005-11-26 10:38:39 +0000169 | (env->vfp.vec_stride << 4);
170 if ((env->uncached_cpsr & CPSR_M) != ARM_CPU_MODE_USR)
171 flags |= (1 << 6);
bellard8a40a182005-11-20 10:35:40 +0000172 cs_base = 0;
173 pc = env->regs[15];
174#elif defined(TARGET_SPARC)
175#ifdef TARGET_SPARC64
176 flags = (env->pstate << 2) | ((env->lsu & (DMMU_E | IMMU_E)) >> 2);
177#else
178 flags = env->psrs | ((env->mmuregs[0] & (MMU_E | MMU_NF)) << 1);
179#endif
180 cs_base = env->npc;
181 pc = env->pc;
182#elif defined(TARGET_PPC)
183 flags = (msr_pr << MSR_PR) | (msr_fp << MSR_FP) |
184 (msr_se << MSR_SE) | (msr_le << MSR_LE);
185 cs_base = 0;
186 pc = env->nip;
187#elif defined(TARGET_MIPS)
bellard6810e152005-12-05 19:59:05 +0000188 flags = env->hflags & (MIPS_HFLAGS_TMASK | MIPS_HFLAG_BMASK);
bellardcc9442b2005-11-26 18:43:28 +0000189 cs_base = 0;
bellard8a40a182005-11-20 10:35:40 +0000190 pc = env->PC;
191#else
192#error unsupported CPU
193#endif
194 tb = env->tb_jmp_cache[tb_jmp_cache_hash_func(pc)];
195 if (__builtin_expect(!tb || tb->pc != pc || tb->cs_base != cs_base ||
196 tb->flags != flags, 0)) {
197 tb = tb_find_slow(pc, cs_base, flags);
bellard15388002005-12-19 01:42:32 +0000198 /* Note: we do it here to avoid a gcc bug on Mac OS X when
199 doing it in tb_find_slow */
200 if (tb_invalidated_flag) {
201 /* as some TB could have been invalidated because
202 of memory exceptions while generating the code, we
203 must recompute the hash index here */
204 T0 = 0;
205 }
bellard8a40a182005-11-20 10:35:40 +0000206 }
207 return tb;
208}
209
210
bellard7d132992003-03-06 23:23:54 +0000211/* main execution loop */
212
bellarde4533c72003-06-15 19:51:39 +0000213int cpu_exec(CPUState *env1)
bellard7d132992003-03-06 23:23:54 +0000214{
bellard34751872005-07-02 14:31:34 +0000215 int saved_T0, saved_T1;
216#if defined(reg_T2)
217 int saved_T2;
218#endif
bellarde4533c72003-06-15 19:51:39 +0000219 CPUState *saved_env;
bellard34751872005-07-02 14:31:34 +0000220#if defined(TARGET_I386)
bellard04369ff2003-03-20 22:33:23 +0000221#ifdef reg_EAX
222 int saved_EAX;
223#endif
224#ifdef reg_ECX
225 int saved_ECX;
226#endif
227#ifdef reg_EDX
228 int saved_EDX;
229#endif
230#ifdef reg_EBX
231 int saved_EBX;
232#endif
233#ifdef reg_ESP
234 int saved_ESP;
235#endif
236#ifdef reg_EBP
237 int saved_EBP;
238#endif
239#ifdef reg_ESI
240 int saved_ESI;
241#endif
242#ifdef reg_EDI
243 int saved_EDI;
244#endif
bellard34751872005-07-02 14:31:34 +0000245#elif defined(TARGET_SPARC)
246#if defined(reg_REGWPTR)
247 uint32_t *saved_regwptr;
248#endif
249#endif
bellard8c6939c2003-06-09 15:28:00 +0000250#ifdef __sparc__
251 int saved_i7, tmp_T0;
252#endif
bellard8a40a182005-11-20 10:35:40 +0000253 int ret, interrupt_request;
bellard7d132992003-03-06 23:23:54 +0000254 void (*gen_func)(void);
bellard8a40a182005-11-20 10:35:40 +0000255 TranslationBlock *tb;
bellardc27004e2005-01-03 23:35:10 +0000256 uint8_t *tc_ptr;
bellard8c6939c2003-06-09 15:28:00 +0000257
bellard5a1e3cf2005-11-23 21:02:53 +0000258#if defined(TARGET_I386)
259 /* handle exit of HALTED state */
260 if (env1->hflags & HF_HALTED_MASK) {
261 /* disable halt condition */
262 if ((env1->interrupt_request & CPU_INTERRUPT_HARD) &&
263 (env1->eflags & IF_MASK)) {
264 env1->hflags &= ~HF_HALTED_MASK;
265 } else {
266 return EXCP_HALTED;
267 }
268 }
bellarde80e1cc2005-11-23 22:05:28 +0000269#elif defined(TARGET_PPC)
bellard50443c92005-11-26 20:15:14 +0000270 if (env1->halted) {
bellarde80e1cc2005-11-23 22:05:28 +0000271 if (env1->msr[MSR_EE] &&
272 (env1->interrupt_request &
273 (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER))) {
bellard50443c92005-11-26 20:15:14 +0000274 env1->halted = 0;
bellarde80e1cc2005-11-23 22:05:28 +0000275 } else {
276 return EXCP_HALTED;
277 }
278 }
bellardba3c64f2005-12-05 20:31:52 +0000279#elif defined(TARGET_SPARC)
280 if (env1->halted) {
281 if ((env1->interrupt_request & CPU_INTERRUPT_HARD) &&
282 (env1->psret != 0)) {
283 env1->halted = 0;
284 } else {
285 return EXCP_HALTED;
286 }
287 }
bellard9332f9d2005-11-26 10:46:39 +0000288#elif defined(TARGET_ARM)
289 if (env1->halted) {
290 /* An interrupt wakes the CPU even if the I and F CPSR bits are
291 set. */
292 if (env1->interrupt_request
293 & (CPU_INTERRUPT_FIQ | CPU_INTERRUPT_HARD)) {
294 env1->halted = 0;
295 } else {
296 return EXCP_HALTED;
297 }
298 }
bellard6810e152005-12-05 19:59:05 +0000299#elif defined(TARGET_MIPS)
300 if (env1->halted) {
301 if (env1->interrupt_request &
302 (CPU_INTERRUPT_HARD | CPU_INTERRUPT_TIMER)) {
303 env1->halted = 0;
304 } else {
305 return EXCP_HALTED;
306 }
307 }
bellard5a1e3cf2005-11-23 21:02:53 +0000308#endif
309
bellard6a00d602005-11-21 23:25:50 +0000310 cpu_single_env = env1;
311
bellard7d132992003-03-06 23:23:54 +0000312 /* first we save global registers */
bellardc27004e2005-01-03 23:35:10 +0000313 saved_env = env;
314 env = env1;
bellard7d132992003-03-06 23:23:54 +0000315 saved_T0 = T0;
316 saved_T1 = T1;
bellard34751872005-07-02 14:31:34 +0000317#if defined(reg_T2)
bellarde4533c72003-06-15 19:51:39 +0000318 saved_T2 = T2;
bellard34751872005-07-02 14:31:34 +0000319#endif
bellarde4533c72003-06-15 19:51:39 +0000320#ifdef __sparc__
321 /* we also save i7 because longjmp may not restore it */
322 asm volatile ("mov %%i7, %0" : "=r" (saved_i7));
323#endif
324
325#if defined(TARGET_I386)
bellard04369ff2003-03-20 22:33:23 +0000326#ifdef reg_EAX
327 saved_EAX = EAX;
bellard04369ff2003-03-20 22:33:23 +0000328#endif
329#ifdef reg_ECX
330 saved_ECX = ECX;
bellard04369ff2003-03-20 22:33:23 +0000331#endif
332#ifdef reg_EDX
333 saved_EDX = EDX;
bellard04369ff2003-03-20 22:33:23 +0000334#endif
335#ifdef reg_EBX
336 saved_EBX = EBX;
bellard04369ff2003-03-20 22:33:23 +0000337#endif
338#ifdef reg_ESP
339 saved_ESP = ESP;
bellard04369ff2003-03-20 22:33:23 +0000340#endif
341#ifdef reg_EBP
342 saved_EBP = EBP;
bellard04369ff2003-03-20 22:33:23 +0000343#endif
344#ifdef reg_ESI
345 saved_ESI = ESI;
bellard04369ff2003-03-20 22:33:23 +0000346#endif
347#ifdef reg_EDI
348 saved_EDI = EDI;
bellard04369ff2003-03-20 22:33:23 +0000349#endif
bellard0d1a29f2004-10-12 22:01:28 +0000350
351 env_to_regs();
bellard9de5e442003-03-23 16:49:39 +0000352 /* put eflags in CPU temporary format */
bellardfc2b4c42003-03-29 16:52:44 +0000353 CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
354 DF = 1 - (2 * ((env->eflags >> 10) & 1));
bellard9de5e442003-03-23 16:49:39 +0000355 CC_OP = CC_OP_EFLAGS;
bellardfc2b4c42003-03-29 16:52:44 +0000356 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
bellarde4533c72003-06-15 19:51:39 +0000357#elif defined(TARGET_ARM)
bellard93ac68b2003-09-30 20:57:29 +0000358#elif defined(TARGET_SPARC)
bellard34751872005-07-02 14:31:34 +0000359#if defined(reg_REGWPTR)
360 saved_regwptr = REGWPTR;
361#endif
bellard67867302003-11-23 17:05:30 +0000362#elif defined(TARGET_PPC)
bellard6af0bf92005-07-02 14:58:51 +0000363#elif defined(TARGET_MIPS)
bellarde4533c72003-06-15 19:51:39 +0000364#else
365#error unsupported target CPU
366#endif
bellard3fb2ded2003-06-24 13:22:59 +0000367 env->exception_index = -1;
bellard9d27abd2003-05-10 13:13:54 +0000368
bellard7d132992003-03-06 23:23:54 +0000369 /* prepare setjmp context for exception handling */
bellard3fb2ded2003-06-24 13:22:59 +0000370 for(;;) {
371 if (setjmp(env->jmp_env) == 0) {
bellardee8b7022004-02-03 23:35:10 +0000372 env->current_tb = NULL;
bellard3fb2ded2003-06-24 13:22:59 +0000373 /* if an exception is pending, we execute it here */
374 if (env->exception_index >= 0) {
375 if (env->exception_index >= EXCP_INTERRUPT) {
376 /* exit request from the cpu execution loop */
377 ret = env->exception_index;
378 break;
379 } else if (env->user_mode_only) {
380 /* if user mode only, we simulate a fake exception
381 which will be hanlded outside the cpu execution
382 loop */
bellard83479e72003-06-25 16:12:37 +0000383#if defined(TARGET_I386)
bellard3fb2ded2003-06-24 13:22:59 +0000384 do_interrupt_user(env->exception_index,
385 env->exception_is_int,
386 env->error_code,
387 env->exception_next_eip);
bellard83479e72003-06-25 16:12:37 +0000388#endif
bellard3fb2ded2003-06-24 13:22:59 +0000389 ret = env->exception_index;
390 break;
391 } else {
bellard83479e72003-06-25 16:12:37 +0000392#if defined(TARGET_I386)
bellard3fb2ded2003-06-24 13:22:59 +0000393 /* simulate a real cpu exception. On i386, it can
394 trigger new exceptions, but we do not handle
395 double or triple faults yet. */
396 do_interrupt(env->exception_index,
397 env->exception_is_int,
398 env->error_code,
bellardd05e66d2003-08-20 21:34:35 +0000399 env->exception_next_eip, 0);
bellardce097762004-01-04 23:53:18 +0000400#elif defined(TARGET_PPC)
401 do_interrupt(env);
bellard6af0bf92005-07-02 14:58:51 +0000402#elif defined(TARGET_MIPS)
403 do_interrupt(env);
bellarde95c8d52004-09-30 22:22:08 +0000404#elif defined(TARGET_SPARC)
bellard1a0c3292005-02-13 19:02:07 +0000405 do_interrupt(env->exception_index);
bellardb5ff1b32005-11-26 10:38:39 +0000406#elif defined(TARGET_ARM)
407 do_interrupt(env);
bellard83479e72003-06-25 16:12:37 +0000408#endif
bellard3fb2ded2003-06-24 13:22:59 +0000409 }
410 env->exception_index = -1;
bellard9df217a2005-02-10 22:05:51 +0000411 }
412#ifdef USE_KQEMU
413 if (kqemu_is_ok(env) && env->interrupt_request == 0) {
414 int ret;
415 env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
416 ret = kqemu_cpu_exec(env);
417 /* put eflags in CPU temporary format */
418 CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
419 DF = 1 - (2 * ((env->eflags >> 10) & 1));
420 CC_OP = CC_OP_EFLAGS;
421 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
422 if (ret == 1) {
423 /* exception */
424 longjmp(env->jmp_env, 1);
425 } else if (ret == 2) {
426 /* softmmu execution needed */
427 } else {
428 if (env->interrupt_request != 0) {
429 /* hardware interrupt will be executed just after */
430 } else {
431 /* otherwise, we restart */
432 longjmp(env->jmp_env, 1);
433 }
434 }
bellard9de5e442003-03-23 16:49:39 +0000435 }
bellard9df217a2005-02-10 22:05:51 +0000436#endif
437
bellard3fb2ded2003-06-24 13:22:59 +0000438 T0 = 0; /* force lookup of first TB */
439 for(;;) {
440#ifdef __sparc__
441 /* g1 can be modified by some libc? functions */
442 tmp_T0 = T0;
443#endif
bellard68a79312003-06-30 13:12:32 +0000444 interrupt_request = env->interrupt_request;
bellard2e255c62003-08-21 23:25:21 +0000445 if (__builtin_expect(interrupt_request, 0)) {
bellard68a79312003-06-30 13:12:32 +0000446#if defined(TARGET_I386)
447 /* if hardware interrupt pending, we execute it */
448 if ((interrupt_request & CPU_INTERRUPT_HARD) &&
bellard3f337312003-08-20 23:02:09 +0000449 (env->eflags & IF_MASK) &&
450 !(env->hflags & HF_INHIBIT_IRQ_MASK)) {
bellard68a79312003-06-30 13:12:32 +0000451 int intno;
bellardfbf9eeb2004-04-25 21:21:33 +0000452 env->interrupt_request &= ~CPU_INTERRUPT_HARD;
bellarda541f292004-04-12 20:39:29 +0000453 intno = cpu_get_pic_interrupt(env);
bellardf193c792004-03-21 17:06:25 +0000454 if (loglevel & CPU_LOG_TB_IN_ASM) {
bellard68a79312003-06-30 13:12:32 +0000455 fprintf(logfile, "Servicing hardware INT=0x%02x\n", intno);
456 }
bellardd05e66d2003-08-20 21:34:35 +0000457 do_interrupt(intno, 0, 0, 0, 1);
bellard907a5b22003-06-30 23:18:22 +0000458 /* ensure that no TB jump will be modified as
459 the program flow was changed */
460#ifdef __sparc__
461 tmp_T0 = 0;
462#else
463 T0 = 0;
464#endif
bellard68a79312003-06-30 13:12:32 +0000465 }
bellardce097762004-01-04 23:53:18 +0000466#elif defined(TARGET_PPC)
bellard9fddaa02004-05-21 12:59:32 +0000467#if 0
468 if ((interrupt_request & CPU_INTERRUPT_RESET)) {
469 cpu_ppc_reset(env);
470 }
471#endif
472 if (msr_ee != 0) {
bellard8a40a182005-11-20 10:35:40 +0000473 if ((interrupt_request & CPU_INTERRUPT_HARD)) {
bellard9fddaa02004-05-21 12:59:32 +0000474 /* Raise it */
475 env->exception_index = EXCP_EXTERNAL;
476 env->error_code = 0;
bellardce097762004-01-04 23:53:18 +0000477 do_interrupt(env);
bellard8a40a182005-11-20 10:35:40 +0000478 env->interrupt_request &= ~CPU_INTERRUPT_HARD;
479#ifdef __sparc__
480 tmp_T0 = 0;
481#else
482 T0 = 0;
483#endif
484 } else if ((interrupt_request & CPU_INTERRUPT_TIMER)) {
485 /* Raise it */
486 env->exception_index = EXCP_DECR;
487 env->error_code = 0;
488 do_interrupt(env);
bellard9fddaa02004-05-21 12:59:32 +0000489 env->interrupt_request &= ~CPU_INTERRUPT_TIMER;
bellard8a40a182005-11-20 10:35:40 +0000490#ifdef __sparc__
491 tmp_T0 = 0;
492#else
493 T0 = 0;
494#endif
495 }
bellardce097762004-01-04 23:53:18 +0000496 }
bellard6af0bf92005-07-02 14:58:51 +0000497#elif defined(TARGET_MIPS)
498 if ((interrupt_request & CPU_INTERRUPT_HARD) &&
499 (env->CP0_Status & (1 << CP0St_IE)) &&
bellard7ebab692005-08-21 09:43:38 +0000500 (env->CP0_Status & env->CP0_Cause & 0x0000FF00) &&
bellard6af0bf92005-07-02 14:58:51 +0000501 !(env->hflags & MIPS_HFLAG_EXL) &&
502 !(env->hflags & MIPS_HFLAG_ERL) &&
503 !(env->hflags & MIPS_HFLAG_DM)) {
504 /* Raise it */
505 env->exception_index = EXCP_EXT_INTERRUPT;
506 env->error_code = 0;
507 do_interrupt(env);
508 env->interrupt_request &= ~CPU_INTERRUPT_HARD;
bellard8a40a182005-11-20 10:35:40 +0000509#ifdef __sparc__
510 tmp_T0 = 0;
511#else
512 T0 = 0;
513#endif
bellard6af0bf92005-07-02 14:58:51 +0000514 }
bellarde95c8d52004-09-30 22:22:08 +0000515#elif defined(TARGET_SPARC)
bellard66321a12005-04-06 20:47:48 +0000516 if ((interrupt_request & CPU_INTERRUPT_HARD) &&
517 (env->psret != 0)) {
518 int pil = env->interrupt_index & 15;
519 int type = env->interrupt_index & 0xf0;
520
521 if (((type == TT_EXTINT) &&
522 (pil == 15 || pil > env->psrpil)) ||
523 type != TT_EXTINT) {
524 env->interrupt_request &= ~CPU_INTERRUPT_HARD;
525 do_interrupt(env->interrupt_index);
526 env->interrupt_index = 0;
bellard8a40a182005-11-20 10:35:40 +0000527#ifdef __sparc__
528 tmp_T0 = 0;
529#else
530 T0 = 0;
531#endif
bellard66321a12005-04-06 20:47:48 +0000532 }
bellarde95c8d52004-09-30 22:22:08 +0000533 } else if (interrupt_request & CPU_INTERRUPT_TIMER) {
534 //do_interrupt(0, 0, 0, 0, 0);
535 env->interrupt_request &= ~CPU_INTERRUPT_TIMER;
bellardba3c64f2005-12-05 20:31:52 +0000536 } else if (interrupt_request & CPU_INTERRUPT_HALT) {
537 env1->halted = 1;
538 return EXCP_HALTED;
539 }
bellardb5ff1b32005-11-26 10:38:39 +0000540#elif defined(TARGET_ARM)
541 if (interrupt_request & CPU_INTERRUPT_FIQ
542 && !(env->uncached_cpsr & CPSR_F)) {
543 env->exception_index = EXCP_FIQ;
544 do_interrupt(env);
545 }
546 if (interrupt_request & CPU_INTERRUPT_HARD
547 && !(env->uncached_cpsr & CPSR_I)) {
548 env->exception_index = EXCP_IRQ;
549 do_interrupt(env);
550 }
bellard68a79312003-06-30 13:12:32 +0000551#endif
bellardb5ff1b32005-11-26 10:38:39 +0000552 if (env->interrupt_request & CPU_INTERRUPT_EXITTB) {
bellardbf3e8bf2004-02-16 21:58:54 +0000553 env->interrupt_request &= ~CPU_INTERRUPT_EXITTB;
554 /* ensure that no TB jump will be modified as
555 the program flow was changed */
556#ifdef __sparc__
557 tmp_T0 = 0;
558#else
559 T0 = 0;
560#endif
561 }
bellard68a79312003-06-30 13:12:32 +0000562 if (interrupt_request & CPU_INTERRUPT_EXIT) {
563 env->interrupt_request &= ~CPU_INTERRUPT_EXIT;
564 env->exception_index = EXCP_INTERRUPT;
565 cpu_loop_exit();
566 }
bellard3fb2ded2003-06-24 13:22:59 +0000567 }
568#ifdef DEBUG_EXEC
bellardb5ff1b32005-11-26 10:38:39 +0000569 if ((loglevel & CPU_LOG_TB_CPU)) {
bellard3fb2ded2003-06-24 13:22:59 +0000570#if defined(TARGET_I386)
571 /* restore flags in standard format */
bellardfc9f7152005-04-26 19:33:35 +0000572#ifdef reg_EAX
bellard3fb2ded2003-06-24 13:22:59 +0000573 env->regs[R_EAX] = EAX;
bellardfc9f7152005-04-26 19:33:35 +0000574#endif
575#ifdef reg_EBX
bellard3fb2ded2003-06-24 13:22:59 +0000576 env->regs[R_EBX] = EBX;
bellardfc9f7152005-04-26 19:33:35 +0000577#endif
578#ifdef reg_ECX
bellard3fb2ded2003-06-24 13:22:59 +0000579 env->regs[R_ECX] = ECX;
bellardfc9f7152005-04-26 19:33:35 +0000580#endif
581#ifdef reg_EDX
bellard3fb2ded2003-06-24 13:22:59 +0000582 env->regs[R_EDX] = EDX;
bellardfc9f7152005-04-26 19:33:35 +0000583#endif
584#ifdef reg_ESI
bellard3fb2ded2003-06-24 13:22:59 +0000585 env->regs[R_ESI] = ESI;
bellardfc9f7152005-04-26 19:33:35 +0000586#endif
587#ifdef reg_EDI
bellard3fb2ded2003-06-24 13:22:59 +0000588 env->regs[R_EDI] = EDI;
bellardfc9f7152005-04-26 19:33:35 +0000589#endif
590#ifdef reg_EBP
bellard3fb2ded2003-06-24 13:22:59 +0000591 env->regs[R_EBP] = EBP;
bellardfc9f7152005-04-26 19:33:35 +0000592#endif
593#ifdef reg_ESP
bellard3fb2ded2003-06-24 13:22:59 +0000594 env->regs[R_ESP] = ESP;
bellardfc9f7152005-04-26 19:33:35 +0000595#endif
bellard3fb2ded2003-06-24 13:22:59 +0000596 env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
bellard7fe48482004-10-09 18:08:01 +0000597 cpu_dump_state(env, logfile, fprintf, X86_DUMP_CCOP);
bellard3fb2ded2003-06-24 13:22:59 +0000598 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
bellarde4533c72003-06-15 19:51:39 +0000599#elif defined(TARGET_ARM)
bellard7fe48482004-10-09 18:08:01 +0000600 cpu_dump_state(env, logfile, fprintf, 0);
bellard93ac68b2003-09-30 20:57:29 +0000601#elif defined(TARGET_SPARC)
bellard34751872005-07-02 14:31:34 +0000602 REGWPTR = env->regbase + (env->cwp * 16);
603 env->regwptr = REGWPTR;
604 cpu_dump_state(env, logfile, fprintf, 0);
bellard67867302003-11-23 17:05:30 +0000605#elif defined(TARGET_PPC)
bellard7fe48482004-10-09 18:08:01 +0000606 cpu_dump_state(env, logfile, fprintf, 0);
bellard6af0bf92005-07-02 14:58:51 +0000607#elif defined(TARGET_MIPS)
608 cpu_dump_state(env, logfile, fprintf, 0);
bellarde4533c72003-06-15 19:51:39 +0000609#else
610#error unsupported target CPU
611#endif
bellard3fb2ded2003-06-24 13:22:59 +0000612 }
bellard7d132992003-03-06 23:23:54 +0000613#endif
bellard8a40a182005-11-20 10:35:40 +0000614 tb = tb_find_fast();
bellard9d27abd2003-05-10 13:13:54 +0000615#ifdef DEBUG_EXEC
bellardc1135f62005-01-30 22:41:54 +0000616 if ((loglevel & CPU_LOG_EXEC)) {
bellardc27004e2005-01-03 23:35:10 +0000617 fprintf(logfile, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
618 (long)tb->tc_ptr, tb->pc,
619 lookup_symbol(tb->pc));
bellard3fb2ded2003-06-24 13:22:59 +0000620 }
bellard9d27abd2003-05-10 13:13:54 +0000621#endif
bellard8c6939c2003-06-09 15:28:00 +0000622#ifdef __sparc__
bellard3fb2ded2003-06-24 13:22:59 +0000623 T0 = tmp_T0;
bellard8c6939c2003-06-09 15:28:00 +0000624#endif
bellard8a40a182005-11-20 10:35:40 +0000625 /* see if we can patch the calling TB. When the TB
626 spans two pages, we cannot safely do a direct
627 jump. */
bellardc27004e2005-01-03 23:35:10 +0000628 {
bellard8a40a182005-11-20 10:35:40 +0000629 if (T0 != 0 &&
630 tb->page_addr[1] == -1
bellardbf3e8bf2004-02-16 21:58:54 +0000631#if defined(TARGET_I386) && defined(USE_CODE_COPY)
632 && (tb->cflags & CF_CODE_COPY) ==
633 (((TranslationBlock *)(T0 & ~3))->cflags & CF_CODE_COPY)
634#endif
635 ) {
bellard3fb2ded2003-06-24 13:22:59 +0000636 spin_lock(&tb_lock);
bellardc27004e2005-01-03 23:35:10 +0000637 tb_add_jump((TranslationBlock *)(long)(T0 & ~3), T0 & 3, tb);
bellard97eb5b12004-02-25 23:19:55 +0000638#if defined(USE_CODE_COPY)
639 /* propagates the FP use info */
640 ((TranslationBlock *)(T0 & ~3))->cflags |=
641 (tb->cflags & CF_FP_USED);
642#endif
bellard3fb2ded2003-06-24 13:22:59 +0000643 spin_unlock(&tb_lock);
644 }
bellardc27004e2005-01-03 23:35:10 +0000645 }
bellard3fb2ded2003-06-24 13:22:59 +0000646 tc_ptr = tb->tc_ptr;
bellard83479e72003-06-25 16:12:37 +0000647 env->current_tb = tb;
bellard3fb2ded2003-06-24 13:22:59 +0000648 /* execute the generated code */
649 gen_func = (void *)tc_ptr;
650#if defined(__sparc__)
651 __asm__ __volatile__("call %0\n\t"
652 "mov %%o7,%%i0"
653 : /* no outputs */
654 : "r" (gen_func)
655 : "i0", "i1", "i2", "i3", "i4", "i5");
656#elif defined(__arm__)
657 asm volatile ("mov pc, %0\n\t"
658 ".global exec_loop\n\t"
659 "exec_loop:\n\t"
660 : /* no outputs */
661 : "r" (gen_func)
662 : "r1", "r2", "r3", "r8", "r9", "r10", "r12", "r14");
bellardbf3e8bf2004-02-16 21:58:54 +0000663#elif defined(TARGET_I386) && defined(USE_CODE_COPY)
664{
665 if (!(tb->cflags & CF_CODE_COPY)) {
bellard97eb5b12004-02-25 23:19:55 +0000666 if ((tb->cflags & CF_FP_USED) && env->native_fp_regs) {
667 save_native_fp_state(env);
668 }
bellardbf3e8bf2004-02-16 21:58:54 +0000669 gen_func();
670 } else {
bellard97eb5b12004-02-25 23:19:55 +0000671 if ((tb->cflags & CF_FP_USED) && !env->native_fp_regs) {
672 restore_native_fp_state(env);
673 }
bellardbf3e8bf2004-02-16 21:58:54 +0000674 /* we work with native eflags */
675 CC_SRC = cc_table[CC_OP].compute_all();
676 CC_OP = CC_OP_EFLAGS;
677 asm(".globl exec_loop\n"
678 "\n"
679 "debug1:\n"
680 " pushl %%ebp\n"
681 " fs movl %10, %9\n"
682 " fs movl %11, %%eax\n"
683 " andl $0x400, %%eax\n"
684 " fs orl %8, %%eax\n"
685 " pushl %%eax\n"
686 " popf\n"
687 " fs movl %%esp, %12\n"
688 " fs movl %0, %%eax\n"
689 " fs movl %1, %%ecx\n"
690 " fs movl %2, %%edx\n"
691 " fs movl %3, %%ebx\n"
692 " fs movl %4, %%esp\n"
693 " fs movl %5, %%ebp\n"
694 " fs movl %6, %%esi\n"
695 " fs movl %7, %%edi\n"
696 " fs jmp *%9\n"
697 "exec_loop:\n"
698 " fs movl %%esp, %4\n"
699 " fs movl %12, %%esp\n"
700 " fs movl %%eax, %0\n"
701 " fs movl %%ecx, %1\n"
702 " fs movl %%edx, %2\n"
703 " fs movl %%ebx, %3\n"
704 " fs movl %%ebp, %5\n"
705 " fs movl %%esi, %6\n"
706 " fs movl %%edi, %7\n"
707 " pushf\n"
708 " popl %%eax\n"
709 " movl %%eax, %%ecx\n"
710 " andl $0x400, %%ecx\n"
711 " shrl $9, %%ecx\n"
712 " andl $0x8d5, %%eax\n"
713 " fs movl %%eax, %8\n"
714 " movl $1, %%eax\n"
715 " subl %%ecx, %%eax\n"
716 " fs movl %%eax, %11\n"
717 " fs movl %9, %%ebx\n" /* get T0 value */
718 " popl %%ebp\n"
719 :
720 : "m" (*(uint8_t *)offsetof(CPUState, regs[0])),
721 "m" (*(uint8_t *)offsetof(CPUState, regs[1])),
722 "m" (*(uint8_t *)offsetof(CPUState, regs[2])),
723 "m" (*(uint8_t *)offsetof(CPUState, regs[3])),
724 "m" (*(uint8_t *)offsetof(CPUState, regs[4])),
725 "m" (*(uint8_t *)offsetof(CPUState, regs[5])),
726 "m" (*(uint8_t *)offsetof(CPUState, regs[6])),
727 "m" (*(uint8_t *)offsetof(CPUState, regs[7])),
728 "m" (*(uint8_t *)offsetof(CPUState, cc_src)),
729 "m" (*(uint8_t *)offsetof(CPUState, tmp0)),
730 "a" (gen_func),
731 "m" (*(uint8_t *)offsetof(CPUState, df)),
732 "m" (*(uint8_t *)offsetof(CPUState, saved_esp))
733 : "%ecx", "%edx"
734 );
735 }
736}
bellardb8076a72005-04-07 22:20:31 +0000737#elif defined(__ia64)
738 struct fptr {
739 void *ip;
740 void *gp;
741 } fp;
742
743 fp.ip = tc_ptr;
744 fp.gp = code_gen_buffer + 2 * (1 << 20);
745 (*(void (*)(void)) &fp)();
bellard3fb2ded2003-06-24 13:22:59 +0000746#else
747 gen_func();
748#endif
bellard83479e72003-06-25 16:12:37 +0000749 env->current_tb = NULL;
bellard4cbf74b2003-08-10 21:48:43 +0000750 /* reset soft MMU for next block (it can currently
751 only be set by a memory fault) */
752#if defined(TARGET_I386) && !defined(CONFIG_SOFTMMU)
bellard3f337312003-08-20 23:02:09 +0000753 if (env->hflags & HF_SOFTMMU_MASK) {
754 env->hflags &= ~HF_SOFTMMU_MASK;
bellard4cbf74b2003-08-10 21:48:43 +0000755 /* do not allow linking to another block */
756 T0 = 0;
757 }
758#endif
bellard3fb2ded2003-06-24 13:22:59 +0000759 }
760 } else {
bellard0d1a29f2004-10-12 22:01:28 +0000761 env_to_regs();
bellard7d132992003-03-06 23:23:54 +0000762 }
bellard3fb2ded2003-06-24 13:22:59 +0000763 } /* for(;;) */
764
bellard7d132992003-03-06 23:23:54 +0000765
bellarde4533c72003-06-15 19:51:39 +0000766#if defined(TARGET_I386)
bellard97eb5b12004-02-25 23:19:55 +0000767#if defined(USE_CODE_COPY)
768 if (env->native_fp_regs) {
769 save_native_fp_state(env);
770 }
771#endif
bellard9de5e442003-03-23 16:49:39 +0000772 /* restore flags in standard format */
bellardfc2b4c42003-03-29 16:52:44 +0000773 env->eflags = env->eflags | cc_table[CC_OP].compute_all() | (DF & DF_MASK);
bellard9de5e442003-03-23 16:49:39 +0000774
bellard7d132992003-03-06 23:23:54 +0000775 /* restore global registers */
bellard04369ff2003-03-20 22:33:23 +0000776#ifdef reg_EAX
777 EAX = saved_EAX;
778#endif
779#ifdef reg_ECX
780 ECX = saved_ECX;
781#endif
782#ifdef reg_EDX
783 EDX = saved_EDX;
784#endif
785#ifdef reg_EBX
786 EBX = saved_EBX;
787#endif
788#ifdef reg_ESP
789 ESP = saved_ESP;
790#endif
791#ifdef reg_EBP
792 EBP = saved_EBP;
793#endif
794#ifdef reg_ESI
795 ESI = saved_ESI;
796#endif
797#ifdef reg_EDI
798 EDI = saved_EDI;
799#endif
bellarde4533c72003-06-15 19:51:39 +0000800#elif defined(TARGET_ARM)
bellardb7bcbe92005-02-22 19:27:29 +0000801 /* XXX: Save/restore host fpu exception state?. */
bellard93ac68b2003-09-30 20:57:29 +0000802#elif defined(TARGET_SPARC)
bellard34751872005-07-02 14:31:34 +0000803#if defined(reg_REGWPTR)
804 REGWPTR = saved_regwptr;
805#endif
bellard67867302003-11-23 17:05:30 +0000806#elif defined(TARGET_PPC)
bellard6af0bf92005-07-02 14:58:51 +0000807#elif defined(TARGET_MIPS)
bellarde4533c72003-06-15 19:51:39 +0000808#else
809#error unsupported target CPU
810#endif
bellard8c6939c2003-06-09 15:28:00 +0000811#ifdef __sparc__
812 asm volatile ("mov %0, %%i7" : : "r" (saved_i7));
813#endif
bellard7d132992003-03-06 23:23:54 +0000814 T0 = saved_T0;
815 T1 = saved_T1;
bellard34751872005-07-02 14:31:34 +0000816#if defined(reg_T2)
bellarde4533c72003-06-15 19:51:39 +0000817 T2 = saved_T2;
bellard34751872005-07-02 14:31:34 +0000818#endif
bellard7d132992003-03-06 23:23:54 +0000819 env = saved_env;
bellard6a00d602005-11-21 23:25:50 +0000820 /* fail safe : never use cpu_single_env outside cpu_exec() */
821 cpu_single_env = NULL;
bellard7d132992003-03-06 23:23:54 +0000822 return ret;
823}
bellard6dbad632003-03-16 18:05:05 +0000824
bellardfbf9eeb2004-04-25 21:21:33 +0000825/* must only be called from the generated code as an exception can be
826 generated */
827void tb_invalidate_page_range(target_ulong start, target_ulong end)
828{
bellarddc5d0b32004-06-22 18:43:30 +0000829 /* XXX: cannot enable it yet because it yields to MMU exception
830 where NIP != read address on PowerPC */
831#if 0
bellardfbf9eeb2004-04-25 21:21:33 +0000832 target_ulong phys_addr;
833 phys_addr = get_phys_addr_code(env, start);
834 tb_invalidate_phys_page_range(phys_addr, phys_addr + end - start, 0);
bellarddc5d0b32004-06-22 18:43:30 +0000835#endif
bellardfbf9eeb2004-04-25 21:21:33 +0000836}
837
bellard1a18c712003-10-30 01:07:51 +0000838#if defined(TARGET_I386) && defined(CONFIG_USER_ONLY)
bellarde4533c72003-06-15 19:51:39 +0000839
bellard6dbad632003-03-16 18:05:05 +0000840void cpu_x86_load_seg(CPUX86State *s, int seg_reg, int selector)
841{
842 CPUX86State *saved_env;
843
844 saved_env = env;
845 env = s;
bellarda412ac52003-07-26 18:01:40 +0000846 if (!(env->cr[0] & CR0_PE_MASK) || (env->eflags & VM_MASK)) {
bellarda513fe12003-05-27 23:29:48 +0000847 selector &= 0xffff;
bellard2e255c62003-08-21 23:25:21 +0000848 cpu_x86_load_seg_cache(env, seg_reg, selector,
bellardc27004e2005-01-03 23:35:10 +0000849 (selector << 4), 0xffff, 0);
bellarda513fe12003-05-27 23:29:48 +0000850 } else {
bellardb453b702004-01-04 15:45:21 +0000851 load_seg(seg_reg, selector);
bellarda513fe12003-05-27 23:29:48 +0000852 }
bellard6dbad632003-03-16 18:05:05 +0000853 env = saved_env;
854}
bellard9de5e442003-03-23 16:49:39 +0000855
bellardd0a1ffc2003-05-29 20:04:28 +0000856void cpu_x86_fsave(CPUX86State *s, uint8_t *ptr, int data32)
857{
858 CPUX86State *saved_env;
859
860 saved_env = env;
861 env = s;
862
bellardc27004e2005-01-03 23:35:10 +0000863 helper_fsave((target_ulong)ptr, data32);
bellardd0a1ffc2003-05-29 20:04:28 +0000864
865 env = saved_env;
866}
867
868void cpu_x86_frstor(CPUX86State *s, uint8_t *ptr, int data32)
869{
870 CPUX86State *saved_env;
871
872 saved_env = env;
873 env = s;
874
bellardc27004e2005-01-03 23:35:10 +0000875 helper_frstor((target_ulong)ptr, data32);
bellardd0a1ffc2003-05-29 20:04:28 +0000876
877 env = saved_env;
878}
879
bellarde4533c72003-06-15 19:51:39 +0000880#endif /* TARGET_I386 */
881
bellard67b915a2004-03-31 23:37:16 +0000882#if !defined(CONFIG_SOFTMMU)
883
bellard3fb2ded2003-06-24 13:22:59 +0000884#if defined(TARGET_I386)
885
bellardb56dad12003-05-08 15:38:04 +0000886/* 'pc' is the host PC at which the exception was raised. 'address' is
bellardfd6ce8f2003-05-14 19:00:11 +0000887 the effective address of the memory exception. 'is_write' is 1 if a
888 write caused the exception and otherwise 0'. 'old_set' is the
889 signal set which should be restored */
bellard2b413142003-05-14 23:01:10 +0000890static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
bellardbf3e8bf2004-02-16 21:58:54 +0000891 int is_write, sigset_t *old_set,
892 void *puc)
bellard9de5e442003-03-23 16:49:39 +0000893{
bellarda513fe12003-05-27 23:29:48 +0000894 TranslationBlock *tb;
895 int ret;
bellard68a79312003-06-30 13:12:32 +0000896
bellard83479e72003-06-25 16:12:37 +0000897 if (cpu_single_env)
898 env = cpu_single_env; /* XXX: find a correct solution for multithread */
bellardfd6ce8f2003-05-14 19:00:11 +0000899#if defined(DEBUG_SIGNAL)
bellardbf3e8bf2004-02-16 21:58:54 +0000900 qemu_printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
901 pc, address, is_write, *(unsigned long *)old_set);
bellard9de5e442003-03-23 16:49:39 +0000902#endif
bellard25eb4482003-05-14 21:50:54 +0000903 /* XXX: locking issue */
bellardfbf9eeb2004-04-25 21:21:33 +0000904 if (is_write && page_unprotect(address, pc, puc)) {
bellardfd6ce8f2003-05-14 19:00:11 +0000905 return 1;
906 }
bellardfbf9eeb2004-04-25 21:21:33 +0000907
bellard3fb2ded2003-06-24 13:22:59 +0000908 /* see if it is an MMU fault */
bellard93a40ea2003-10-27 21:13:06 +0000909 ret = cpu_x86_handle_mmu_fault(env, address, is_write,
910 ((env->hflags & HF_CPL_MASK) == 3), 0);
bellard3fb2ded2003-06-24 13:22:59 +0000911 if (ret < 0)
912 return 0; /* not an MMU fault */
913 if (ret == 0)
914 return 1; /* the MMU fault was handled without causing real CPU fault */
915 /* now we have a real cpu fault */
bellarda513fe12003-05-27 23:29:48 +0000916 tb = tb_find_pc(pc);
917 if (tb) {
bellard9de5e442003-03-23 16:49:39 +0000918 /* the PC is inside the translated code. It means that we have
919 a virtual CPU fault */
bellardbf3e8bf2004-02-16 21:58:54 +0000920 cpu_restore_state(tb, env, pc, puc);
bellard3fb2ded2003-06-24 13:22:59 +0000921 }
bellard4cbf74b2003-08-10 21:48:43 +0000922 if (ret == 1) {
bellard3fb2ded2003-06-24 13:22:59 +0000923#if 0
bellard4cbf74b2003-08-10 21:48:43 +0000924 printf("PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\n",
925 env->eip, env->cr[2], env->error_code);
bellard3fb2ded2003-06-24 13:22:59 +0000926#endif
bellard4cbf74b2003-08-10 21:48:43 +0000927 /* we restore the process signal mask as the sigreturn should
928 do it (XXX: use sigsetjmp) */
929 sigprocmask(SIG_SETMASK, old_set, NULL);
bellard54ca9092005-12-04 18:46:06 +0000930 raise_exception_err(env->exception_index, env->error_code);
bellard4cbf74b2003-08-10 21:48:43 +0000931 } else {
932 /* activate soft MMU for this block */
bellard3f337312003-08-20 23:02:09 +0000933 env->hflags |= HF_SOFTMMU_MASK;
bellardfbf9eeb2004-04-25 21:21:33 +0000934 cpu_resume_from_signal(env, puc);
bellard4cbf74b2003-08-10 21:48:43 +0000935 }
bellard3fb2ded2003-06-24 13:22:59 +0000936 /* never comes here */
937 return 1;
938}
939
bellarde4533c72003-06-15 19:51:39 +0000940#elif defined(TARGET_ARM)
bellard3fb2ded2003-06-24 13:22:59 +0000941static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
bellardbf3e8bf2004-02-16 21:58:54 +0000942 int is_write, sigset_t *old_set,
943 void *puc)
bellard3fb2ded2003-06-24 13:22:59 +0000944{
bellard68016c62005-02-07 23:12:27 +0000945 TranslationBlock *tb;
946 int ret;
947
948 if (cpu_single_env)
949 env = cpu_single_env; /* XXX: find a correct solution for multithread */
950#if defined(DEBUG_SIGNAL)
951 printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
952 pc, address, is_write, *(unsigned long *)old_set);
953#endif
bellard9f0777e2005-02-02 20:42:01 +0000954 /* XXX: locking issue */
955 if (is_write && page_unprotect(address, pc, puc)) {
956 return 1;
957 }
bellard68016c62005-02-07 23:12:27 +0000958 /* see if it is an MMU fault */
959 ret = cpu_arm_handle_mmu_fault(env, address, is_write, 1, 0);
960 if (ret < 0)
961 return 0; /* not an MMU fault */
962 if (ret == 0)
963 return 1; /* the MMU fault was handled without causing real CPU fault */
964 /* now we have a real cpu fault */
965 tb = tb_find_pc(pc);
966 if (tb) {
967 /* the PC is inside the translated code. It means that we have
968 a virtual CPU fault */
969 cpu_restore_state(tb, env, pc, puc);
970 }
971 /* we restore the process signal mask as the sigreturn should
972 do it (XXX: use sigsetjmp) */
973 sigprocmask(SIG_SETMASK, old_set, NULL);
974 cpu_loop_exit();
bellard3fb2ded2003-06-24 13:22:59 +0000975}
bellard93ac68b2003-09-30 20:57:29 +0000976#elif defined(TARGET_SPARC)
977static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
bellardbf3e8bf2004-02-16 21:58:54 +0000978 int is_write, sigset_t *old_set,
979 void *puc)
bellard93ac68b2003-09-30 20:57:29 +0000980{
bellard68016c62005-02-07 23:12:27 +0000981 TranslationBlock *tb;
982 int ret;
983
984 if (cpu_single_env)
985 env = cpu_single_env; /* XXX: find a correct solution for multithread */
986#if defined(DEBUG_SIGNAL)
987 printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
988 pc, address, is_write, *(unsigned long *)old_set);
989#endif
bellardb453b702004-01-04 15:45:21 +0000990 /* XXX: locking issue */
bellardfbf9eeb2004-04-25 21:21:33 +0000991 if (is_write && page_unprotect(address, pc, puc)) {
bellardb453b702004-01-04 15:45:21 +0000992 return 1;
993 }
bellard68016c62005-02-07 23:12:27 +0000994 /* see if it is an MMU fault */
995 ret = cpu_sparc_handle_mmu_fault(env, address, is_write, 1, 0);
996 if (ret < 0)
997 return 0; /* not an MMU fault */
998 if (ret == 0)
999 return 1; /* the MMU fault was handled without causing real CPU fault */
1000 /* now we have a real cpu fault */
1001 tb = tb_find_pc(pc);
1002 if (tb) {
1003 /* the PC is inside the translated code. It means that we have
1004 a virtual CPU fault */
1005 cpu_restore_state(tb, env, pc, puc);
1006 }
1007 /* we restore the process signal mask as the sigreturn should
1008 do it (XXX: use sigsetjmp) */
1009 sigprocmask(SIG_SETMASK, old_set, NULL);
1010 cpu_loop_exit();
bellard93ac68b2003-09-30 20:57:29 +00001011}
bellard67867302003-11-23 17:05:30 +00001012#elif defined (TARGET_PPC)
1013static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
bellardbf3e8bf2004-02-16 21:58:54 +00001014 int is_write, sigset_t *old_set,
1015 void *puc)
bellard67867302003-11-23 17:05:30 +00001016{
1017 TranslationBlock *tb;
bellardce097762004-01-04 23:53:18 +00001018 int ret;
bellard67867302003-11-23 17:05:30 +00001019
bellard67867302003-11-23 17:05:30 +00001020 if (cpu_single_env)
1021 env = cpu_single_env; /* XXX: find a correct solution for multithread */
bellard67867302003-11-23 17:05:30 +00001022#if defined(DEBUG_SIGNAL)
1023 printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
1024 pc, address, is_write, *(unsigned long *)old_set);
1025#endif
1026 /* XXX: locking issue */
bellardfbf9eeb2004-04-25 21:21:33 +00001027 if (is_write && page_unprotect(address, pc, puc)) {
bellard67867302003-11-23 17:05:30 +00001028 return 1;
1029 }
1030
bellardce097762004-01-04 23:53:18 +00001031 /* see if it is an MMU fault */
bellard7f957d22004-01-18 23:19:48 +00001032 ret = cpu_ppc_handle_mmu_fault(env, address, is_write, msr_pr, 0);
bellardce097762004-01-04 23:53:18 +00001033 if (ret < 0)
1034 return 0; /* not an MMU fault */
1035 if (ret == 0)
1036 return 1; /* the MMU fault was handled without causing real CPU fault */
1037
bellard67867302003-11-23 17:05:30 +00001038 /* now we have a real cpu fault */
1039 tb = tb_find_pc(pc);
1040 if (tb) {
1041 /* the PC is inside the translated code. It means that we have
1042 a virtual CPU fault */
bellardbf3e8bf2004-02-16 21:58:54 +00001043 cpu_restore_state(tb, env, pc, puc);
bellard67867302003-11-23 17:05:30 +00001044 }
bellardce097762004-01-04 23:53:18 +00001045 if (ret == 1) {
bellard67867302003-11-23 17:05:30 +00001046#if 0
bellardce097762004-01-04 23:53:18 +00001047 printf("PF exception: NIP=0x%08x error=0x%x %p\n",
1048 env->nip, env->error_code, tb);
bellard67867302003-11-23 17:05:30 +00001049#endif
1050 /* we restore the process signal mask as the sigreturn should
1051 do it (XXX: use sigsetjmp) */
bellardbf3e8bf2004-02-16 21:58:54 +00001052 sigprocmask(SIG_SETMASK, old_set, NULL);
bellard9fddaa02004-05-21 12:59:32 +00001053 do_raise_exception_err(env->exception_index, env->error_code);
bellardce097762004-01-04 23:53:18 +00001054 } else {
1055 /* activate soft MMU for this block */
bellardfbf9eeb2004-04-25 21:21:33 +00001056 cpu_resume_from_signal(env, puc);
bellardce097762004-01-04 23:53:18 +00001057 }
bellard67867302003-11-23 17:05:30 +00001058 /* never comes here */
1059 return 1;
1060}
bellard6af0bf92005-07-02 14:58:51 +00001061
1062#elif defined (TARGET_MIPS)
1063static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
1064 int is_write, sigset_t *old_set,
1065 void *puc)
1066{
1067 TranslationBlock *tb;
1068 int ret;
1069
1070 if (cpu_single_env)
1071 env = cpu_single_env; /* XXX: find a correct solution for multithread */
1072#if defined(DEBUG_SIGNAL)
1073 printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
1074 pc, address, is_write, *(unsigned long *)old_set);
1075#endif
1076 /* XXX: locking issue */
1077 if (is_write && page_unprotect(address, pc, puc)) {
1078 return 1;
1079 }
1080
1081 /* see if it is an MMU fault */
bellardcc9442b2005-11-26 18:43:28 +00001082 ret = cpu_mips_handle_mmu_fault(env, address, is_write, 1, 0);
bellard6af0bf92005-07-02 14:58:51 +00001083 if (ret < 0)
1084 return 0; /* not an MMU fault */
1085 if (ret == 0)
1086 return 1; /* the MMU fault was handled without causing real CPU fault */
1087
1088 /* now we have a real cpu fault */
1089 tb = tb_find_pc(pc);
1090 if (tb) {
1091 /* the PC is inside the translated code. It means that we have
1092 a virtual CPU fault */
1093 cpu_restore_state(tb, env, pc, puc);
1094 }
1095 if (ret == 1) {
1096#if 0
1097 printf("PF exception: NIP=0x%08x error=0x%x %p\n",
1098 env->nip, env->error_code, tb);
1099#endif
1100 /* we restore the process signal mask as the sigreturn should
1101 do it (XXX: use sigsetjmp) */
1102 sigprocmask(SIG_SETMASK, old_set, NULL);
1103 do_raise_exception_err(env->exception_index, env->error_code);
1104 } else {
1105 /* activate soft MMU for this block */
1106 cpu_resume_from_signal(env, puc);
1107 }
1108 /* never comes here */
1109 return 1;
1110}
1111
bellarde4533c72003-06-15 19:51:39 +00001112#else
1113#error unsupported target CPU
1114#endif
bellard9de5e442003-03-23 16:49:39 +00001115
bellard2b413142003-05-14 23:01:10 +00001116#if defined(__i386__)
1117
bellardbf3e8bf2004-02-16 21:58:54 +00001118#if defined(USE_CODE_COPY)
1119static void cpu_send_trap(unsigned long pc, int trap,
1120 struct ucontext *uc)
1121{
1122 TranslationBlock *tb;
1123
1124 if (cpu_single_env)
1125 env = cpu_single_env; /* XXX: find a correct solution for multithread */
1126 /* now we have a real cpu fault */
1127 tb = tb_find_pc(pc);
1128 if (tb) {
1129 /* the PC is inside the translated code. It means that we have
1130 a virtual CPU fault */
1131 cpu_restore_state(tb, env, pc, uc);
1132 }
1133 sigprocmask(SIG_SETMASK, &uc->uc_sigmask, NULL);
1134 raise_exception_err(trap, env->error_code);
1135}
1136#endif
1137
bellarde4533c72003-06-15 19:51:39 +00001138int cpu_signal_handler(int host_signum, struct siginfo *info,
1139 void *puc)
bellard9de5e442003-03-23 16:49:39 +00001140{
bellard9de5e442003-03-23 16:49:39 +00001141 struct ucontext *uc = puc;
1142 unsigned long pc;
bellardbf3e8bf2004-02-16 21:58:54 +00001143 int trapno;
bellard97eb5b12004-02-25 23:19:55 +00001144
bellardd691f662003-03-24 21:58:34 +00001145#ifndef REG_EIP
1146/* for glibc 2.1 */
bellardfd6ce8f2003-05-14 19:00:11 +00001147#define REG_EIP EIP
1148#define REG_ERR ERR
1149#define REG_TRAPNO TRAPNO
bellardd691f662003-03-24 21:58:34 +00001150#endif
bellardfc2b4c42003-03-29 16:52:44 +00001151 pc = uc->uc_mcontext.gregs[REG_EIP];
bellardbf3e8bf2004-02-16 21:58:54 +00001152 trapno = uc->uc_mcontext.gregs[REG_TRAPNO];
1153#if defined(TARGET_I386) && defined(USE_CODE_COPY)
1154 if (trapno == 0x00 || trapno == 0x05) {
1155 /* send division by zero or bound exception */
1156 cpu_send_trap(pc, trapno, uc);
1157 return 1;
1158 } else
1159#endif
1160 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1161 trapno == 0xe ?
1162 (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0,
1163 &uc->uc_sigmask, puc);
bellard2b413142003-05-14 23:01:10 +00001164}
1165
bellardbc51c5c2004-03-17 23:46:04 +00001166#elif defined(__x86_64__)
1167
1168int cpu_signal_handler(int host_signum, struct siginfo *info,
1169 void *puc)
1170{
1171 struct ucontext *uc = puc;
1172 unsigned long pc;
1173
1174 pc = uc->uc_mcontext.gregs[REG_RIP];
1175 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1176 uc->uc_mcontext.gregs[REG_TRAPNO] == 0xe ?
1177 (uc->uc_mcontext.gregs[REG_ERR] >> 1) & 1 : 0,
1178 &uc->uc_sigmask, puc);
1179}
1180
bellard83fb7ad2004-07-05 21:25:26 +00001181#elif defined(__powerpc__)
bellard2b413142003-05-14 23:01:10 +00001182
bellard83fb7ad2004-07-05 21:25:26 +00001183/***********************************************************************
1184 * signal context platform-specific definitions
1185 * From Wine
1186 */
1187#ifdef linux
1188/* All Registers access - only for local access */
1189# define REG_sig(reg_name, context) ((context)->uc_mcontext.regs->reg_name)
1190/* Gpr Registers access */
1191# define GPR_sig(reg_num, context) REG_sig(gpr[reg_num], context)
1192# define IAR_sig(context) REG_sig(nip, context) /* Program counter */
1193# define MSR_sig(context) REG_sig(msr, context) /* Machine State Register (Supervisor) */
1194# define CTR_sig(context) REG_sig(ctr, context) /* Count register */
1195# define XER_sig(context) REG_sig(xer, context) /* User's integer exception register */
1196# define LR_sig(context) REG_sig(link, context) /* Link register */
1197# define CR_sig(context) REG_sig(ccr, context) /* Condition register */
1198/* Float Registers access */
1199# define FLOAT_sig(reg_num, context) (((double*)((char*)((context)->uc_mcontext.regs+48*4)))[reg_num])
1200# define FPSCR_sig(context) (*(int*)((char*)((context)->uc_mcontext.regs+(48+32*2)*4)))
1201/* Exception Registers access */
1202# define DAR_sig(context) REG_sig(dar, context)
1203# define DSISR_sig(context) REG_sig(dsisr, context)
1204# define TRAP_sig(context) REG_sig(trap, context)
1205#endif /* linux */
1206
1207#ifdef __APPLE__
1208# include <sys/ucontext.h>
1209typedef struct ucontext SIGCONTEXT;
1210/* All Registers access - only for local access */
1211# define REG_sig(reg_name, context) ((context)->uc_mcontext->ss.reg_name)
1212# define FLOATREG_sig(reg_name, context) ((context)->uc_mcontext->fs.reg_name)
1213# define EXCEPREG_sig(reg_name, context) ((context)->uc_mcontext->es.reg_name)
1214# define VECREG_sig(reg_name, context) ((context)->uc_mcontext->vs.reg_name)
1215/* Gpr Registers access */
1216# define GPR_sig(reg_num, context) REG_sig(r##reg_num, context)
1217# define IAR_sig(context) REG_sig(srr0, context) /* Program counter */
1218# define MSR_sig(context) REG_sig(srr1, context) /* Machine State Register (Supervisor) */
1219# define CTR_sig(context) REG_sig(ctr, context)
1220# define XER_sig(context) REG_sig(xer, context) /* Link register */
1221# define LR_sig(context) REG_sig(lr, context) /* User's integer exception register */
1222# define CR_sig(context) REG_sig(cr, context) /* Condition register */
1223/* Float Registers access */
1224# define FLOAT_sig(reg_num, context) FLOATREG_sig(fpregs[reg_num], context)
1225# define FPSCR_sig(context) ((double)FLOATREG_sig(fpscr, context))
1226/* Exception Registers access */
1227# define DAR_sig(context) EXCEPREG_sig(dar, context) /* Fault registers for coredump */
1228# define DSISR_sig(context) EXCEPREG_sig(dsisr, context)
1229# define TRAP_sig(context) EXCEPREG_sig(exception, context) /* number of powerpc exception taken */
1230#endif /* __APPLE__ */
1231
bellardd1d9f422004-07-14 17:20:55 +00001232int cpu_signal_handler(int host_signum, struct siginfo *info,
bellarde4533c72003-06-15 19:51:39 +00001233 void *puc)
bellard2b413142003-05-14 23:01:10 +00001234{
bellard25eb4482003-05-14 21:50:54 +00001235 struct ucontext *uc = puc;
bellard25eb4482003-05-14 21:50:54 +00001236 unsigned long pc;
bellard25eb4482003-05-14 21:50:54 +00001237 int is_write;
1238
bellard83fb7ad2004-07-05 21:25:26 +00001239 pc = IAR_sig(uc);
bellard25eb4482003-05-14 21:50:54 +00001240 is_write = 0;
1241#if 0
1242 /* ppc 4xx case */
bellard83fb7ad2004-07-05 21:25:26 +00001243 if (DSISR_sig(uc) & 0x00800000)
bellard25eb4482003-05-14 21:50:54 +00001244 is_write = 1;
bellard9de5e442003-03-23 16:49:39 +00001245#else
bellard83fb7ad2004-07-05 21:25:26 +00001246 if (TRAP_sig(uc) != 0x400 && (DSISR_sig(uc) & 0x02000000))
bellard25eb4482003-05-14 21:50:54 +00001247 is_write = 1;
1248#endif
1249 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
bellardbf3e8bf2004-02-16 21:58:54 +00001250 is_write, &uc->uc_sigmask, puc);
bellard9de5e442003-03-23 16:49:39 +00001251}
bellard2b413142003-05-14 23:01:10 +00001252
bellard2f87c602003-06-02 20:38:09 +00001253#elif defined(__alpha__)
1254
bellarde4533c72003-06-15 19:51:39 +00001255int cpu_signal_handler(int host_signum, struct siginfo *info,
bellard2f87c602003-06-02 20:38:09 +00001256 void *puc)
1257{
1258 struct ucontext *uc = puc;
1259 uint32_t *pc = uc->uc_mcontext.sc_pc;
1260 uint32_t insn = *pc;
1261 int is_write = 0;
1262
bellard8c6939c2003-06-09 15:28:00 +00001263 /* XXX: need kernel patch to get write flag faster */
bellard2f87c602003-06-02 20:38:09 +00001264 switch (insn >> 26) {
1265 case 0x0d: // stw
1266 case 0x0e: // stb
1267 case 0x0f: // stq_u
1268 case 0x24: // stf
1269 case 0x25: // stg
1270 case 0x26: // sts
1271 case 0x27: // stt
1272 case 0x2c: // stl
1273 case 0x2d: // stq
1274 case 0x2e: // stl_c
1275 case 0x2f: // stq_c
1276 is_write = 1;
1277 }
1278
1279 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
bellardbf3e8bf2004-02-16 21:58:54 +00001280 is_write, &uc->uc_sigmask, puc);
bellard2f87c602003-06-02 20:38:09 +00001281}
bellard8c6939c2003-06-09 15:28:00 +00001282#elif defined(__sparc__)
1283
bellarde4533c72003-06-15 19:51:39 +00001284int cpu_signal_handler(int host_signum, struct siginfo *info,
1285 void *puc)
bellard8c6939c2003-06-09 15:28:00 +00001286{
1287 uint32_t *regs = (uint32_t *)(info + 1);
1288 void *sigmask = (regs + 20);
1289 unsigned long pc;
1290 int is_write;
1291 uint32_t insn;
1292
1293 /* XXX: is there a standard glibc define ? */
1294 pc = regs[1];
1295 /* XXX: need kernel patch to get write flag faster */
1296 is_write = 0;
1297 insn = *(uint32_t *)pc;
1298 if ((insn >> 30) == 3) {
1299 switch((insn >> 19) & 0x3f) {
1300 case 0x05: // stb
1301 case 0x06: // sth
1302 case 0x04: // st
1303 case 0x07: // std
1304 case 0x24: // stf
1305 case 0x27: // stdf
1306 case 0x25: // stfsr
1307 is_write = 1;
1308 break;
1309 }
1310 }
1311 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
bellardbf3e8bf2004-02-16 21:58:54 +00001312 is_write, sigmask, NULL);
bellard8c6939c2003-06-09 15:28:00 +00001313}
1314
1315#elif defined(__arm__)
1316
bellarde4533c72003-06-15 19:51:39 +00001317int cpu_signal_handler(int host_signum, struct siginfo *info,
1318 void *puc)
bellard8c6939c2003-06-09 15:28:00 +00001319{
1320 struct ucontext *uc = puc;
1321 unsigned long pc;
1322 int is_write;
1323
1324 pc = uc->uc_mcontext.gregs[R15];
1325 /* XXX: compute is_write */
1326 is_write = 0;
1327 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1328 is_write,
1329 &uc->uc_sigmask);
1330}
1331
bellard38e584a2003-08-10 22:14:22 +00001332#elif defined(__mc68000)
1333
1334int cpu_signal_handler(int host_signum, struct siginfo *info,
1335 void *puc)
1336{
1337 struct ucontext *uc = puc;
1338 unsigned long pc;
1339 int is_write;
1340
1341 pc = uc->uc_mcontext.gregs[16];
1342 /* XXX: compute is_write */
1343 is_write = 0;
1344 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1345 is_write,
bellardbf3e8bf2004-02-16 21:58:54 +00001346 &uc->uc_sigmask, puc);
bellard38e584a2003-08-10 22:14:22 +00001347}
1348
bellardb8076a72005-04-07 22:20:31 +00001349#elif defined(__ia64)
1350
1351#ifndef __ISR_VALID
1352 /* This ought to be in <bits/siginfo.h>... */
1353# define __ISR_VALID 1
1354# define si_flags _sifields._sigfault._si_pad0
1355#endif
1356
1357int cpu_signal_handler(int host_signum, struct siginfo *info, void *puc)
1358{
1359 struct ucontext *uc = puc;
1360 unsigned long ip;
1361 int is_write = 0;
1362
1363 ip = uc->uc_mcontext.sc_ip;
1364 switch (host_signum) {
1365 case SIGILL:
1366 case SIGFPE:
1367 case SIGSEGV:
1368 case SIGBUS:
1369 case SIGTRAP:
1370 if (info->si_code && (info->si_flags & __ISR_VALID))
1371 /* ISR.W (write-access) is bit 33: */
1372 is_write = (info->si_isr >> 33) & 1;
1373 break;
1374
1375 default:
1376 break;
1377 }
1378 return handle_cpu_signal(ip, (unsigned long)info->si_addr,
1379 is_write,
1380 &uc->uc_sigmask, puc);
1381}
1382
bellard90cb9492005-07-24 15:11:38 +00001383#elif defined(__s390__)
1384
1385int cpu_signal_handler(int host_signum, struct siginfo *info,
1386 void *puc)
1387{
1388 struct ucontext *uc = puc;
1389 unsigned long pc;
1390 int is_write;
1391
1392 pc = uc->uc_mcontext.psw.addr;
1393 /* XXX: compute is_write */
1394 is_write = 0;
1395 return handle_cpu_signal(pc, (unsigned long)info->si_addr,
1396 is_write,
1397 &uc->uc_sigmask, puc);
1398}
1399
bellard2b413142003-05-14 23:01:10 +00001400#else
1401
bellard3fb2ded2003-06-24 13:22:59 +00001402#error host CPU specific signal handler needed
bellard2b413142003-05-14 23:01:10 +00001403
1404#endif
bellard67b915a2004-03-31 23:37:16 +00001405
1406#endif /* !defined(CONFIG_SOFTMMU) */