VirtualBox

Changeset 37675 in vbox for trunk/src/recompiler/cpu-exec.c


Ignore:
Timestamp:
Jun 29, 2011 7:07:14 AM (13 years ago)
Author:
vboxsync
Message:

rem: Synced with v0.12.5.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/recompiler/cpu-exec.c

    r36768 r37675  
    4949#endif
    5050
    51 #if defined(__sparc__) && !defined(HOST_SOLARIS)
     51#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
    5252// Work around ugly bugs in glibc that mangle global register contents
    5353#undef env
     
    5757int tb_invalidated_flag;
    5858
    59 //#define DEBUG_EXEC
     59//#define CONFIG_DEBUG_EXEC
    6060//#define DEBUG_SIGNAL
    6161
     
    217217
    218218    if (!env->watchpoint_hit)
    219         TAILQ_FOREACH(wp, &env->watchpoints, entry)
     219        QTAILQ_FOREACH(wp, &env->watchpoints, entry)
    220220            wp->flags &= ~BP_WATCHPOINT_HIT;
    221221
     
    425425                RAWEx_ProfileStop(env, STATS_RAW_CHECK);
    426426
     427{
     428    RTGCPTR mypc = env->eip + env->segs[R_CS].base;
     429if (mypc == 0x00fe0d2 || mypc == 0x00f19e9 || mypc == 0x000f0827 || mypc == 0x000fe090) {
     430    RTLogFlags(NULL, "enabled");
     431    loglevel = ~0;
     432    Log(("BANG CRASH!\n"));
     433}
     434}
     435#ifdef CONFIG_DEBUG_EXEC
     436                if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) {
     437                    /* restore flags in standard format */
     438                    regs_to_env();
     439                    env->eflags = env->eflags | helper_cc_compute_all(CC_OP) | (DF & DF_MASK);
     440                    log_cpu_state(env, X86_DUMP_CCOP);
     441                    env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
     442                }
     443#endif
    427444                RAWEx_ProfileStart(env, STATS_TLB_LOOKUP);
    428445                spin_lock(&tb_lock);
     
    437454                    tb_invalidated_flag = 0;
    438455                }
     456#ifdef CONFIG_DEBUG_EXEC
     457                qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08lx [" TARGET_FMT_lx "] %s [sp=%RGv, bp=%RGv\n",
     458                             (long)tb->tc_ptr, tb->pc, lookup_symbol(tb->pc), (RTGCPTR)env->regs[R_ESP], (RTGCPTR)env->regs[R_EBP]);
     459#endif
     460
    439461
    440462                /* see if we can patch the calling TB. When the TB
     
    562584    env_to_regs();
    563585#if defined(TARGET_I386)
    564     /* put eflags in CPU temporary format */
    565     CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
    566     DF = 1 - (2 * ((env->eflags >> 10) & 1));
    567     CC_OP = CC_OP_EFLAGS;
    568     env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
     586    if (!kvm_enabled()) {
     587        /* put eflags in CPU temporary format */
     588        CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
     589        DF = 1 - (2 * ((env->eflags >> 10) & 1));
     590        CC_OP = CC_OP_EFLAGS;
     591        env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
     592    }
    569593#elif defined(TARGET_SPARC)
    570594#elif defined(TARGET_M68K)
     
    579603#elif defined(TARGET_SH4)
    580604#elif defined(TARGET_CRIS)
     605#elif defined(TARGET_S390X)
    581606    /* XXXXX */
    582607#else
     
    588613    for(;;) {
    589614        if (setjmp(env->jmp_env) == 0) {
    590 #if defined(__sparc__) && !defined(HOST_SOLARIS)
     615#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
    591616#undef env
    592617                    env = cpu_single_env;
     
    651676                env->exception_index = -1;
    652677            }
    653 #ifdef CONFIG_KQEMU
    654             if (kqemu_is_ok(env) && env->interrupt_request == 0 && env->exit_request == 0) {
    655                 int ret;
    656                 env->eflags = env->eflags | helper_cc_compute_all(CC_OP) | (DF & DF_MASK);
    657                 ret = kqemu_cpu_exec(env);
    658                 /* put eflags in CPU temporary format */
    659                 CC_SRC = env->eflags & (CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
    660                 DF = 1 - (2 * ((env->eflags >> 10) & 1));
    661                 CC_OP = CC_OP_EFLAGS;
    662                 env->eflags &= ~(DF_MASK | CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C);
    663                 if (ret == 1) {
    664                     /* exception */
    665                     longjmp(env->jmp_env, 1);
    666                 } else if (ret == 2) {
    667                     /* softmmu execution needed */
    668                 } else {
    669                     if (env->interrupt_request != 0 || env->exit_request != 0) {
    670                         /* hardware interrupt will be executed just after */
    671                     } else {
    672                         /* otherwise, we restart */
    673                         longjmp(env->jmp_env, 1);
    674                     }
    675                 }
    676             }
    677 #endif
    678678
    679679            if (kvm_enabled()) {
     
    744744                            intno = cpu_get_pic_interrupt(env);
    745745                            qemu_log_mask(CPU_LOG_TB_IN_ASM, "Servicing hardware INT=0x%02x\n", intno);
    746 #if defined(__sparc__) && !defined(HOST_SOLARIS)
     746#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
    747747#undef env
    748748                    env = cpu_single_env;
     
    771771#if 0
    772772                    if ((interrupt_request & CPU_INTERRUPT_RESET)) {
    773                         cpu_ppc_reset(env);
     773                        cpu_reset(env);
    774774                    }
    775775#endif
     
    815815                            do_interrupt(env);
    816816                            env->interrupt_index = 0;
    817 #if !defined(CONFIG_USER_ONLY)
    818                             cpu_check_irqs(env);
    819 #endif
    820817                        next_tb = 0;
    821818                        }
     
    898895                    cpu_loop_exit();
    899896                }
    900 #ifdef DEBUG_EXEC
     897#ifdef CONFIG_DEBUG_EXEC
    901898                if (qemu_loglevel_mask(CPU_LOG_TB_CPU)) {
    902899                    /* restore flags in standard format */
     
    944941                    tb_invalidated_flag = 0;
    945942                }
    946 #ifdef DEBUG_EXEC
     943#ifdef CONFIG_DEBUG_EXEC
    947944                qemu_log_mask(CPU_LOG_EXEC, "Trace 0x%08lx [" TARGET_FMT_lx "] %s\n",
    948945                             (long)tb->tc_ptr, tb->pc,
     
    953950                   jump. */
    954951                {
    955                     if (next_tb != 0 &&
    956 #ifdef CONFIG_KQEMU
    957                         (env->kqemu_enabled != 2) &&
    958 #endif
    959                         tb->page_addr[1] == -1) {
     952                    if (next_tb != 0 && tb->page_addr[1] == -1) {
    960953                    tb_add_jump((TranslationBlock *)(next_tb & ~3), next_tb & 3, tb);
    961954                }
     
    974967                    tc_ptr = tb->tc_ptr;
    975968                /* execute the generated code */
    976 #if defined(__sparc__) && !defined(HOST_SOLARIS)
     969#if defined(__sparc__) && !defined(CONFIG_SOLARIS)
    977970#undef env
    978971                    env = cpu_single_env;
     
    10111004                /* reset soft MMU for next block (it can currently
    10121005                   only be set by a memory fault) */
    1013 #if defined(CONFIG_KQEMU)
    1014 #define MIN_CYCLE_BEFORE_SWITCH (100 * 1000)
    1015                 if (kqemu_is_ok(env) &&
    1016                     (cpu_get_time_fast() - env->last_io_time) >= MIN_CYCLE_BEFORE_SWITCH) {
    1017                     cpu_loop_exit();
    1018                 }
    1019 #endif
    10201006            } /* for(;;) */
    10211007        } else {
     
    10421028#elif defined(TARGET_ALPHA)
    10431029#elif defined(TARGET_CRIS)
     1030#elif defined(TARGET_S390X)
    10441031    /* XXXXX */
    10451032#else
     
    11171104
    11181105#if defined(TARGET_I386)
     1106#define EXCEPTION_ACTION raise_exception_err(env->exception_index, env->error_code)
     1107#else
     1108#define EXCEPTION_ACTION cpu_loop_exit()
     1109#endif
    11191110
    11201111/* 'pc' is the host PC at which the exception was raised. 'address' is
     
    11411132
    11421133    /* see if it is an MMU fault */
    1143     ret = cpu_x86_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
     1134    ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    11441135    if (ret < 0)
    11451136        return 0; /* not an MMU fault */
     
    11531144        cpu_restore_state(tb, env, pc, puc);
    11541145    }
    1155     if (ret == 1) {
    1156 #if 0
    1157         printf("PF exception: EIP=0x%08x CR2=0x%08x error=0x%x\n",
    1158                env->eip, env->cr[2], env->error_code);
    1159 #endif
    1160         /* we restore the process signal mask as the sigreturn should
    1161            do it (XXX: use sigsetjmp) */
    1162         sigprocmask(SIG_SETMASK, old_set, NULL);
    1163         raise_exception_err(env->exception_index, env->error_code);
    1164     } else {
    1165         /* activate soft MMU for this block */
    1166         env->hflags |= HF_SOFTMMU_MASK;
    1167         cpu_resume_from_signal(env, puc);
    1168     }
    1169     /* never comes here */
    1170     return 1;
    1171 }
    1172 
    1173 #elif defined(TARGET_ARM)
    1174 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1175                                     int is_write, sigset_t *old_set,
    1176                                     void *puc)
    1177 {
    1178     TranslationBlock *tb;
    1179     int ret;
    1180 
    1181     if (cpu_single_env)
    1182         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1183 #if defined(DEBUG_SIGNAL)
    1184     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1185            pc, address, is_write, *(unsigned long *)old_set);
    1186 #endif
    1187     /* XXX: locking issue */
    1188     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1189         return 1;
    1190     }
    1191     /* see if it is an MMU fault */
    1192     ret = cpu_arm_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1193     if (ret < 0)
    1194         return 0; /* not an MMU fault */
    1195     if (ret == 0)
    1196         return 1; /* the MMU fault was handled without causing real CPU fault */
    1197     /* now we have a real cpu fault */
    1198     tb = tb_find_pc(pc);
    1199     if (tb) {
    1200         /* the PC is inside the translated code. It means that we have
    1201            a virtual CPU fault */
    1202         cpu_restore_state(tb, env, pc, puc);
    1203     }
     1146
    12041147    /* we restore the process signal mask as the sigreturn should
    12051148       do it (XXX: use sigsetjmp) */
    12061149    sigprocmask(SIG_SETMASK, old_set, NULL);
    1207     cpu_loop_exit();
     1150    EXCEPTION_ACTION;
     1151
    12081152    /* never comes here */
    12091153    return 1;
    12101154}
    1211 #elif defined(TARGET_SPARC)
    1212 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1213                                     int is_write, sigset_t *old_set,
    1214                                     void *puc)
    1215 {
    1216     TranslationBlock *tb;
    1217     int ret;
    1218 
    1219     if (cpu_single_env)
    1220         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1221 #if defined(DEBUG_SIGNAL)
    1222     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1223            pc, address, is_write, *(unsigned long *)old_set);
    1224 #endif
    1225     /* XXX: locking issue */
    1226     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1227         return 1;
    1228     }
    1229     /* see if it is an MMU fault */
    1230     ret = cpu_sparc_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1231     if (ret < 0)
    1232         return 0; /* not an MMU fault */
    1233     if (ret == 0)
    1234         return 1; /* the MMU fault was handled without causing real CPU fault */
    1235     /* now we have a real cpu fault */
    1236     tb = tb_find_pc(pc);
    1237     if (tb) {
    1238         /* the PC is inside the translated code. It means that we have
    1239            a virtual CPU fault */
    1240         cpu_restore_state(tb, env, pc, puc);
    1241     }
    1242     /* we restore the process signal mask as the sigreturn should
    1243        do it (XXX: use sigsetjmp) */
    1244     sigprocmask(SIG_SETMASK, old_set, NULL);
    1245     cpu_loop_exit();
    1246     /* never comes here */
    1247     return 1;
    1248 }
    1249 #elif defined (TARGET_PPC)
    1250 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1251                                     int is_write, sigset_t *old_set,
    1252                                     void *puc)
    1253 {
    1254     TranslationBlock *tb;
    1255     int ret;
    1256 
    1257     if (cpu_single_env)
    1258         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1259 #if defined(DEBUG_SIGNAL)
    1260     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1261            pc, address, is_write, *(unsigned long *)old_set);
    1262 #endif
    1263     /* XXX: locking issue */
    1264     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1265         return 1;
    1266     }
    1267 
    1268     /* see if it is an MMU fault */
    1269     ret = cpu_ppc_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1270     if (ret < 0)
    1271         return 0; /* not an MMU fault */
    1272     if (ret == 0)
    1273         return 1; /* the MMU fault was handled without causing real CPU fault */
    1274 
    1275     /* now we have a real cpu fault */
    1276     tb = tb_find_pc(pc);
    1277     if (tb) {
    1278         /* the PC is inside the translated code. It means that we have
    1279            a virtual CPU fault */
    1280         cpu_restore_state(tb, env, pc, puc);
    1281     }
    1282     if (ret == 1) {
    1283 #if 0
    1284         printf("PF exception: NIP=0x%08x error=0x%x %p\n",
    1285                env->nip, env->error_code, tb);
    1286 #endif
    1287     /* we restore the process signal mask as the sigreturn should
    1288        do it (XXX: use sigsetjmp) */
    1289         sigprocmask(SIG_SETMASK, old_set, NULL);
    1290         cpu_loop_exit();
    1291     } else {
    1292         /* activate soft MMU for this block */
    1293         cpu_resume_from_signal(env, puc);
    1294     }
    1295     /* never comes here */
    1296     return 1;
    1297 }
    1298 
    1299 #elif defined(TARGET_M68K)
    1300 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1301                                     int is_write, sigset_t *old_set,
    1302                                     void *puc)
    1303 {
    1304     TranslationBlock *tb;
    1305     int ret;
    1306 
    1307     if (cpu_single_env)
    1308         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1309 #if defined(DEBUG_SIGNAL)
    1310     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1311            pc, address, is_write, *(unsigned long *)old_set);
    1312 #endif
    1313     /* XXX: locking issue */
    1314     if (is_write && page_unprotect(address, pc, puc)) {
    1315         return 1;
    1316     }
    1317     /* see if it is an MMU fault */
    1318     ret = cpu_m68k_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1319     if (ret < 0)
    1320         return 0; /* not an MMU fault */
    1321     if (ret == 0)
    1322         return 1; /* the MMU fault was handled without causing real CPU fault */
    1323     /* now we have a real cpu fault */
    1324     tb = tb_find_pc(pc);
    1325     if (tb) {
    1326         /* the PC is inside the translated code. It means that we have
    1327            a virtual CPU fault */
    1328         cpu_restore_state(tb, env, pc, puc);
    1329     }
    1330     /* we restore the process signal mask as the sigreturn should
    1331        do it (XXX: use sigsetjmp) */
    1332     sigprocmask(SIG_SETMASK, old_set, NULL);
    1333     cpu_loop_exit();
    1334     /* never comes here */
    1335     return 1;
    1336 }
    1337 
    1338 #elif defined (TARGET_MIPS)
    1339 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1340                                     int is_write, sigset_t *old_set,
    1341                                     void *puc)
    1342 {
    1343     TranslationBlock *tb;
    1344     int ret;
    1345 
    1346     if (cpu_single_env)
    1347         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1348 #if defined(DEBUG_SIGNAL)
    1349     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1350            pc, address, is_write, *(unsigned long *)old_set);
    1351 #endif
    1352     /* XXX: locking issue */
    1353     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1354         return 1;
    1355     }
    1356 
    1357     /* see if it is an MMU fault */
    1358     ret = cpu_mips_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1359     if (ret < 0)
    1360         return 0; /* not an MMU fault */
    1361     if (ret == 0)
    1362         return 1; /* the MMU fault was handled without causing real CPU fault */
    1363 
    1364     /* now we have a real cpu fault */
    1365     tb = tb_find_pc(pc);
    1366     if (tb) {
    1367         /* the PC is inside the translated code. It means that we have
    1368            a virtual CPU fault */
    1369         cpu_restore_state(tb, env, pc, puc);
    1370     }
    1371     if (ret == 1) {
    1372 #if 0
    1373         printf("PF exception: PC=0x" TARGET_FMT_lx " error=0x%x %p\n",
    1374                env->PC, env->error_code, tb);
    1375 #endif
    1376     /* we restore the process signal mask as the sigreturn should
    1377        do it (XXX: use sigsetjmp) */
    1378         sigprocmask(SIG_SETMASK, old_set, NULL);
    1379         cpu_loop_exit();
    1380     } else {
    1381         /* activate soft MMU for this block */
    1382         cpu_resume_from_signal(env, puc);
    1383     }
    1384     /* never comes here */
    1385     return 1;
    1386 }
    1387 
    1388 #elif defined (TARGET_MICROBLAZE)
    1389 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1390                                     int is_write, sigset_t *old_set,
    1391                                     void *puc)
    1392 {
    1393     TranslationBlock *tb;
    1394     int ret;
    1395 
    1396     if (cpu_single_env)
    1397         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1398 #if defined(DEBUG_SIGNAL)
    1399     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1400            pc, address, is_write, *(unsigned long *)old_set);
    1401 #endif
    1402     /* XXX: locking issue */
    1403     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1404         return 1;
    1405     }
    1406 
    1407     /* see if it is an MMU fault */
    1408     ret = cpu_mb_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1409     if (ret < 0)
    1410         return 0; /* not an MMU fault */
    1411     if (ret == 0)
    1412         return 1; /* the MMU fault was handled without causing real CPU fault */
    1413 
    1414     /* now we have a real cpu fault */
    1415     tb = tb_find_pc(pc);
    1416     if (tb) {
    1417         /* the PC is inside the translated code. It means that we have
    1418            a virtual CPU fault */
    1419         cpu_restore_state(tb, env, pc, puc);
    1420     }
    1421     if (ret == 1) {
    1422 #if 0
    1423         printf("PF exception: PC=0x" TARGET_FMT_lx " error=0x%x %p\n",
    1424                env->PC, env->error_code, tb);
    1425 #endif
    1426     /* we restore the process signal mask as the sigreturn should
    1427        do it (XXX: use sigsetjmp) */
    1428         sigprocmask(SIG_SETMASK, old_set, NULL);
    1429         cpu_loop_exit();
    1430     } else {
    1431         /* activate soft MMU for this block */
    1432         cpu_resume_from_signal(env, puc);
    1433     }
    1434     /* never comes here */
    1435     return 1;
    1436 }
    1437 
    1438 #elif defined (TARGET_SH4)
    1439 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1440                                     int is_write, sigset_t *old_set,
    1441                                     void *puc)
    1442 {
    1443     TranslationBlock *tb;
    1444     int ret;
    1445 
    1446     if (cpu_single_env)
    1447         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1448 #if defined(DEBUG_SIGNAL)
    1449     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1450            pc, address, is_write, *(unsigned long *)old_set);
    1451 #endif
    1452     /* XXX: locking issue */
    1453     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1454         return 1;
    1455     }
    1456 
    1457     /* see if it is an MMU fault */
    1458     ret = cpu_sh4_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1459     if (ret < 0)
    1460         return 0; /* not an MMU fault */
    1461     if (ret == 0)
    1462         return 1; /* the MMU fault was handled without causing real CPU fault */
    1463 
    1464     /* now we have a real cpu fault */
    1465     tb = tb_find_pc(pc);
    1466     if (tb) {
    1467         /* the PC is inside the translated code. It means that we have
    1468            a virtual CPU fault */
    1469         cpu_restore_state(tb, env, pc, puc);
    1470     }
    1471 #if 0
    1472         printf("PF exception: NIP=0x%08x error=0x%x %p\n",
    1473                env->nip, env->error_code, tb);
    1474 #endif
    1475     /* we restore the process signal mask as the sigreturn should
    1476        do it (XXX: use sigsetjmp) */
    1477     sigprocmask(SIG_SETMASK, old_set, NULL);
    1478     cpu_loop_exit();
    1479     /* never comes here */
    1480     return 1;
    1481 }
    1482 
    1483 #elif defined (TARGET_ALPHA)
    1484 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1485                                     int is_write, sigset_t *old_set,
    1486                                     void *puc)
    1487 {
    1488     TranslationBlock *tb;
    1489     int ret;
    1490 
    1491     if (cpu_single_env)
    1492         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1493 #if defined(DEBUG_SIGNAL)
    1494     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1495            pc, address, is_write, *(unsigned long *)old_set);
    1496 #endif
    1497     /* XXX: locking issue */
    1498     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1499         return 1;
    1500     }
    1501 
    1502     /* see if it is an MMU fault */
    1503     ret = cpu_alpha_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1504     if (ret < 0)
    1505         return 0; /* not an MMU fault */
    1506     if (ret == 0)
    1507         return 1; /* the MMU fault was handled without causing real CPU fault */
    1508 
    1509     /* now we have a real cpu fault */
    1510     tb = tb_find_pc(pc);
    1511     if (tb) {
    1512         /* the PC is inside the translated code. It means that we have
    1513            a virtual CPU fault */
    1514         cpu_restore_state(tb, env, pc, puc);
    1515     }
    1516 #if 0
    1517         printf("PF exception: NIP=0x%08x error=0x%x %p\n",
    1518                env->nip, env->error_code, tb);
    1519 #endif
    1520     /* we restore the process signal mask as the sigreturn should
    1521        do it (XXX: use sigsetjmp) */
    1522     sigprocmask(SIG_SETMASK, old_set, NULL);
    1523     cpu_loop_exit();
    1524     /* never comes here */
    1525     return 1;
    1526 }
    1527 #elif defined (TARGET_CRIS)
    1528 static inline int handle_cpu_signal(unsigned long pc, unsigned long address,
    1529                                     int is_write, sigset_t *old_set,
    1530                                     void *puc)
    1531 {
    1532     TranslationBlock *tb;
    1533     int ret;
    1534 
    1535     if (cpu_single_env)
    1536         env = cpu_single_env; /* XXX: find a correct solution for multithread */
    1537 #if defined(DEBUG_SIGNAL)
    1538     printf("qemu: SIGSEGV pc=0x%08lx address=%08lx w=%d oldset=0x%08lx\n",
    1539            pc, address, is_write, *(unsigned long *)old_set);
    1540 #endif
    1541     /* XXX: locking issue */
    1542     if (is_write && page_unprotect(h2g(address), pc, puc)) {
    1543         return 1;
    1544     }
    1545 
    1546     /* see if it is an MMU fault */
    1547     ret = cpu_cris_handle_mmu_fault(env, address, is_write, MMU_USER_IDX, 0);
    1548     if (ret < 0)
    1549         return 0; /* not an MMU fault */
    1550     if (ret == 0)
    1551         return 1; /* the MMU fault was handled without causing real CPU fault */
    1552 
    1553     /* now we have a real cpu fault */
    1554     tb = tb_find_pc(pc);
    1555     if (tb) {
    1556         /* the PC is inside the translated code. It means that we have
    1557            a virtual CPU fault */
    1558         cpu_restore_state(tb, env, pc, puc);
    1559     }
    1560     /* we restore the process signal mask as the sigreturn should
    1561        do it (XXX: use sigsetjmp) */
    1562     sigprocmask(SIG_SETMASK, old_set, NULL);
    1563     cpu_loop_exit();
    1564     /* never comes here */
    1565     return 1;
    1566 }
    1567 
    1568 #else
    1569 #error unsupported target CPU
    1570 #endif
    15711155
    15721156#if defined(__i386__)
     
    15781162# define TRAP_sig(context)    ((context)->uc_mcontext->es.trapno)
    15791163# define ERROR_sig(context)   ((context)->uc_mcontext->es.err)
     1164# define MASK_sig(context)    ((context)->uc_sigmask)
     1165#elif defined (__NetBSD__)
     1166# include <ucontext.h>
     1167
     1168# define EIP_sig(context)     ((context)->uc_mcontext.__gregs[_REG_EIP])
     1169# define TRAP_sig(context)    ((context)->uc_mcontext.__gregs[_REG_TRAPNO])
     1170# define ERROR_sig(context)   ((context)->uc_mcontext.__gregs[_REG_ERR])
     1171# define MASK_sig(context)    ((context)->uc_sigmask)
     1172#elif defined (__FreeBSD__) || defined(__DragonFly__)
     1173# include <ucontext.h>
     1174
     1175# define EIP_sig(context)  (*((unsigned long*)&(context)->uc_mcontext.mc_eip))
     1176# define TRAP_sig(context)    ((context)->uc_mcontext.mc_trapno)
     1177# define ERROR_sig(context)   ((context)->uc_mcontext.mc_err)
    15801178# define MASK_sig(context)    ((context)->uc_sigmask)
    15811179#elif defined(__OpenBSD__)
     
    15951193{
    15961194    siginfo_t *info = pinfo;
    1597 #if defined(__OpenBSD__)
     1195#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__)
     1196    ucontext_t *uc = puc;
     1197#elif defined(__OpenBSD__)
    15981198    struct sigcontext *uc = puc;
    15991199#else
     
    16291229#define ERROR_sig(context)    ((context)->sc_err)
    16301230#define MASK_sig(context)     ((context)->sc_mask)
     1231#elif defined (__FreeBSD__) || defined(__DragonFly__)
     1232#include <ucontext.h>
     1233
     1234#define PC_sig(context)  (*((unsigned long*)&(context)->uc_mcontext.mc_rip))
     1235#define TRAP_sig(context)     ((context)->uc_mcontext.mc_trapno)
     1236#define ERROR_sig(context)    ((context)->uc_mcontext.mc_err)
     1237#define MASK_sig(context)     ((context)->uc_sigmask)
    16311238#else
    16321239#define PC_sig(context)       ((context)->uc_mcontext.gregs[REG_RIP])
     
    16411248    siginfo_t *info = pinfo;
    16421249    unsigned long pc;
    1643 #ifdef __NetBSD__
     1250#if defined(__NetBSD__) || defined (__FreeBSD__) || defined(__DragonFly__)
    16441251    ucontext_t *uc = puc;
    16451252#elif defined(__OpenBSD__)
     
    17671374    int is_write;
    17681375    uint32_t insn;
    1769 #if !defined(__arch64__) || defined(HOST_SOLARIS)
     1376#if !defined(__arch64__) || defined(CONFIG_SOLARIS)
    17701377    uint32_t *regs = (uint32_t *)(info + 1);
    17711378    void *sigmask = (regs + 20);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette