VirtualBox

儲存庫 vbox 的更動 12090


忽略:
時間撮記:
2008-9-4 下午12:51:46 (16 年 以前)
作者:
vboxsync
訊息:

Started with hardware debug register support.
Fixed out of sync tr/ldtr/gdtr/idtr in AMD-V & VT-x.

位置:
trunk/src/VBox/VMM
檔案:
修改 4 筆資料

圖例:

未更動
新增
刪除
  • trunk/src/VBox/VMM/HWACCMInternal.h

    r12061 r12090  
    375375    /** Currenty shadow paging mode. */
    376376    PGMMODE                 enmShadowMode;
     377
     378
     379#ifdef VBOX_SAVE_HOST_DEBUG_REGISTERS
     380    struct
     381    {
     382        /* Saved host debug registers. */
     383        uint64_t                dr0, dr1, dr2, dr3, dr6, dr7;
     384        bool                    fHostDR7Saved;
     385    } savedhoststate;
     386#endif
    377387
    378388    STAMPROFILEADV          StatEntry;
  • trunk/src/VBox/VMM/VMMR0/HWACCMR0.cpp

    r11311 r12090  
    744744    CPUMDeactivateGuestFPUState(pVM);
    745745
     746#ifdef VBOX_WITH_DEBUG_REGISTER_SUPPORT
     747    /*
     748     * Check if host debug registers are armed. All context switches set DR7 back to 0x400.
     749     */
     750    uint64_t u64DR7 = ASMGetDR7();
     751    if (u32DR7 & X86_DR7_ENABLED_MASK)
     752    {
     753        pVM->hwaccm.s.savedhoststate.dr7  = u64DR7;
     754        pVM->hwaccm.s.savedhoststate.fHostDR7Saved = true;
     755    }
     756    else
     757        pVM->hwaccm.s.savedhoststate.fHostDR7Saved = false;
     758#endif
     759
    746760    /* Always reload the host context and the guest's CR0 register. (!!!!) */
    747761    pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0 | HWACCM_CHANGED_HOST_CONTEXT;
     
    791805        pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_CR0;
    792806    }
     807
     808#ifdef VBOX_WITH_DEBUG_REGISTER_SUPPORT
     809    if (pVM->hwaccm.s.savedhoststate.fHostDR7Saved)
     810    {
     811        ASMSetDR7(pVM->hwaccm.s.savedhoststate.dr7);
     812        pVM->hwaccm.s.savedhoststate.fHostDR7Saved = false;
     813    }
     814#endif
    793815
    794816    return HWACCMR0Globals.pfnLeaveSession(pVM);
  • trunk/src/VBox/VMM/VMMR0/HWSVMR0.cpp

    r12077 r12090  
    11691169    pCtx->SysEnter.esp      = pVMCB->guest.u64SysEnterESP;
    11701170
     1171    /* Remaining guest CPU context: TR, IDTR, GDTR, LDTR; must sync everything otherwise we can get out of sync when jumping to ring 3. */
     1172    SVM_READ_SELREG(LDTR, ldtr);
     1173    SVM_READ_SELREG(TR, tr);
     1174
     1175    pCtx->gdtr.cbGdt        = pVMCB->guest.GDTR.u32Limit;
     1176    pCtx->gdtr.pGdt         = pVMCB->guest.GDTR.u64Base;
     1177
     1178    pCtx->idtr.cbIdt        = pVMCB->guest.IDTR.u32Limit;
     1179    pCtx->idtr.pIdt         = pVMCB->guest.IDTR.u64Base;
     1180
    11711181    /* Note: no reason to sync back the CRx and DRx registers. They can't be changed by the guest. */
    11721182    /* Note: only in the nested paging case can CR3 & CR4 be changed by the guest. */
     
    16561666        {
    16571667            /* EIP has been updated already. */
     1668            pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG;
    16581669
    16591670            /* Only resume if successful. */
     
    18801891
    18811892end:
    1882     if (fGuestStateSynced)
    1883     {
    1884         /* Remaining guest CPU context: TR, IDTR, GDTR, LDTR. */
    1885         SVM_READ_SELREG(LDTR, ldtr);
    1886         SVM_READ_SELREG(TR, tr);
    1887 
    1888         pCtx->gdtr.cbGdt        = pVMCB->guest.GDTR.u32Limit;
    1889         pCtx->gdtr.pGdt         = pVMCB->guest.GDTR.u64Base;
    1890 
    1891         pCtx->idtr.cbIdt        = pVMCB->guest.IDTR.u32Limit;
    1892         pCtx->idtr.pIdt         = pVMCB->guest.IDTR.u64Base;
    1893     }
    18941893
    18951894    /* Signal changes for the recompiler. */
  • trunk/src/VBox/VMM/VMMR0/HWVMXR0.cpp

    r12079 r12090  
    11451145#endif
    11461146
    1147 #if 0
    1148     /*
    1149      * Check if debug registers are armed.
    1150      */
    1151     uint32_t u32DR7 = ASMGetDR7();
    1152     if (u32DR7 & X86_DR7_ENABLED_MASK)
    1153     {
    1154         pVM->cpum.s.fUseFlags |= CPUM_USE_DEBUG_REGS_HOST;
    1155     }
    1156     else
    1157         pVM->cpum.s.fUseFlags &= ~CPUM_USE_DEBUG_REGS_HOST;
    1158 #endif
    1159 
    11601147    /* We can jump to this point to resume execution after determining that a VM-exit is innocent.
    11611148     */
     
    15421529    VMXReadVMCS(VMX_VMCS_GUEST_SYSENTER_ESP,     &val);
    15431530    pCtx->SysEnter.esp      = val;
     1531
     1532    /* Misc. registers; must sync everything otherwise we can get out of sync when jumping to ring 3. */
     1533    VMX_READ_SELREG(LDTR, ldtr);
     1534    VMX_READ_SELREG(TR, tr);
     1535
     1536    VMXReadVMCS(VMX_VMCS_GUEST_GDTR_LIMIT,       &val);
     1537    pCtx->gdtr.cbGdt        = val;
     1538    VMXReadVMCS(VMX_VMCS_GUEST_GDTR_BASE,        &val);
     1539    pCtx->gdtr.pGdt         = val;
     1540
     1541    VMXReadVMCS(VMX_VMCS_GUEST_IDTR_LIMIT,       &val);
     1542    pCtx->idtr.cbIdt        = val;
     1543    VMXReadVMCS(VMX_VMCS_GUEST_IDTR_BASE,        &val);
     1544    pCtx->idtr.pIdt         = val;
    15441545
    15451546    /** @note NOW IT'S SAFE FOR LOGGING! */
     
    19501951                                     VMX_EXIT_QUALIFICATION_DRX_REGISTER(exitQualification),
    19511952                                     VMX_EXIT_QUALIFICATION_DRX_GENREG(exitQualification));
     1953            pVM->hwaccm.s.fContextUseFlags |= HWACCM_CHANGED_GUEST_DEBUG;
    19521954            Log2(("DR7=%08x\n", pCtx->dr7));
    19531955        }
     
    22212223    }
    22222224end:
    2223     if (fGuestStateSynced)
    2224     {
    2225         /* Remaining guest CPU context: TR, IDTR, GDTR, LDTR. */
    2226         VMX_READ_SELREG(LDTR, ldtr);
    2227         VMX_READ_SELREG(TR, tr);
    2228 
    2229         VMXReadVMCS(VMX_VMCS_GUEST_GDTR_LIMIT,       &val);
    2230         pCtx->gdtr.cbGdt        = val;
    2231         VMXReadVMCS(VMX_VMCS_GUEST_GDTR_BASE,        &val);
    2232         pCtx->gdtr.pGdt         = val;
    2233 
    2234         VMXReadVMCS(VMX_VMCS_GUEST_IDTR_LIMIT,       &val);
    2235         pCtx->idtr.cbIdt        = val;
    2236         VMXReadVMCS(VMX_VMCS_GUEST_IDTR_BASE,        &val);
    2237         pCtx->idtr.pIdt         = val;
    2238     }
    22392225
    22402226    /* Signal changes for the recompiler. */
注意: 瀏覽 TracChangeset 來幫助您使用更動檢視器

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