VirtualBox

Changeset 71908 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Apr 19, 2018 5:13:28 AM (7 years ago)
Author:
vboxsync
Message:

VMM/HMSVMR0: Cleanup, for using up next added if 0'd set/clear functions for control intercepts.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r71907 r71908  
    13711371
    13721372/**
    1373  * Adds an exception to the intercept exception bitmap in the VMCB and updates
    1374  * the corresponding VMCB Clean bit.
     1373 * Sets an exception intercept in the specified VMCB.
    13751374 *
    13761375 * @param   pVmcb       Pointer to the VM control block.
    1377  * @param   u32Xcpt     The value of the exception (X86_XCPT_*).
    1378  */
    1379 DECLINLINE(void) hmR0SvmAddXcptIntercept(PSVMVMCB pVmcb, uint32_t u32Xcpt)
    1380 {
    1381     if (!(pVmcb->ctrl.u32InterceptXcpt & RT_BIT(u32Xcpt)))
    1382     {
    1383         pVmcb->ctrl.u32InterceptXcpt |= RT_BIT(u32Xcpt);
     1376 * @param   uXcpt       The exception (X86_XCPT_*).
     1377 */
     1378DECLINLINE(void) hmR0SvmSetXcptIntercept(PSVMVMCB pVmcb, uint8_t uXcpt)
     1379{
     1380    if (!(pVmcb->ctrl.u32InterceptXcpt & RT_BIT(uXcpt)))
     1381    {
     1382        pVmcb->ctrl.u32InterceptXcpt |= RT_BIT(uXcpt);
    13841383        pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS;
    13851384    }
     
    13881387
    13891388/**
    1390  * Removes an exception from the intercept-exception bitmap in the VMCB and
    1391  * updates the corresponding VMCB Clean bit.
     1389 * Clears an exception intercept in the specified VMCB.
    13921390 *
    13931391 * @param   pVCpu       The cross context virtual CPU structure.
    13941392 * @param   pCtx        Pointer to the guest-CPU context.
    13951393 * @param   pVmcb       Pointer to the VM control block.
    1396  * @param   u32Xcpt     The value of the exception (X86_XCPT_*).
     1394 * @param   uXcpt       The exception (X86_XCPT_*).
    13971395 *
    13981396 * @remarks This takes into account if we're executing a nested-guest and only
     
    14001398 *          are not intercepting it.
    14011399 */
    1402 DECLINLINE(void) hmR0SvmRemoveXcptIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint32_t u32Xcpt)
    1403 {
    1404     Assert(u32Xcpt != X86_XCPT_DB);
    1405     Assert(u32Xcpt != X86_XCPT_AC);
     1400DECLINLINE(void) hmR0SvmClearXcptIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint8_t uXcpt)
     1401{
     1402    Assert(uXcpt != X86_XCPT_DB);
     1403    Assert(uXcpt != X86_XCPT_AC);
    14061404#ifndef HMSVM_ALWAYS_TRAP_ALL_XCPTS
    1407     if (pVmcb->ctrl.u32InterceptXcpt & RT_BIT(u32Xcpt))
    1408     {
    1409         bool fRemoveXcpt = true;
     1405    if (pVmcb->ctrl.u32InterceptXcpt & RT_BIT(uXcpt))
     1406    {
     1407        bool fRemove = true;
    14101408#ifdef VBOX_WITH_NESTED_HWVIRT
    14111409        /* Only remove the intercept if the nested-guest is also not intercepting it! */
     
    14131411        {
    14141412            PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = hmR0SvmGetNestedVmcbCache(pVCpu, pCtx);
    1415             fRemoveXcpt = !(pVmcbNstGstCache->u32InterceptXcpt & RT_BIT(u32Xcpt));
     1413            fRemove = !(pVmcbNstGstCache->u32InterceptXcpt & RT_BIT(uXcpt));
    14161414        }
    14171415#else
    14181416        RT_NOREF2(pVCpu, pCtx);
    14191417#endif
    1420         if (fRemoveXcpt)
    1421         {
    1422             pVmcb->ctrl.u32InterceptXcpt &= ~RT_BIT(u32Xcpt);
     1418        if (fRemove)
     1419        {
     1420            pVmcb->ctrl.u32InterceptXcpt &= ~RT_BIT(uXcpt);
    14231421            pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS;
    14241422        }
     
    14291427}
    14301428
     1429#if 0
     1430/**
     1431 * Sets a control intercept in the specified VMCB.
     1432 *
     1433 * @param   pVmcb           Pointer to the VM control block.
     1434 * @param   fCtrlIntercept  The control intercept (SVM_CTRL_INTERCEPT_*).
     1435 */
     1436DECLINLINE(void) hmR0SvmSetCtrlIntercept(PSVMVMCB pVmcb, uint64_t fCtrlIntercept)
     1437{
     1438    if (!(pVmcb->ctrl.u64InterceptCtrl & fCtrlIntercept))
     1439    {
     1440        pVmcb->ctrl.u64InterceptCtrl |= fCtrlIntercept;
     1441        pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS;
     1442    }
     1443}
     1444
     1445
     1446/**
     1447 * Clears a control intercept in the specified VMCB.
     1448 *
     1449 * @param   pVCpu           The cross context virtual CPU structure.
     1450 * @param   pCtx            Pointer to the guest-CPU context.
     1451 * @param   pVmcb           Pointer to the VM control block.
     1452 * @param   fCtrlIntercept  The control intercept (SVM_CTRL_INTERCEPT_*).
     1453 *
     1454 * @remarks This takes into account if we're executing a nested-guest and only
     1455 *          removes the control intercept if both the guest -and- nested-guest
     1456 *          are not intercepting it.
     1457 */
     1458DECLINLINE(void) hmR0SvmClearCtrlIntercept(PVMCPU pVCpu, PCPUMCTX pCtx, PSVMVMCB pVmcb, uint64_t fCtrlIntercept)
     1459{
     1460    if (pVmcb->ctrl.u64InterceptCtrl & fCtrlIntercept)
     1461    {
     1462        bool fRemove = true;
     1463#ifdef VBOX_WITH_NESTED_HWVIRT
     1464        /* Only remove the control intercept if the nested-guest is also not intercepting it! */
     1465        if (CPUMIsGuestInSvmNestedHwVirtMode(pCtx))
     1466        {
     1467            PCSVMNESTEDVMCBCACHE pVmcbNstGstCache = hmR0SvmGetNestedVmcbCache(pVCpu, pCtx);
     1468            fRemove = !(pVmcbNstGstCache->u64InterceptCtrl & fCtrlIntercept);
     1469        }
     1470#else
     1471        RT_NOREF2(pVCpu, pCtx);
     1472#endif
     1473        if (fRemove)
     1474        {
     1475            pVmcb->ctrl.u64InterceptCtrl &= ~fCtrlIntercept;
     1476            pVmcb->ctrl.u32VmcbCleanBits &= ~HMSVM_VMCB_CLEAN_INTERCEPTS;
     1477        }
     1478    }
     1479}
     1480#endif
    14311481
    14321482/**
     
    14691519    {
    14701520        uShadowCr0 |= X86_CR0_NE;
    1471         hmR0SvmAddXcptIntercept(pVmcb, X86_XCPT_MF);
     1521        hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_MF);
    14721522    }
    14731523    else
    1474         hmR0SvmRemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_MF);
     1524        hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_MF);
    14751525
    14761526    /*
     
    20332083        /* Trap #UD for GIM provider (e.g. for hypercalls). */
    20342084        if (pVCpu->hm.s.fGIMTrapXcptUD)
    2035             hmR0SvmAddXcptIntercept(pVmcb, X86_XCPT_UD);
     2085            hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_UD);
    20362086        else
    2037             hmR0SvmRemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_UD);
     2087            hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_UD);
    20382088
    20392089        /* Trap #BP for INT3 debug breakpoints set by the VM debugger. */
    20402090        if (pVCpu->CTX_SUFF(pVM)->dbgf.ro.cEnabledInt3Breakpoints)
    2041             hmR0SvmAddXcptIntercept(pVmcb, X86_XCPT_BP);
     2091            hmR0SvmSetXcptIntercept(pVmcb, X86_XCPT_BP);
    20422092        else
    2043             hmR0SvmRemoveXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_BP);
     2093            hmR0SvmClearXcptIntercept(pVCpu, pCtx, pVmcb, X86_XCPT_BP);
    20442094
    20452095        /* The remaining intercepts are handled elsewhere, e.g. in hmR0SvmLoadSharedCR0(). */
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