VirtualBox

Changeset 74487 in vbox for trunk


Ignore:
Timestamp:
Sep 27, 2018 4:17:27 AM (6 years ago)
Author:
vboxsync
Message:

VMM/CPUM: Nested SVM, VMX: bugref:7243 bugref:9180 Fix for upcoming nested VMX changes. Use the enum to figure out which union
to reference rather than assuming existence and offsets of VMCB/VMCS pointer. Gives us flexibility in keeping VMX and SVM unions
without a partially shared layout.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r74165 r74487  
    16361636DECLINLINE(bool) CPUMIsGuestSvmCtrlInterceptSet(PVMCPU pVCpu, PCPUMCTX pCtx, uint64_t fIntercept)
    16371637{
    1638     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1639     if (!pVmcb)
     1638    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    16401639        return false;
     1640    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    16411641    if (HMHasGuestSvmVmcbCached(pVCpu))
    16421642        return HMIsGuestSvmCtrlInterceptSet(pVCpu, fIntercept);
     
    16551655{
    16561656    Assert(uCr < 16);
    1657     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1658     if (!pVmcb)
     1657    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    16591658        return false;
     1659    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    16601660    if (HMHasGuestSvmVmcbCached(pVCpu))
    16611661        return HMIsGuestSvmReadCRxInterceptSet(pVCpu, uCr);
     
    16741674{
    16751675    Assert(uCr < 16);
    1676     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1677     if (!pVmcb)
     1676    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    16781677        return false;
     1678    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    16791679    if (HMHasGuestSvmVmcbCached(pVCpu))
    16801680        return HMIsGuestSvmWriteCRxInterceptSet(pVCpu, uCr);
     
    16931693{
    16941694    Assert(uDr < 16);
    1695     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1696     if (!pVmcb)
     1695    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    16971696        return false;
     1697    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    16981698    if (HMHasGuestSvmVmcbCached(pVCpu))
    16991699        return HMIsGuestSvmReadDRxInterceptSet(pVCpu, uDr);
     
    17121712{
    17131713    Assert(uDr < 16);
    1714     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1715     if (!pVmcb)
     1714    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    17161715        return false;
     1716    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    17171717    if (HMHasGuestSvmVmcbCached(pVCpu))
    17181718        return HMIsGuestSvmWriteDRxInterceptSet(pVCpu, uDr);
     
    17311731{
    17321732    Assert(uVector < 32);
    1733     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1734     if (!pVmcb)
     1733    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    17351734        return false;
     1735    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    17361736    if (HMHasGuestSvmVmcbCached(pVCpu))
    17371737        return HMIsGuestSvmXcptInterceptSet(pVCpu, uVector);
     
    17501750DECLINLINE(bool) CPUMIsGuestSvmVirtIntrMasking(PVMCPU pVCpu, PCCPUMCTX pCtx)
    17511751{
    1752     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1753     if (!pVmcb)
     1752    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    17541753        return false;
     1754    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    17551755    if (HMHasGuestSvmVmcbCached(pVCpu))
    17561756        return HMIsGuestSvmVirtIntrMasking(pVCpu);
     
    17691769DECLINLINE(bool) CPUMIsGuestSvmNestedPagingEnabled(PVMCPU pVCpu, PCCPUMCTX pCtx)
    17701770{
    1771     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1772     if (!pVmcb)
     1771    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    17731772        return false;
     1773    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    17741774    if (HMHasGuestSvmVmcbCached(pVCpu))
    17751775        return HMIsGuestSvmNestedPagingEnabled(pVCpu);
     
    17881788DECLINLINE(uint16_t) CPUMGetGuestSvmPauseFilterCount(PVMCPU pVCpu, PCCPUMCTX pCtx)
    17891789{
    1790     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1791     if (!pVmcb)
     1790    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM)
    17921791        return false;
     1792    PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb); Assert(pVmcb);
    17931793    if (HMHasGuestSvmVmcbCached(pVCpu))
    17941794        return HMGetGuestSvmPauseFilterCount(pVCpu);
     
    18081808{
    18091809    RT_NOREF(pVCpu);
     1810    Assert(pCtx->hwvirt.enmHwvirt == CPUMHWVIRT_SVM);
    18101811    PSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    18111812    Assert(pVmcb);
     
    18281829     */
    18291830#ifndef IN_RC
    1830     PCSVMVMCB pVmcb = pCtx->hwvirt.svm.CTX_SUFF(pVmcb);
    1831     return pVmcb && (pVmcb->ctrl.u64InterceptCtrl & SVM_CTRL_INTERCEPT_VMRUN);
     1831    if (   pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_SVM
     1832        || !(pCtx->hwvirt.svm.CTX_SUFF(pVmcb)->ctrl.u64InterceptCtrl & SVM_CTRL_INTERCEPT_VMRUN))
     1833        return false;
     1834    return true;
    18321835#else
    18331836    NOREF(pCtx);
     
    18451848{
    18461849#ifndef IN_RC
     1850    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_VMX)
     1851        return false;
    18471852    Assert(!pCtx->hwvirt.vmx.fInVmxNonRootMode || pCtx->hwvirt.vmx.fInVmxRootMode);
    18481853    return pCtx->hwvirt.vmx.fInVmxNonRootMode;
     
    18621867{
    18631868#ifndef IN_RC
     1869    if (pCtx->hwvirt.enmHwvirt != CPUMHWVIRT_VMX)
     1870        return false;
    18641871    return pCtx->hwvirt.vmx.fInVmxRootMode;
    18651872#else
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