VirtualBox

Changeset 80047 in vbox for trunk/src


Ignore:
Timestamp:
Jul 29, 2019 7:12:29 PM (5 years ago)
Author:
vboxsync
Message:

Main: Kicking out raw-mode - GVMMR0, HMR0. bugref:9517

Location:
trunk/src/VBox/VMM
Files:
1 deleted
2 edited

Legend:

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

    r78431 r80047  
    899899                    const uint32_t  cPages    = RT_ALIGN_32(cbVM, PAGE_SIZE) >> PAGE_SHIFT;
    900900                    RTR0MEMOBJ      hVMMemObj = NIL_RTR0MEMOBJ;
    901 # if defined(VBOX_WITH_RAW_MODE) || HC_ARCH_BITS == 32
    902                     rc = RTR0MemObjAllocLow(&hVMMemObj, cPages << PAGE_SHIFT, false /* fExecutable */);
    903 # else
    904901                    rc = RTR0MemObjAllocPage(&hVMMemObj, cPages << PAGE_SHIFT, false /* fExecutable */);
    905 # endif
    906902                    if (RT_SUCCESS(rc))
    907903                    {
     
    10641060                            pVM->cCpus            = cCpus;
    10651061                            pVM->uCpuExecutionCap = 100; /* default is no cap. */
    1066 # ifdef VBOX_WITH_RAW_MODE
    1067                             pVM->offVMCPU         = RT_UOFFSETOF_DYN(VM, aCpus);
    1068 # endif
    10691062                            AssertCompileMemberAlignment(VM, cpum, 64);
    10701063                            AssertCompileMemberAlignment(VM, tm, 64);
     
    12371230    pGVM->cbSelf           = sizeof(VM);
    12381231    pGVM->cbVCpu           = sizeof(VMCPU);
    1239 # ifdef VBOX_WITH_RAW_MODE
    1240     pGVM->offVMCPU         = RT_UOFFSETOF_DYN(GVM, aCpus); /** @todo set this when mapping the VM structure into raw-mode context */
    1241 # endif
    12421232#endif
    12431233
  • trunk/src/VBox/VMM/VMMR0/HMR0.cpp

    r79352 r80047  
    16631663}
    16641664
    1665 
    1666 #ifdef VBOX_WITH_RAW_MODE
    1667 /**
    1668  * Raw-mode switcher hook - disable VT-x if it's active *and* the current
    1669  * switcher turns off paging.
    1670  *
    1671  * @returns VBox status code.
    1672  * @param   pVM             The cross context VM structure.
    1673  * @param   enmSwitcher     The switcher we're about to use.
    1674  * @param   pfVTxDisabled   Where to store whether VT-x was disabled or not.
    1675  */
    1676 VMMR0_INT_DECL(int) HMR0EnterSwitcher(PVM pVM, VMMSWITCHER enmSwitcher, bool *pfVTxDisabled)
    1677 {
    1678     NOREF(pVM);
    1679 
    1680     Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    1681 
    1682     *pfVTxDisabled = false;
    1683 
    1684     /* No such issues with AMD-V */
    1685     if (!g_HmR0.hwvirt.u.vmx.fSupported)
    1686         return VINF_SUCCESS;
    1687 
    1688     /* Check if the switching we're up to is safe. */
    1689     switch (enmSwitcher)
    1690     {
    1691         case VMMSWITCHER_32_TO_32:
    1692         case VMMSWITCHER_PAE_TO_PAE:
    1693             return VINF_SUCCESS;    /* safe switchers as they don't turn off paging */
    1694 
    1695         case VMMSWITCHER_32_TO_PAE:
    1696         case VMMSWITCHER_PAE_TO_32: /* is this one actually used?? */
    1697         case VMMSWITCHER_AMD64_TO_32:
    1698         case VMMSWITCHER_AMD64_TO_PAE:
    1699             break;                  /* unsafe switchers */
    1700 
    1701         default:
    1702             AssertFailedReturn(VERR_HM_WRONG_SWITCHER);
    1703     }
    1704 
    1705     /* When using SUPR0EnableVTx we must let the host suspend and resume VT-x,
    1706        regardless of whether we're currently using VT-x or not. */
    1707     if (g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx)
    1708     {
    1709         *pfVTxDisabled = SUPR0SuspendVTxOnCpu();
    1710         return VINF_SUCCESS;
    1711     }
    1712 
    1713     /** @todo Check if this code is presumptive wrt other VT-x users on the
    1714     *        system... */
    1715 
    1716     /* Nothing to do if we haven't enabled VT-x. */
    1717     if (!g_HmR0.fEnabled)
    1718         return VINF_SUCCESS;
    1719 
    1720     /* Local init implies the CPU is currently not in VMX root mode. */
    1721     if (!g_HmR0.fGlobalInit)
    1722         return VINF_SUCCESS;
    1723 
    1724     /* Ok, disable VT-x. */
    1725     PCHMPHYSCPU pHostCpu = hmR0GetCurrentCpu();
    1726     AssertReturn(   pHostCpu
    1727                  && pHostCpu->hMemObj != NIL_RTR0MEMOBJ
    1728                  && pHostCpu->pvMemObj
    1729                  && pHostCpu->HCPhysMemObj != NIL_RTHCPHYS,
    1730                  VERR_HM_IPE_2);
    1731 
    1732     *pfVTxDisabled = true;
    1733     return VMXR0DisableCpu(pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj);
    1734 }
    1735 
    1736 
    1737 /**
    1738  * Raw-mode switcher hook - re-enable VT-x if was active *and* the current
    1739  * switcher turned off paging.
    1740  *
    1741  * @param   pVM             The cross context VM structure.
    1742  * @param   fVTxDisabled    Whether VT-x was disabled or not.
    1743  */
    1744 VMMR0_INT_DECL(void) HMR0LeaveSwitcher(PVM pVM, bool fVTxDisabled)
    1745 {
    1746     Assert(!ASMIntAreEnabled());
    1747 
    1748     if (!fVTxDisabled)
    1749         return;         /* nothing to do */
    1750 
    1751     Assert(g_HmR0.hwvirt.u.vmx.fSupported);
    1752     if (g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx)
    1753         SUPR0ResumeVTxOnCpu(fVTxDisabled);
    1754     else
    1755     {
    1756         Assert(g_HmR0.fEnabled);
    1757         Assert(g_HmR0.fGlobalInit);
    1758 
    1759         PHMPHYSCPU pHostCpu = hmR0GetCurrentCpu();
    1760         AssertReturnVoid(   pHostCpu
    1761                          && pHostCpu->hMemObj != NIL_RTR0MEMOBJ
    1762                          && pHostCpu->pvMemObj
    1763                          && pHostCpu->HCPhysMemObj != NIL_RTHCPHYS);
    1764 
    1765         VMXR0EnableCpu(pHostCpu, pVM, pHostCpu->pvMemObj, pHostCpu->HCPhysMemObj, false, &g_HmR0.hwvirt.Msrs);
    1766     }
    1767 }
    1768 #endif /* VBOX_WITH_RAW_MODE */
    1769 
    1770 
    17711665#ifdef VBOX_STRICT
     1666
    17721667/**
    17731668 * Dumps a descriptor.
     
    20381933    NOREF(pFpuCtx);
    20391934}
     1935
    20401936#endif /* VBOX_STRICT */
    20411937
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