VirtualBox

Changeset 87532 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Feb 2, 2021 11:56:56 AM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
142558
Message:

VMM/HM: Moving the g_HmR0.hwvirt.svm.fSupported and g_HmR0.hwvirt.vmx.fSupported member out of the struct an into separate variables. bugref:9217

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

Legend:

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

    r87522 r87532  
    118118                /** The shift mask employed by the VMX-Preemption timer. */
    119119                uint8_t                     cPreemptTimerShift;
    120                 /** Padding. */
    121                 uint8_t                     abPadding[3];
    122120                /** Whether we're using the preemption timer or not. */
    123121                bool                        fUsePreemptTimer;
     
    127125                 * module termination. */
    128126                bool                        fCalledSUPR0EnableVTx;
    129                 /** Set to by us to indicate VMX is supported by the CPU. */
    130                 bool                        fSupported;
    131127            } vmx;
    132128
     
    138134                /** SVM feature bits from cpuid 0x8000000a */
    139135                uint32_t                    u32Features;
    140                 /** Padding. */
    141                 bool                        afPadding[3];
    142                 /** Set by us to indicate SVM is supported by the CPU. */
    143                 bool                        fSupported;
    144136            } svm;
    145137        } u;
     
    167159} g_HmR0;
    168160
     161
     162/** Set if VT-x (VMX) is supported by the CPU. */
     163bool        g_fHmVmxSupported = false;
     164/** Set if AMD-V is supported by the CPU. */
     165bool        g_fHmSvmSupported = false;
    169166/** Maximum allowed ASID/VPID (inclusive).
    170167 * @todo r=bird: This is exclusive for VT-x according to source code comment.
     
    316313        if (RT_SUCCESS(rc))
    317314        {
    318             g_HmR0.hwvirt.u.vmx.fSupported = true;
     315            g_fHmVmxSupported = true;
    319316            rc = SUPR0EnableVTx(false /* fEnable */);
    320317            AssertLogRelRC(rc);
     
    386383            if (RT_SUCCESS(rc))
    387384            {
    388                 g_HmR0.hwvirt.u.vmx.fSupported = true;
     385                g_fHmVmxSupported = true;
    389386                VMXDisable();
    390387            }
     
    403400                 */
    404401                g_HmR0.rcInit = VERR_VMX_IN_VMX_ROOT_MODE;
    405                 Assert(g_HmR0.hwvirt.u.vmx.fSupported == false);
     402                Assert(g_fHmVmxSupported == false);
    406403            }
    407404
     
    416413        }
    417414
    418         if (g_HmR0.hwvirt.u.vmx.fSupported)
     415        if (g_fHmVmxSupported)
    419416        {
    420417            rc = VMXR0GlobalInit();
     
    510507    {
    511508        SUPR0GetHwvirtMsrs(&g_HmR0.hwvirt.Msrs, SUPVTCAPS_AMD_V, false /* fForce */);
    512         g_HmR0.hwvirt.u.svm.fSupported = true;
     509        g_fHmSvmSupported = true;
    513510    }
    514511    else
     
    562559    /* Default is global VT-x/AMD-V init. */
    563560    g_HmR0.fGlobalInit         = true;
     561
     562    g_fHmVmxSupported  = false;
     563    g_fHmSvmSupported  = false;
     564    g_uHmMaxAsid       = 0;
    564565
    565566    /*
     
    623624{
    624625    int rc;
    625     if (   g_HmR0.hwvirt.u.vmx.fSupported
     626    if (   g_fHmVmxSupported
    626627        && g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx)
    627628    {
     
    647648    else
    648649    {
    649         Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     650        Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    650651
    651652        /* Doesn't really matter if this fails. */
     
    694695     *        should move into their respective modules. */
    695696    /* Finally, call global VT-x/AMD-V termination. */
    696     if (g_HmR0.hwvirt.u.vmx.fSupported)
     697    if (g_fHmVmxSupported)
    697698        VMXR0GlobalTerm();
    698     else if (g_HmR0.hwvirt.u.svm.fSupported)
     699    else if (g_fHmSvmSupported)
    699700        SVMR0GlobalTerm();
    700701
     
    765766
    766767    int rc;
    767     if (   g_HmR0.hwvirt.u.vmx.fSupported
     768    if (   g_fHmVmxSupported
    768769        && g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx)
    769770        rc = g_HmR0.pfnEnableCpu(pHostCpu, pVM, NULL /* pvCpuPage */, NIL_RTHCPHYS, true, &g_HmR0.hwvirt.Msrs);
     
    838839
    839840    int rc;
    840     if (   g_HmR0.hwvirt.u.vmx.fSupported
     841    if (   g_fHmVmxSupported
    841842        && g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx)
    842843    {
     
    942943    PHMPHYSCPU pHostCpu = &g_HmR0.aCpuInfo[idCpu];
    943944
    944     Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     945    Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    945946    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    946947    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
     
    10111012{
    10121013    NOREF(pvData);
    1013     Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     1014    Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    10141015
    10151016    /*
     
    10521053{
    10531054    NOREF(pvUser);
    1054     Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     1055    Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    10551056
    10561057#ifdef LOG_ENABLED
     
    10841085            /* Reinit the CPUs from scratch as the suspend state might have
    10851086               messed with the MSRs. (lousy BIOSes as usual) */
    1086             if (g_HmR0.hwvirt.u.vmx.fSupported)
     1087            if (g_fHmVmxSupported)
    10871088                rc = RTMpOnAll(hmR0InitIntelCpu, &FirstRc, NULL);
    10881089            else
     
    13131314    if (!g_HmR0.fGlobalInit)
    13141315    {
    1315         Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     1316        Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    13161317        rc = hmR0EnableCpu(pVM, idCpu);
    13171318        if (RT_FAILURE(rc))
     
    13281329    if (!g_HmR0.fGlobalInit)
    13291330    {
    1330         Assert(!g_HmR0.hwvirt.u.vmx.fSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
     1331        Assert(!g_fHmVmxSupported || !g_HmR0.hwvirt.u.vmx.fUsingSUPR0EnableVTx);
    13311332        int rc2 = hmR0DisableCpu(idCpu);
    13321333        AssertRC(rc2);
     
    13811382
    13821383    /* Reload host-state (back from ring-3/migrated CPUs) and shared guest/host bits. */
    1383     if (g_HmR0.hwvirt.u.vmx.fSupported)
     1384    if (g_fHmVmxSupported)
    13841385        pVCpu->hm.s.fCtxChanged |= HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE;
    13851386    else
     
    14101411    if (RT_SUCCESS(rc))
    14111412    {
    1412         if (g_HmR0.hwvirt.u.vmx.fSupported)
    1413         {
    1414             Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE))
    1415                                            == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE));
    1416         }
     1413        if (g_fHmVmxSupported)
     1414            Assert(   (pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE))
     1415                   ==                            (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_VMX_HOST_GUEST_SHARED_STATE));
    14171416        else
    1418         {
    1419             Assert((pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE))
    1420                                            == (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE));
    1421         }
     1417            Assert(   (pVCpu->hm.s.fCtxChanged & (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE))
     1418                   ==                            (HM_CHANGED_HOST_CONTEXT | HM_CHANGED_SVM_HOST_GUEST_SHARED_STATE));
    14221419
    14231420#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
  • trunk/src/VBox/VMM/include/HMInternal.h

    r87531 r87532  
    548548        uint32_t                    u32Alignment1;
    549549
    550         /** Host-physical address for a failing VMXON instruction. */
     550        /** Host-physical address for a failing VMXON instruction (diagnostics). */
    551551        RTHCPHYS                    HCPhysVmxEnableError;
    552552
     
    578578        uint8_t                     u8Alignment0[2];
    579579
    580         /* HWCR MSR (for diagnostics) */
     580        /** HWCR MSR (for diagnostics). */
    581581        uint64_t                    u64MsrHwcr;
    582582
     
    14431443
    14441444#ifdef IN_RING0
     1445extern bool     g_fHmVmxSupported;
     1446extern bool     g_fHmSvmSupported;
    14451447extern uint32_t g_uHmMaxAsid;
    14461448
Note: See TracChangeset for help on using the changeset viewer.

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