VirtualBox

Changeset 8564

Show
Ignore:
Timestamp:
05/05/08 13:50:50 (8 months ago)
Author:
vboxsync
Message:

NoDmik? -> NOT_DMIK.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/include/VBox/cdefs.h

    r8155 r8564  
    13841384 
    13851385/** @def NoDmik(expr) 
    1386  * Turns the given expression into NOOP when DEBUG_dmik is defined. Evaluates  
    1387  * the expression normally otherwise.  
     1386 * Turns the given expression into NOOP when DEBUG_dmik is defined. Evaluates 
     1387 * the expression normally otherwise. 
    13881388 * @param expr  Expression to guard. 
    1389  * @todo r=bird: please rename to NO_DMIK or NOT_DMIK. 
    13901389 */ 
    13911390#if defined(DEBUG_dmik) 
    1392 # define NoDmik(expr) do { } while (0) 
    1393 #else 
    1394 # define NoDmik(expr) expr 
    1395 #endif 
    1396  
    1397  
    1398 #endif 
    1399  
     1391# define NOT_DMIK(expr)    do { } while (0) 
     1392#else 
     1393# define NOT_DMIK(expr)    expr 
     1394#endif 
     1395 
     1396 
     1397#endif 
     1398 
  • trunk/src/VBox/VMM/CFGM.cpp

    r8155 r8564  
    143143    } 
    144144    else 
    145         NoDmik(AssertMsgFailed(("Constructor failed with rc=%Vrc pfnCFGMConstructor=%p\n", rc, pfnCFGMConstructor))); 
     145        NOT_DMIK(AssertMsgFailed(("Constructor failed with rc=%Vrc pfnCFGMConstructor=%p\n", rc, pfnCFGMConstructor))); 
    146146 
    147147    return rc; 
  • trunk/src/VBox/VMM/PDMDevice.cpp

    r8155 r8564  
    942942        if (VBOX_FAILURE(rc)) 
    943943        { 
    944             NoDmik(AssertMsgFailed(("Failed to construct '%s'/%d! %Vra\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc))); 
     944            NOT_DMIK(AssertMsgFailed(("Failed to construct '%s'/%d! %Vra\n", pDevIns->pDevReg->szDeviceName, pDevIns->iInstance, rc))); 
    945945            /* because we're damn lazy right now, we'll say that the destructor will be called even if the constructor fails. */ 
    946946            return rc; 
  • trunk/src/VBox/VMM/VM.cpp

    r8155 r8564  
    241241                default: 
    242242                    pszError = N_("Unknown error creating VM"); 
    243                     NoDmik(AssertMsgFailed(("Add error message for rc=%d (%Vrc)\n", rc, rc))); 
     243                    NOT_DMIK(AssertMsgFailed(("Add error message for rc=%d (%Vrc)\n", rc, rc))); 
    244244                    break; 
    245245            } 
  • trunk/src/recompiler/target-i386/helper.c

    r8450 r8564  
    11/* 
    22 *  i386 helpers 
    3  *  
     3 * 
    44 *  Copyright (c) 2003 Fabrice Bellard 
    55 * 
     
    7171/* modulo 17 table */ 
    7272const uint8_t rclw_table[32] = { 
    73     0, 1, 2, 3, 4, 5, 6, 7,  
     73    0, 1, 2, 3, 4, 5, 6, 7, 
    7474    8, 9,10,11,12,13,14,15, 
    7575   16, 0, 1, 2, 3, 4, 5, 6, 
     
    7979/* modulo 9 table */ 
    8080const uint8_t rclb_table[32] = { 
    81     0, 1, 2, 3, 4, 5, 6, 7,  
     81    0, 1, 2, 3, 4, 5, 6, 7, 
    8282    8, 0, 1, 2, 3, 4, 5, 6, 
    83     7, 8, 0, 1, 2, 3, 4, 5,  
     83    7, 8, 0, 1, 2, 3, 4, 5, 
    8484    6, 7, 8, 0, 1, 2, 3, 4, 
    8585}; 
     
    9595    3.32192809488736234781L,  /*l2t*/ 
    9696}; 
    97      
     97 
    9898/* thread support */ 
    9999 
     
    138138    return 0; 
    139139} 
    140                                       
     140 
    141141static inline unsigned int get_seg_limit(uint32_t e1, uint32_t e2) 
    142142{ 
     
    164164{ 
    165165    selector &= 0xffff; 
    166     cpu_x86_load_seg_cache(env, seg, selector,  
     166    cpu_x86_load_seg_cache(env, seg, selector, 
    167167                           (selector << 4), 0xffff, 0); 
    168168} 
    169169 
    170 static inline void get_ss_esp_from_tss(uint32_t *ss_ptr,  
     170static inline void get_ss_esp_from_tss(uint32_t *ss_ptr, 
    171171                                       uint32_t *esp_ptr, int dpl) 
    172172{ 
    173173    int type, index, shift; 
    174      
     174 
    175175#if 0 
    176176    { 
     
    243243        if (!(e2 & DESC_P_MASK)) 
    244244            raise_exception_err(EXCP0B_NOSEG, selector & 0xfffc); 
    245         cpu_x86_load_seg_cache(env, seg_reg, selector,  
     245        cpu_x86_load_seg_cache(env, seg_reg, selector, 
    246246                       get_seg_base(e1, e2), 
    247247                       get_seg_limit(e1, e2), 
    248248                       e2); 
    249249    } else { 
    250         if (seg_reg == R_SS || seg_reg == R_CS)  
     250        if (seg_reg == R_SS || seg_reg == R_CS) 
    251251            raise_exception_err(EXCP0A_TSS, selector & 0xfffc); 
    252252    } 
     
    258258 
    259259/* XXX: restore CPU state in registers (PowerPC case) */ 
    260 static void switch_tss(int tss_selector,  
     260static void switch_tss(int tss_selector, 
    261261                       uint32_t e1, uint32_t e2, int source, 
    262262                       uint32_t next_eip) 
     
    306306    tss_limit = get_seg_limit(e1, e2); 
    307307    tss_base = get_seg_base(e1, e2); 
    308     if ((tss_selector & 4) != 0 ||  
     308    if ((tss_selector & 4) != 0 || 
    309309        tss_limit < tss_limit_max) 
    310310        raise_exception_err(EXCP0A_TSS, tss_selector & 0xfffc); 
     
    341341        new_trap = 0; 
    342342    } 
    343      
     343 
    344344    /* NOTE: we must avoid memory exceptions during the task switch, 
    345345       so we make dummy accesses before */ 
     
    351351    stb_kernel(env->tr.base, v1); 
    352352    stb_kernel(env->tr.base + old_tss_limit_max, v2); 
    353      
     353 
    354354    /* clear busy bit (it is restartable) */ 
    355355    if (source == SWITCH_TSS_JMP || source == SWITCH_TSS_IRET) { 
     
    364364    if (source == SWITCH_TSS_IRET) 
    365365        old_eflags &= ~NT_MASK; 
    366      
     366 
    367367    /* save the current state in the old TSS */ 
    368368    if (type & 8) { 
     
    399399            stw_kernel(env->tr.base + (0x22 + i * 4), env->segs[i].selector); 
    400400    } 
    401      
     401 
    402402    /* now if an exception occurs, it will occurs in the next task 
    403403       context */ 
     
    426426    env->tr.limit = tss_limit; 
    427427    env->tr.flags = e2 & ~DESC_TSS_BUSY_MASK; 
    428      
     428 
    429429    if ((type & 8) && (env->cr[0] & CR0_PG_MASK)) { 
    430430        cpu_x86_update_cr3(env, new_cr3); 
    431431    } 
    432      
     432 
    433433    /* load all registers without an exception, then reload them with 
    434434       possible exception */ 
    435435    env->eip = new_eip; 
    436     eflags_mask = TF_MASK | AC_MASK | ID_MASK |  
     436    eflags_mask = TF_MASK | AC_MASK | ID_MASK | 
    437437        IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK; 
    438438    if (!(type & 8)) 
     
    449449    EDI = new_regs[7]; 
    450450    if (new_eflags & VM_MASK) { 
    451         for(i = 0; i < 6; i++)  
     451        for(i = 0; i < 6; i++) 
    452452            load_seg_vm(i, new_segs[i]); 
    453453        /* in vm86, CPL is always 3 */ 
     
    460460            cpu_x86_load_seg_cache(env, i, new_segs[i], 0, 0, 0); 
    461461    } 
    462      
     462 
    463463    env->ldt.selector = new_ldt & ~4; 
    464464    env->ldt.base = 0; 
     
    484484        load_seg_cache_raw_dt(&env->ldt, e1, e2); 
    485485    } 
    486      
     486 
    487487    /* load the segments */ 
    488488    if (!(new_eflags & VM_MASK)) { 
     
    494494        tss_load_seg(R_GS, new_segs[R_GS]); 
    495495    } 
    496      
     496 
    497497    /* check that EIP is in the CS segment limits */ 
    498498    if (new_eip > env->segs[R_CS].limit) { 
     
    506506{ 
    507507    int io_offset, val, mask; 
    508      
     508 
    509509    /* TSS must be a valid 32 bit one */ 
    510510    if (!(env->tr.flags & DESC_P_MASK) || 
     
    792792        } 
    793793    } 
    794      
     794 
    795795    if (new_stack) { 
    796796        if (env->eflags & VM_MASK) { 
     
    801801        } 
    802802        ss = (ss & ~3) | dpl; 
    803         cpu_x86_load_seg_cache(env, R_SS, ss,  
     803        cpu_x86_load_seg_cache(env, R_SS, ss, 
    804804                               ssp, get_seg_limit(ss_e1, ss_e2), ss_e2); 
    805805    } 
     
    807807 
    808808    selector = (selector & ~3) | dpl; 
    809     cpu_x86_load_seg_cache(env, R_CS, selector,  
     809    cpu_x86_load_seg_cache(env, R_CS, selector, 
    810810                   get_seg_base(e1, e2), 
    811811                   get_seg_limit(e1, e2), 
     
    828828    int io_offset, intredir_offset; 
    829829    unsigned char val, mask; 
    830      
     830 
    831831    /* TSS must be a valid 32 bit one */ 
    832832    if (!(env->tr.flags & DESC_P_MASK) || 
     
    837837    /* the virtual interrupt redirection bitmap is located below the io bitmap */ 
    838838    intredir_offset = io_offset - 0x20; 
    839      
     839 
    840840    intredir_offset += (intno >> 3); 
    841841    if ((intredir_offset) > env->tr.limit) 
     
    900900    PUSHW(ssp, esp, 0xffff, old_cs); 
    901901    PUSHW(ssp, esp, 0xffff, next_eip); 
    902      
     902 
    903903    /* update processor state */ 
    904904    ESP = (ESP & ~0xffff) | (esp & 0xffff); 
     
    932932{ 
    933933    int index; 
    934      
     934 
    935935#if 0 
    936     printf("TR: base=" TARGET_FMT_lx " limit=%x\n",  
     936    printf("TR: base=" TARGET_FMT_lx " limit=%x\n", 
    937937           env->tr.base, env->tr.limit); 
    938938#endif 
     
    10521052        PUSHQ(esp, error_code); 
    10531053    } 
    1054      
     1054 
    10551055    if (new_stack) { 
    10561056        ss = 0 | dpl; 
     
    10601060 
    10611061    selector = (selector & ~3) | dpl; 
    1062     cpu_x86_load_seg_cache(env, R_CS, selector,  
     1062    cpu_x86_load_seg_cache(env, R_CS, selector, 
    10631063                   get_seg_base(e1, e2), 
    10641064                   get_seg_limit(e1, e2), 
     
    10891089        ECX = env->eip + next_eip_addend; 
    10901090        env->regs[11] = compute_eflags(); 
    1091          
     1091 
    10921092        code64 = env->hflags & HF_CS64_MASK; 
    10931093 
    10941094        cpu_x86_set_cpl(env, 0); 
    1095         cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc,  
    1096                            0, 0xffffffff,  
     1095        cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 
     1096                           0, 0xffffffff, 
    10971097                               DESC_G_MASK | DESC_P_MASK | 
    10981098                               DESC_S_MASK | 
    10991099                               DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK | DESC_L_MASK); 
    1100         cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc,  
     1100        cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc, 
    11011101                               0, 0xffffffff, 
    11021102                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
     
    11081108        else 
    11091109            env->eip = env->cstar; 
    1110     } else  
     1110    } else 
    11111111#endif 
    11121112    { 
    11131113        ECX = (uint32_t)(env->eip + next_eip_addend); 
    1114          
     1114 
    11151115        cpu_x86_set_cpl(env, 0); 
    1116         cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc,  
    1117                            0, 0xffffffff,  
     1116        cpu_x86_load_seg_cache(env, R_CS, selector & 0xfffc, 
     1117                           0, 0xffffffff, 
    11181118                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
    11191119                               DESC_S_MASK | 
    11201120                               DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK); 
    1121         cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc,  
     1121        cpu_x86_load_seg_cache(env, R_SS, (selector + 8) & 0xfffc, 
    11221122                               0, 0xffffffff, 
    11231123                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
     
    11441144    if (env->hflags & HF_LMA_MASK) { 
    11451145        if (dflag == 2) { 
    1146             cpu_x86_load_seg_cache(env, R_CS, (selector + 16) | 3,  
    1147                                    0, 0xffffffff,  
     1146            cpu_x86_load_seg_cache(env, R_CS, (selector + 16) | 3, 
     1147                                   0, 0xffffffff, 
    11481148                                   DESC_G_MASK | DESC_P_MASK | 
    11491149                                   DESC_S_MASK | (3 << DESC_DPL_SHIFT) | 
    1150                                    DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK |  
     1150                                   DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK | 
    11511151                                   DESC_L_MASK); 
    11521152            env->eip = ECX; 
    11531153        } else { 
    1154             cpu_x86_load_seg_cache(env, R_CS, selector | 3,  
    1155                                    0, 0xffffffff,  
     1154            cpu_x86_load_seg_cache(env, R_CS, selector | 3, 
     1155                                   0, 0xffffffff, 
    11561156                                   DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
    11571157                                   DESC_S_MASK | (3 << DESC_DPL_SHIFT) | 
     
    11591159            env->eip = (uint32_t)ECX; 
    11601160        } 
    1161         cpu_x86_load_seg_cache(env, R_SS, selector + 8,  
     1161        cpu_x86_load_seg_cache(env, R_SS, selector + 8, 
    11621162                               0, 0xffffffff, 
    11631163                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
    11641164                               DESC_S_MASK | (3 << DESC_DPL_SHIFT) | 
    11651165                               DESC_W_MASK | DESC_A_MASK); 
    1166         load_eflags((uint32_t)(env->regs[11]), TF_MASK | AC_MASK | ID_MASK |  
     1166        load_eflags((uint32_t)(env->regs[11]), TF_MASK | AC_MASK | ID_MASK | 
    11671167                    IF_MASK | IOPL_MASK | VM_MASK | RF_MASK | NT_MASK); 
    11681168        cpu_x86_set_cpl(env, 3); 
    1169     } else  
     1169    } else 
    11701170#endif 
    11711171    { 
    1172         cpu_x86_load_seg_cache(env, R_CS, selector | 3,  
    1173                                0, 0xffffffff,  
     1172        cpu_x86_load_seg_cache(env, R_CS, selector | 3, 
     1173                               0, 0xffffffff, 
    11741174                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
    11751175                               DESC_S_MASK | (3 << DESC_DPL_SHIFT) | 
    11761176                               DESC_CS_MASK | DESC_R_MASK | DESC_A_MASK); 
    11771177        env->eip = (uint32_t)ECX; 
    1178         cpu_x86_load_seg_cache(env, R_SS, selector + 8,  
     1178        cpu_x86_load_seg_cache(env, R_SS, selector + 8, 
    11791179                               0, 0xffffffff, 
    11801180                               DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
     
    11961196#ifdef VBOX 
    11971197/** 
    1198  * Checks and processes external VMM events.  
     1198 * Checks and processes external VMM events. 
    11991199 * Called by op_check_external_event() when any of the flags is set and can be serviced. 
    12001200 */ 
     
    12651265    PUSHW(ssp, esp, 0xffff, old_cs); 
    12661266    PUSHW(ssp, esp, 0xffff, old_eip); 
    1267      
     1267 
    12681268    /* update processor state */ 
    12691269    ESP = (ESP & ~0xffff) | (esp & 0xffff); 
     
    12751275 
    12761276/* fake user mode interrupt */ 
    1277 void do_interrupt_user(int intno, int is_int, int error_code,  
     1277void do_interrupt_user(int intno, int is_int, int error_code, 
    12781278                       target_ulong next_eip) 
    12791279{ 
     
    12861286    ptr = dt->base + (intno * 8); 
    12871287    e2 = ldl_kernel(ptr + 4); 
    1288      
     1288 
    12891289    dpl = (e2 >> DESC_DPL_SHIFT) & 3; 
    12901290    cpl = env->hflags & HF_CPL_MASK; 
     
    13031303 * Begin execution of an interruption. is_int is TRUE if coming from 
    13041304 * the int instruction. next_eip is the EIP value AFTER the interrupt 
    1305  * instruction. It is only relevant if is_int is TRUE.   
     1305 * instruction. It is only relevant if is_int is TRUE. 
    13061306 */ 
    1307 void do_interrupt(int intno, int is_int, int error_code,  
     1307void do_interrupt(int intno, int is_int, int error_code, 
    13081308                  target_ulong next_eip, int is_hw) 
    13091309{ 
     
    13481348#ifdef VBOX 
    13491349            /* int xx *, v86 code and VME enabled? */ 
    1350             if (    (env->eflags & VM_MASK)  
     1350            if (    (env->eflags & VM_MASK) 
    13511351                &&  (env->cr[4] & CR4_VME_MASK) 
    13521352                &&  is_int 
     
    13681368 * is_int is TRUE if coming from the int instruction. next_eip is the 
    13691369 * EIP value AFTER the interrupt instruction. It is only relevant if 
    1370  * is_int is TRUE.   
     1370 * is_int is TRUE. 
    13711371 */ 
    1372 void raise_interrupt(int intno, int is_int, int error_code,  
     1372void raise_interrupt(int intno, int is_int, int error_code, 
    13731373                     int next_eip_addend) 
    13741374{ 
    13751375#if defined(VBOX) && defined(DEBUG) 
    1376     NoDmik(Log2(("raise_interrupt: %x %x %x %08x\n", intno, is_int, error_code, env->eip + next_eip_addend))); 
     1376    NOT_DMIK(Log2(("raise_interrupt: %x %x %x %08x\n", intno, is_int, error_code, env->eip + next_eip_addend))); 
    13771377#endif 
    13781378    env->exception_index = intno; 
     
    14071407/* SMM support */ 
    14081408 
    1409 #if defined(CONFIG_USER_ONLY)  
     1409#if defined(CONFIG_USER_ONLY) 
    14101410 
    14111411void do_smm_enter(void) 
     
    14271427void do_smm_enter(void) 
    14281428{ 
    1429 #ifdef VBOX  
     1429#ifdef VBOX 
    14301430    cpu_abort(env, "do_ssm_enter"); 
    14311431#else /* !VBOX */ 
     
    14431443 
    14441444    sm_state = env->smbase + 0x8000; 
    1445      
     1445 
    14461446#ifdef TARGET_X86_64 
    14471447    for(i = 0; i < 6; i++) { 
     
    14611461    stl_phys(sm_state + 0x7e74, env->ldt.limit); 
    14621462    stw_phys(sm_state + 0x7e72, (env->ldt.flags >> 8) & 0xf0ff); 
    1463      
     1463 
    14641464    stq_phys(sm_state + 0x7e88, env->idt.base); 
    14651465    stl_phys(sm_state + 0x7e84, env->idt.limit); 
     
    14691469    stl_phys(sm_state + 0x7e94, env->tr.limit); 
    14701470    stw_phys(sm_state + 0x7e92, (env->tr.flags >> 8) & 0xf0ff); 
    1471      
     1471 
    14721472    stq_phys(sm_state + 0x7ed0, env->efer); 
    14731473 
     
    14801480    stq_phys(sm_state + 0x7fc8, ESI); 
    14811481    stq_phys(sm_state + 0x7fc0, EDI); 
    1482     for(i = 8; i < 16; i++)  
     1482    for(i = 8; i < 16; i++) 
    14831483        stq_phys(sm_state + 0x7ff8 - i * 8, env->regs[i]); 
    14841484    stq_phys(sm_state + 0x7f78, env->eip); 
     
    15081508    stl_phys(sm_state + 0x7fcc, env->dr[6]); 
    15091509    stl_phys(sm_state + 0x7fc8, env->dr[7]); 
    1510      
     1510 
    15111511    stl_phys(sm_state + 0x7fc4, env->tr.selector); 
    15121512    stl_phys(sm_state + 0x7f64, env->tr.base); 
    15131513    stl_phys(sm_state + 0x7f60, env->tr.limit); 
    15141514    stl_phys(sm_state + 0x7f5c, (env->tr.flags >> 8) & 0xf0ff); 
    1515      
     1515 
    15161516    stl_phys(sm_state + 0x7fc0, env->ldt.selector); 
    15171517    stl_phys(sm_state + 0x7f80, env->ldt.base); 
    15181518    stl_phys(sm_state + 0x7f7c, env->ldt.limit); 
    15191519    stl_phys(sm_state + 0x7f78, (env->ldt.flags >> 8) & 0xf0ff); 
    1520      
     1520 
    15211521    stl_phys(sm_state + 0x7f74, env->gdt.base); 
    15221522    stl_phys(sm_state + 0x7f70, env->gdt.limit); 
     
    15561556    cpu_x86_load_seg_cache(env, R_FS, 0, 0, 0xffffffff, 0); 
    15571557    cpu_x86_load_seg_cache(env, R_GS, 0, 0, 0xffffffff, 0); 
    1558      
    1559     cpu_x86_update_cr0(env,  
     1558 
     1559    cpu_x86_update_cr0(env, 
    15601560                       env->cr[0] & ~(CR0_PE_MASK | CR0_EM_MASK | CR0_TS_MASK | CR0_PG_MASK)); 
    15611561    cpu_x86_update_cr4(env, 0); 
     
    15841584    for(i = 0; i < 6; i++) { 
    15851585        offset = 0x7e00 + i * 16; 
    1586         cpu_x86_load_seg_cache(env, i,  
     1586        cpu_x86_load_seg_cache(env, i, 
    15871587                               lduw_phys(sm_state + offset), 
    15881588                               ldq_phys(sm_state + offset + 8), 
     
    15981598    env->ldt.limit = ldl_phys(sm_state + 0x7e74); 
    15991599    env->ldt.flags = (lduw_phys(sm_state + 0x7e72) & 0xf0ff) << 8; 
    1600      
     1600 
    16011601    env->idt.base = ldq_phys(sm_state + 0x7e88); 
    16021602    env->idt.limit = ldl_phys(sm_state + 0x7e84); 
     
    16061606    env->tr.limit = ldl_phys(sm_state + 0x7e94); 
    16071607    env->tr.flags = (lduw_phys(sm_state + 0x7e92) & 0xf0ff) << 8; 
    1608      
     1608 
    16091609    EAX = ldq_phys(sm_state + 0x7ff8); 
    16101610    ECX = ldq_phys(sm_state + 0x7ff0); 
     
    16151615    ESI = ldq_phys(sm_state + 0x7fc8); 
    16161616    EDI = ldq_phys(sm_state + 0x7fc0); 
    1617     for(i = 8; i < 16; i++)  
     1617    for(i = 8; i < 16; i++) 
    16181618        env->regs[i] = ldq_phys(sm_state + 0x7ff8 - i * 8); 
    16191619    env->eip = ldq_phys(sm_state + 0x7f78); 
    1620     load_eflags(ldl_phys(sm_state + 0x7f70),  
     1620    load_eflags(ldl_phys(sm_state + 0x7f70), 
    16211621                ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK)); 
    16221622    env->dr[6] = ldl_phys(sm_state + 0x7f68); 
     
    16341634    cpu_x86_update_cr0(env, ldl_phys(sm_state + 0x7ffc)); 
    16351635    cpu_x86_update_cr3(env, ldl_phys(sm_state + 0x7ff8)); 
    1636     load_eflags(ldl_phys(sm_state + 0x7ff4),  
     1636    load_eflags(ldl_phys(sm_state + 0x7ff4), 
    16371637                ~(CC_O | CC_S | CC_Z | CC_A | CC_P | CC_C | DF_MASK)); 
    16381638    env->eip = ldl_phys(sm_state + 0x7ff0); 
     
    16471647    env->dr[6] = ldl_phys(sm_state + 0x7fcc); 
    16481648    env->dr[7] = ldl_phys(sm_state + 0x7fc8); 
    1649      
     1649 
    16501650    env->tr.selector = ldl_phys(sm_state + 0x7fc4) & 0xffff; 
    16511651    env->tr.base = ldl_phys(sm_state + 0x7f64); 
    16521652    env->tr.limit = ldl_phys(sm_state + 0x7f60); 
    16531653    env->tr.flags = (ldl_phys(sm_state + 0x7f5c) & 0xf0ff) << 8; 
    1654      
     1654 
    16551655    env->ldt.selector = ldl_phys(sm_state + 0x7fc0) & 0xffff; 
    16561656    env->ldt.base = ldl_phys(sm_state + 0x7f80); 
    16571657    env->ldt.limit = ldl_phys(sm_state + 0x7f7c); 
    16581658    env->ldt.flags = (ldl_phys(sm_state + 0x7f78) & 0xf0ff) << 8; 
    1659      
     1659 
    16601660    env->gdt.base = ldl_phys(sm_state + 0x7f74); 
    16611661    env->gdt.limit = ldl_phys(sm_state + 0x7f70); 
     
    16691669        else 
    16701670            offset = 0x7f2c + (i - 3) * 12; 
    1671         cpu_x86_load_seg_cache(env, i,  
     1671        cpu_x86_load_seg_cache(env, i, 
    16721672                               ldl_phys(sm_state + 0x7fa8 + i * 4) & 0xffff, 
    16731673                               ldl_phys(sm_state + offset + 8), 
     
    17161716    unsigned int den, r; 
    17171717    uint64_t num, q; 
    1718      
     1718 
    17191719    num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32); 
    17201720    den = T0; 
     
    17381738    int den, r; 
    17391739    int64_t num, q; 
    1740      
     1740 
    17411741    num = ((uint32_t)EAX) | ((uint64_t)((uint32_t)EDX) << 32); 
    17421742    den = T0; 
     
    17851785    uint32_t index; 
    17861786    index = (uint32_t)EAX; 
    1787      
     1787 
    17881788    /* test if maximum index reached */ 
    17891789    if (index & 0x80000000) { 
    1790         if (index > env->cpuid_xlevel)  
     1790        if (index > env->cpuid_xlevel) 
    17911791            index = env->cpuid_level; 
    17921792    } else { 
    1793         if (index > env->cpuid_level)  
     1793        if (index > env->cpuid_level) 
    17941794            index = env->cpuid_level; 
    17951795    } 
    1796          
     1796 
    17971797    switch(index) { 
    17981798    case 0: 
     
    19401940    target_ulong ptr; 
    19411941#ifdef VBOX 
    1942     Log(("helper_lldt_T0: old ldtr=%RTsel {.base=%VGv, .limit=%VGv} new=%RTsel\n",  
     1942    Log(("helper_lldt_T0: old ldtr=%RTsel {.base=%VGv, .limit=%VGv} new=%RTsel\n", 
    19431943         (RTSEL)env->ldt.selector, (RTGCPTR)env->ldt.base, (RTGCPTR)env->ldt.limit, (RTSEL)(T0 & 0xffff))); 
    1944 #endif  
    1945      
     1944#endif 
     1945 
    19461946    selector = T0 & 0xffff; 
    19471947    if ((selector & 0xfffc) == 0) { 
     
    19581958            entry_limit = 15; 
    19591959        else 
    1960 #endif             
     1960#endif 
    19611961            entry_limit = 7; 
    19621962        if ((index + entry_limit) > dt->limit) 
     
    19831983    env->ldt.selector = selector; 
    19841984#ifdef VBOX 
    1985     Log(("helper_lldt_T0: new ldtr=%RTsel {.base=%VGv, .limit=%VGv}\n",  
     1985    Log(("helper_lldt_T0: new ldtr=%RTsel {.base=%VGv, .limit=%VGv}\n", 
    19861986         (RTSEL)env->ldt.selector, (RTGCPTR)env->ldt.base, (RTGCPTR)env->ldt.limit)); 
    1987 #endif  
     1987#endif 
    19881988} 
    19891989 
     
    19951995    int index, type, entry_limit; 
    19961996    target_ulong ptr; 
    1997      
     1997 
    19981998#ifdef VBOX 
    1999     Log(("helper_ltr_T0: old tr=%RTsel {.base=%VGv, .limit=%VGv, .flags=%RX32} new=%RTsel\n",  
    2000          (RTSEL)env->tr.selector, (RTGCPTR)env->tr.base, (RTGCPTR)env->tr.limit,  
     1999    Log(("helper_ltr_T0: old tr=%RTsel {.base=%VGv, .limit=%VGv, .flags=%RX32} new=%RTsel\n", 
     2000         (RTSEL)env->tr.selector, (RTGCPTR)env->tr.base, (RTGCPTR)env->tr.limit, 
    20012001         env->tr.flags, (RTSEL)(T0 & 0xffff))); 
    2002 #endif  
     2002#endif 
    20032003 
    20042004    selector = T0 & 0xffff; 
     
    20172017            entry_limit = 15; 
    20182018        else 
    2019 #endif             
     2019#endif 
    20202020            entry_limit = 7; 
    20212021        if ((index + entry_limit) > dt->limit) 
     
    20252025        e2 = ldl_kernel(ptr + 4); 
    20262026        type = (e2 >> DESC_TYPE_SHIFT) & 0xf; 
    2027         if ((e2 & DESC_S_MASK) ||  
     2027        if ((e2 & DESC_S_MASK) || 
    20282028            (type != 1 && type != 9)) 
    20292029            raise_exception_err(EXCP0D_GPF, selector & 0xfffc); 
     
    20362036            load_seg_cache_raw_dt(&env->tr, e1, e2); 
    20372037            env->tr.base |= (target_ulong)e3 << 32; 
    2038         } else  
     2038        } else 
    20392039#endif 
    20402040        { 
     
    20462046    env->tr.selector = selector; 
    20472047#ifdef VBOX 
    2048     Log(("helper_ltr_T0: new tr=%RTsel {.base=%VGv, .limit=%VGv, .flags=%RX32} new=%RTsel\n",  
    2049          (RTSEL)env->tr.selector, (RTGCPTR)env->tr.base, (RTGCPTR)env->tr.limit,  
     2048    Log(("helper_ltr_T0: new tr=%RTsel {.base=%VGv, .limit=%VGv, .flags=%RX32} new=%RTsel\n", 
     2049         (RTSEL)env->tr.selector, (RTGCPTR)env->tr.base, (RTGCPTR)env->tr.limit, 
    20502050         env->tr.flags, (RTSEL)(T0 & 0xffff))); 
    2051 #endif  
     2051#endif 
    20522052} 
    20532053 
     
    20662066#ifdef VBOX 
    20672067    /* Trying to load a selector with CPL=1? */ 
    2068     if (cpl == 0 && (selector & 3) == 1 && (env->state & CPU_RAW_RING0))  
     2068    if (cpl == 0 && (selector & 3) == 1 && (env->state & CPU_RAW_RING0)) 
    20692069    { 
    20702070        Log(("RPL 1 -> sel %04X -> %04X\n", selector, selector & 0xfffc)); 
     
    20832083        cpu_x86_load_seg_cache(env, seg_reg, selector, 0, 0, 0); 
    20842084    } else { 
    2085          
     2085 
    20862086        if (selector & 0x4) 
    20872087            dt = &env->ldt; 
     
    20942094        e1 = ldl_kernel(ptr); 
    20952095        e2 = ldl_kernel(ptr + 4); 
    2096          
     2096 
    20972097        if (!(e2 & DESC_S_MASK)) 
    20982098            raise_exception_err(EXCP0D_GPF, selector & 0xfffc); 
     
    21092109            if ((e2 & (DESC_CS_MASK | DESC_R_MASK)) == DESC_CS_MASK) 
    21102110                raise_exception_err(EXCP0D_GPF, selector & 0xfffc); 
    2111              
     2111 
    21122112            if (!(e2 & DESC_CS_MASK) || !(e2 & DESC_C_MASK)) { 
    21132113                /* if not conforming code, test rights */ 
    2114                 if (dpl < cpl || dpl < rpl)  
     2114                if (dpl < cpl || dpl < rpl) 
    21152115                    raise_exception_err(EXCP0D_GPF, selector & 0xfffc); 
    21162116            } 
     
    21302130        } 
    21312131 
    2132         cpu_x86_load_seg_cache(env, seg_reg, selector,  
     2132        cpu_x86_load_seg_cache(env, seg_reg, selector, 
    21332133                       get_seg_base(e1, e2), 
    21342134                       get_seg_limit(e1, e2), 
    21352135                       e2); 
    21362136#if 0 
    2137         fprintf(logfile, "load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n",  
     2137        fprintf(logfile, "load_seg: sel=0x%04x base=0x%08lx limit=0x%08lx flags=%08x\n", 
    21382138                selector, (unsigned long)sc->base, sc->limit, sc->flags); 
    21392139#endif 
     
    21472147    uint32_t e1, e2, cpl, dpl, rpl, limit; 
    21482148    target_ulong new_eip, next_eip; 
    2149      
     2149 
    21502150    new_cs = T0; 
    21512151    new_eip = T1; 
     
    21742174            raise_exception_err(EXCP0B_NOSEG, new_cs & 0xfffc); 
    21752175        limit = get_seg_limit(e1, e2); 
    2176         if (new_eip > limit &&  
     2176        if (new_eip > limit && 
    21772177            !(env->hflags & HF_LMA_MASK) && !(e2 & DESC_L_MASK)) 
    21782178            raise_exception_err(EXCP0D_GPF, new_cs & 0xfffc); 
     
    22102210            dpl = (e2 >> DESC_DPL_SHIFT) & 3; 
    22112211            /* must be code segment */ 
    2212             if (((e2 & (DESC_S_MASK | DESC_CS_MASK)) !=  
     2212            if (((e2 & (DESC_S_MASK | DESC_CS_MASK)) != 
    22132213                 (DESC_S_MASK | DESC_CS_MASK))) 
    22142214                raise_exception_err(EXCP0D_GPF, gate_cs & 0xfffc); 
    2215             if (((e2 & DESC_C_MASK) && (dpl > cpl)) ||  
     2215            if (((e2 & DESC_C_MASK) && (dpl > cpl)) || 
    22162216                (!(e2 & DESC_C_MASK) && (dpl != cpl))) 
    22172217                raise_exception_err(EXCP0D_GPF, gate_cs & 0xfffc); 
     
    23212321            ESP = rsp; 
    23222322            cpu_x86_load_seg_cache(env, R_CS, (new_cs & 0xfffc) | cpl, 
    2323                                    get_seg_base(e1, e2),  
     2323                                   get_seg_base(e1, e2), 
    23242324                                   get_seg_limit(e1, e2), e2); 
    23252325            EIP = new_eip; 
    2326         } else  
     2326        } else 
    23272327#endif 
    23282328        { 
     
    23372337                PUSHW(ssp, sp, sp_mask, next_eip); 
    23382338            } 
    2339              
     2339 
    23402340            limit = get_seg_limit(e1, e2); 
    23412341            if (new_eip > limit) 
     
    23962396#ifdef DEBUG_PCALL 
    23972397            if (loglevel & CPU_LOG_PCALL) 
    2398                 fprintf(logfile, "new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n",  
     2398                fprintf(logfile, "new ss:esp=%04x:%08x param_count=%d ESP=" TARGET_FMT_lx "\n", 
    23992399                        ss, sp, param_count, ESP); 
    24002400#endif 
     
    24182418                raise_exception_err(EXCP0A_TSS, ss & 0xfffc); 
    24192419#endif 
    2420              
     2420 
    24212421            //            push_size = ((param_count * 2) + 8) << shift; 
    24222422 
    24232423            old_sp_mask = get_sp_mask(env->segs[R_SS].flags); 
    24242424            old_ssp = env->segs[R_SS].base; 
    2425              
     2425 
    24262426            sp_mask = get_sp_mask(ss_e2); 
    24272427            ssp = get_seg_base(ss_e1, ss_e2); 
     
    24632463        if (new_stack) { 
    24642464            ss = (ss & ~3) | dpl; 
    2465             cpu_x86_load_seg_cache(env, R_SS, ss,  
     2465            cpu_x86_load_seg_cache(env, R_SS, ss, 
    24662466                                   ssp, 
    24672467                                   get_seg_limit(ss_e1, ss_e2), 
     
    24702470 
    24712471        selector = (selector & ~3) | dpl; 
    2472         cpu_x86_load_seg_cache(env, R_CS, selector,  
     2472        cpu_x86_load_seg_cache(env, R_CS, selector, 
    24732473                       get_seg_base(e1, e2), 
    24742474                       get_seg_limit(e1, e2), 
     
    25212521        /* if virtual interrupt pending and (virtual) interrupts will be enabled -> #GP */ 
    25222522        /* if TF will be set -> #GP */ 
    2523         if (    ((new_eflags & IF_MASK) && (env->eflags & VIP_MASK))  
    2524             ||  (new_eflags & TF_MASK))  
     2523        if (    ((new_eflags & IF_MASK) && (env->eflags & VIP_MASK)) 
     2524            ||  (new_eflags & TF_MASK)) 
    25252525            raise_exception(EXCP0D_GPF); 
    25262526    } 
     
    25622562       they may still contain a valid base. I would be interested to 
    25632563       know how a real x86_64 CPU behaves */ 
    2564     if ((seg_reg == R_FS || seg_reg == R_GS) &&  
     2564    if ((seg_reg == R_FS || seg_reg == R_GS) && 
    25652565        (env->segs[seg_reg].selector & 0xfffc) == 0) 
    25662566        return; 
     
    25842584    int cpl, dpl, rpl, eflags_mask, iopl; 
    25852585    target_ulong ssp, sp, new_eip, new_esp, sp_mask; 
    2586      
     2586 
    25872587#ifdef TARGET_X86_64 
    25882588    if (shift == 2) 
     
    26222622        } 
    26232623#ifdef VBOX 
    2624         if ((new_cs & 0x3) == 1 && (env->state & CPU_RAW_RING0))  
     2624        if ((new_cs & 0x3) == 1 && (env->state & CPU_RAW_RING0)) 
    26252625        { 
    26262626#ifdef DEBUG 
     
    26672667    } 
    26682668    cpl = env->hflags & HF_CPL_MASK; 
    2669     rpl = new_cs & 3;  
     2669    rpl = new_cs & 3; 
    26702670    if (rpl < cpl) 
    26712671    { 
     
    27012701    } 
    27022702    sp += addend; 
    2703     if (rpl == cpl && (!(env->hflags & HF_CS64_MASK) ||  
     2703    if (rpl == cpl && (!(env->hflags & HF_CS64_MASK) || 
    27042704                       ((env->hflags & HF_CS64_MASK) && !is_iret))) { 
    27052705        /* return to same priledge level */ 
    2706         cpu_x86_load_seg_cache(env, R_CS, new_cs,  
     2706        cpu_x86_load_seg_cache(env, R_CS, new_cs, 
    27072707                       get_seg_base(e1, e2), 
    27082708                       get_seg_limit(e1, e2), 
     
    27382738            /* XXX: test CS64 ? */ 
    27392739            if ((env->hflags & HF_LMA_MASK) && rpl != 3) { 
    2740                 cpu_x86_load_seg_cache(env, R_SS, new_ss,  
     2740                cpu_x86_load_seg_cache(env, R_SS, new_ss, 
    27412741                                       0, 0xffffffff, 
    27422742                                       DESC_G_MASK | DESC_B_MASK | DESC_P_MASK | 
     
    27442744                                       DESC_W_MASK | DESC_A_MASK); 
    27452745                ss_e2 = DESC_B_MASK; /* XXX: should not be needed ? */ 
    2746             } else  
     2746            } else 
    27472747#endif 
    27482748            { 
     
    27632763            if (!(ss_e2 & DESC_P_MASK)) 
    27642764                raise_exception_err(EXCP0B_NOSEG, new_ss & 0xfffc); 
    2765             cpu_x86_load_seg_cache(env, R_SS, new_ss,  
     2765            cpu_x86_load_seg_cache(env, R_SS, new_ss, 
    27662766                                   get_seg_base(ss_e1, ss_e2), 
    27672767                                   get_seg_limit(ss_e1, ss_e2), 
     
    27692769        } 
    27702770 
    2771         cpu_x86_load_seg_cache(env, R_CS, new_cs,  
     2771        cpu_x86_load_seg_cache(env, R_CS, new_cs, 
    27722772                       get_seg_base(e1, e2), 
    27732773                       get_seg_limit(e1, e2), 
     
    28252825    POPL(ssp, sp, sp_mask, new_fs); 
    28262826    POPL(ssp, sp, sp_mask, new_gs); 
    2827      
     2827 
    28282828    /* modify processor state */ 
    2829     load_eflags(new_eflags, TF_MASK | AC_MASK | ID_MASK |  
     2829    load_eflags(new_eflags, TF_MASK | AC_MASK | ID_MASK | 
    28302830                IF_MA