VirtualBox

Changeset 56364 in vbox for trunk/src/VBox/VMM/VMMR0


Ignore:
Timestamp:
Jun 11, 2015 2:52:57 PM (9 years ago)
Author:
vboxsync
Message:

VMM/HM: g_HvmR0 -> g_HmR0.

File:
1 edited

Legend:

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

    r56360 r56364  
    165165    /** Serialize initialization in HMR0EnableAllCpus. */
    166166    RTONCE                          EnableAllCpusOnce;
    167 } g_HvmR0;
     167} g_HmR0;
    168168
    169169
     
    344344    {
    345345        /** @todo move this into a separate function. */
    346         g_HvmR0.vmx.Msrs.u64FeatureCtrl = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
     346        g_HmR0.vmx.Msrs.u64FeatureCtrl = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    347347
    348348        /*
     
    350350         * (This is only supported by some Mac OS X kernels atm.)
    351351         */
    352         int rc = g_HvmR0.lLastError = SUPR0EnableVTx(true /* fEnable */);
    353         g_HvmR0.vmx.fUsingSUPR0EnableVTx = rc != VERR_NOT_SUPPORTED;
    354         if (g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     352        int rc = g_HmR0.lLastError = SUPR0EnableVTx(true /* fEnable */);
     353        g_HmR0.vmx.fUsingSUPR0EnableVTx = rc != VERR_NOT_SUPPORTED;
     354        if (g_HmR0.vmx.fUsingSUPR0EnableVTx)
    355355        {
    356356            AssertLogRelMsg(rc == VINF_SUCCESS || rc == VERR_VMX_IN_VMX_ROOT_MODE || rc == VERR_VMX_NO_VMX, ("%Rrc\n", rc));
    357357            if (RT_SUCCESS(rc))
    358358            {
    359                 g_HvmR0.vmx.fSupported = true;
     359                g_HmR0.vmx.fSupported = true;
    360360                rc = SUPR0EnableVTx(false /* fEnable */);
    361361                AssertLogRelRC(rc);
     
    368368            HMR0FIRSTRC FirstRc;
    369369            hmR0FirstRcInit(&FirstRc);
    370             g_HvmR0.lLastError = RTMpOnAll(hmR0InitIntelCpu, &FirstRc, NULL);
    371             if (RT_SUCCESS(g_HvmR0.lLastError))
    372                 g_HvmR0.lLastError = hmR0FirstRcGetStatus(&FirstRc);
     370            g_HmR0.lLastError = RTMpOnAll(hmR0InitIntelCpu, &FirstRc, NULL);
     371            if (RT_SUCCESS(g_HmR0.lLastError))
     372                g_HmR0.lLastError = hmR0FirstRcGetStatus(&FirstRc);
    373373        }
    374         if (RT_SUCCESS(g_HvmR0.lLastError))
     374        if (RT_SUCCESS(g_HmR0.lLastError))
    375375        {
    376376            /* Reread in case it was changed by hmR0InitIntelCpu(). */
    377             g_HvmR0.vmx.Msrs.u64FeatureCtrl = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
     377            g_HmR0.vmx.Msrs.u64FeatureCtrl = ASMRdMsr(MSR_IA32_FEATURE_CONTROL);
    378378
    379379            /*
    380380             * Read all relevant registers and MSRs.
    381381             */
    382             g_HvmR0.vmx.u64HostCr4          = ASMGetCR4();
    383             g_HvmR0.vmx.u64HostEfer         = ASMRdMsr(MSR_K6_EFER);
    384             g_HvmR0.vmx.Msrs.u64BasicInfo   = ASMRdMsr(MSR_IA32_VMX_BASIC_INFO);
    385             g_HvmR0.vmx.Msrs.VmxPinCtls.u   = ASMRdMsr(MSR_IA32_VMX_PINBASED_CTLS);
    386             g_HvmR0.vmx.Msrs.VmxProcCtls.u  = ASMRdMsr(MSR_IA32_VMX_PROCBASED_CTLS);
    387             g_HvmR0.vmx.Msrs.VmxExit.u      = ASMRdMsr(MSR_IA32_VMX_EXIT_CTLS);
    388             g_HvmR0.vmx.Msrs.VmxEntry.u     = ASMRdMsr(MSR_IA32_VMX_ENTRY_CTLS);
    389             g_HvmR0.vmx.Msrs.u64Misc        = ASMRdMsr(MSR_IA32_VMX_MISC);
    390             g_HvmR0.vmx.Msrs.u64Cr0Fixed0   = ASMRdMsr(MSR_IA32_VMX_CR0_FIXED0);
    391             g_HvmR0.vmx.Msrs.u64Cr0Fixed1   = ASMRdMsr(MSR_IA32_VMX_CR0_FIXED1);
    392             g_HvmR0.vmx.Msrs.u64Cr4Fixed0   = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED0);
    393             g_HvmR0.vmx.Msrs.u64Cr4Fixed1   = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED1);
    394             g_HvmR0.vmx.Msrs.u64VmcsEnum    = ASMRdMsr(MSR_IA32_VMX_VMCS_ENUM);
     382            g_HmR0.vmx.u64HostCr4          = ASMGetCR4();
     383            g_HmR0.vmx.u64HostEfer         = ASMRdMsr(MSR_K6_EFER);
     384            g_HmR0.vmx.Msrs.u64BasicInfo   = ASMRdMsr(MSR_IA32_VMX_BASIC_INFO);
     385            g_HmR0.vmx.Msrs.VmxPinCtls.u   = ASMRdMsr(MSR_IA32_VMX_PINBASED_CTLS);
     386            g_HmR0.vmx.Msrs.VmxProcCtls.u  = ASMRdMsr(MSR_IA32_VMX_PROCBASED_CTLS);
     387            g_HmR0.vmx.Msrs.VmxExit.u      = ASMRdMsr(MSR_IA32_VMX_EXIT_CTLS);
     388            g_HmR0.vmx.Msrs.VmxEntry.u     = ASMRdMsr(MSR_IA32_VMX_ENTRY_CTLS);
     389            g_HmR0.vmx.Msrs.u64Misc        = ASMRdMsr(MSR_IA32_VMX_MISC);
     390            g_HmR0.vmx.Msrs.u64Cr0Fixed0   = ASMRdMsr(MSR_IA32_VMX_CR0_FIXED0);
     391            g_HmR0.vmx.Msrs.u64Cr0Fixed1   = ASMRdMsr(MSR_IA32_VMX_CR0_FIXED1);
     392            g_HmR0.vmx.Msrs.u64Cr4Fixed0   = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED0);
     393            g_HmR0.vmx.Msrs.u64Cr4Fixed1   = ASMRdMsr(MSR_IA32_VMX_CR4_FIXED1);
     394            g_HmR0.vmx.Msrs.u64VmcsEnum    = ASMRdMsr(MSR_IA32_VMX_VMCS_ENUM);
    395395            /* VPID 16 bits ASID. */
    396             g_HvmR0.uMaxAsid                = 0x10000; /* exclusive */
    397 
    398             if (g_HvmR0.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL)
     396            g_HmR0.uMaxAsid                = 0x10000; /* exclusive */
     397
     398            if (g_HmR0.vmx.Msrs.VmxProcCtls.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC_USE_SECONDARY_EXEC_CTRL)
    399399            {
    400                 g_HvmR0.vmx.Msrs.VmxProcCtls2.u = ASMRdMsr(MSR_IA32_VMX_PROCBASED_CTLS2);
    401                 if (g_HvmR0.vmx.Msrs.VmxProcCtls2.n.allowed1 & (VMX_VMCS_CTRL_PROC_EXEC2_EPT | VMX_VMCS_CTRL_PROC_EXEC2_VPID))
    402                     g_HvmR0.vmx.Msrs.u64EptVpidCaps = ASMRdMsr(MSR_IA32_VMX_EPT_VPID_CAP);
    403 
    404                 if (g_HvmR0.vmx.Msrs.VmxProcCtls2.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC2_VMFUNC)
    405                     g_HvmR0.vmx.Msrs.u64Vmfunc = ASMRdMsr(MSR_IA32_VMX_VMFUNC);
     400                g_HmR0.vmx.Msrs.VmxProcCtls2.u = ASMRdMsr(MSR_IA32_VMX_PROCBASED_CTLS2);
     401                if (g_HmR0.vmx.Msrs.VmxProcCtls2.n.allowed1 & (VMX_VMCS_CTRL_PROC_EXEC2_EPT | VMX_VMCS_CTRL_PROC_EXEC2_VPID))
     402                    g_HmR0.vmx.Msrs.u64EptVpidCaps = ASMRdMsr(MSR_IA32_VMX_EPT_VPID_CAP);
     403
     404                if (g_HmR0.vmx.Msrs.VmxProcCtls2.n.allowed1 & VMX_VMCS_CTRL_PROC_EXEC2_VMFUNC)
     405                    g_HmR0.vmx.Msrs.u64Vmfunc = ASMRdMsr(MSR_IA32_VMX_VMFUNC);
    406406            }
    407407
    408             if (!g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     408            if (!g_HmR0.vmx.fUsingSUPR0EnableVTx)
    409409            {
    410410                /*
     
    424424
    425425                /* Set revision dword at the beginning of the structure. */
    426                 *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(g_HvmR0.vmx.Msrs.u64BasicInfo);
     426                *(uint32_t *)pvScatchPage = MSR_IA32_VMX_BASIC_INFO_VMCS_ID(g_HmR0.vmx.Msrs.u64BasicInfo);
    427427
    428428                /* Make sure we don't get rescheduled to another cpu during this probe. */
     
    432432                 * Check CR4.VMXE
    433433                 */
    434                 g_HvmR0.vmx.u64HostCr4 = ASMGetCR4();
    435                 if (!(g_HvmR0.vmx.u64HostCr4 & X86_CR4_VMXE))
     434                g_HmR0.vmx.u64HostCr4 = ASMGetCR4();
     435                if (!(g_HmR0.vmx.u64HostCr4 & X86_CR4_VMXE))
    436436                {
    437437                    /* In theory this bit could be cleared behind our back.  Which would cause
    438438                       #UD faults when we try to execute the VMX instructions... */
    439                     ASMSetCR4(g_HvmR0.vmx.u64HostCr4 | X86_CR4_VMXE);
     439                    ASMSetCR4(g_HmR0.vmx.u64HostCr4 | X86_CR4_VMXE);
    440440                }
    441441
     
    448448                if (RT_SUCCESS(rc))
    449449                {
    450                     g_HvmR0.vmx.fSupported = true;
     450                    g_HmR0.vmx.fSupported = true;
    451451                    VMXDisable();
    452452                }
     
    464464                     * They should fix their code, but until they do we simply refuse to run.
    465465                     */
    466                     g_HvmR0.lLastError = VERR_VMX_IN_VMX_ROOT_MODE;
    467                     Assert(g_HvmR0.vmx.fSupported == false);
     466                    g_HmR0.lLastError = VERR_VMX_IN_VMX_ROOT_MODE;
     467                    Assert(g_HmR0.vmx.fSupported == false);
    468468                }
    469469
     
    471471                   if it wasn't so before (some software could incorrectly
    472472                   think it's in VMX mode). */
    473                 ASMSetCR4(g_HvmR0.vmx.u64HostCr4);
     473                ASMSetCR4(g_HmR0.vmx.u64HostCr4);
    474474                ASMSetFlags(fFlags);
    475475
     
    477477            }
    478478
    479             if (g_HvmR0.vmx.fSupported)
     479            if (g_HmR0.vmx.fSupported)
    480480            {
    481481                rc = VMXR0GlobalInit();
    482482                if (RT_FAILURE(rc))
    483                     g_HvmR0.lLastError = rc;
     483                    g_HmR0.lLastError = rc;
    484484
    485485                /*
    486486                 * Install the VT-x methods.
    487487                 */
    488                 g_HvmR0.pfnEnterSession      = VMXR0Enter;
    489                 g_HvmR0.pfnThreadCtxCallback = VMXR0ThreadCtxCallback;
    490                 g_HvmR0.pfnSaveHostState     = VMXR0SaveHostState;
    491                 g_HvmR0.pfnRunGuestCode      = VMXR0RunGuestCode;
    492                 g_HvmR0.pfnEnableCpu         = VMXR0EnableCpu;
    493                 g_HvmR0.pfnDisableCpu        = VMXR0DisableCpu;
    494                 g_HvmR0.pfnInitVM            = VMXR0InitVM;
    495                 g_HvmR0.pfnTermVM            = VMXR0TermVM;
    496                 g_HvmR0.pfnSetupVM           = VMXR0SetupVM;
     488                g_HmR0.pfnEnterSession      = VMXR0Enter;
     489                g_HmR0.pfnThreadCtxCallback = VMXR0ThreadCtxCallback;
     490                g_HmR0.pfnSaveHostState     = VMXR0SaveHostState;
     491                g_HmR0.pfnRunGuestCode      = VMXR0RunGuestCode;
     492                g_HmR0.pfnEnableCpu         = VMXR0EnableCpu;
     493                g_HmR0.pfnDisableCpu        = VMXR0DisableCpu;
     494                g_HmR0.pfnInitVM            = VMXR0InitVM;
     495                g_HmR0.pfnTermVM            = VMXR0TermVM;
     496                g_HmR0.pfnSetupVM           = VMXR0SetupVM;
    497497
    498498                /*
     
    500500                 * Timer Does Not Count Down at the Rate Specified" erratum.
    501501                 */
    502                 if (g_HvmR0.vmx.Msrs.VmxPinCtls.n.allowed1 & VMX_VMCS_CTRL_PIN_EXEC_PREEMPT_TIMER)
     502                if (g_HmR0.vmx.Msrs.VmxPinCtls.n.allowed1 & VMX_VMCS_CTRL_PIN_EXEC_PREEMPT_TIMER)
    503503                {
    504                     g_HvmR0.vmx.fUsePreemptTimer   = true;
    505                     g_HvmR0.vmx.cPreemptTimerShift = MSR_IA32_VMX_MISC_PREEMPT_TSC_BIT(g_HvmR0.vmx.Msrs.u64Misc);
     504                    g_HmR0.vmx.fUsePreemptTimer   = true;
     505                    g_HmR0.vmx.cPreemptTimerShift = MSR_IA32_VMX_MISC_PREEMPT_TSC_BIT(g_HmR0.vmx.Msrs.u64Misc);
    506506                    if (hmR0InitIntelIsSubjectToVmxPreemptionTimerErratum())
    507                         g_HvmR0.vmx.cPreemptTimerShift = 0; /* This is about right most of the time here. */
     507                        g_HmR0.vmx.cPreemptTimerShift = 0; /* This is about right most of the time here. */
    508508                }
    509509            }
     
    511511#ifdef LOG_ENABLED
    512512        else
    513             SUPR0Printf("hmR0InitIntelCpu failed with rc=%d\n", g_HvmR0.lLastError);
     513            SUPR0Printf("hmR0InitIntelCpu failed with rc=%d\n", g_HmR0.lLastError);
    514514#endif
    515515    }
    516516    else
    517         g_HvmR0.lLastError = VERR_VMX_NO_VMX;
     517        g_HmR0.lLastError = VERR_VMX_NO_VMX;
    518518    return VINF_SUCCESS;
    519519}
     
    532532     */
    533533    int rc;
    534     if (   (g_HvmR0.cpuid.u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
     534    if (   (g_HmR0.cpuid.u32AMDFeatureECX & X86_CPUID_AMD_FEATURE_ECX_SVM)
    535535        && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_MSR)
    536536        && (u32FeaturesEDX & X86_CPUID_FEATURE_EDX_FXSR)
     
    543543        if (RT_FAILURE(rc))
    544544        {
    545             g_HvmR0.lLastError = rc;
     545            g_HmR0.lLastError = rc;
    546546            return rc;
    547547        }
     
    550550         * Install the AMD-V methods.
    551551         */
    552         g_HvmR0.pfnEnterSession      = SVMR0Enter;
    553         g_HvmR0.pfnThreadCtxCallback = SVMR0ThreadCtxCallback;
    554         g_HvmR0.pfnSaveHostState     = SVMR0SaveHostState;
    555         g_HvmR0.pfnRunGuestCode      = SVMR0RunGuestCode;
    556         g_HvmR0.pfnEnableCpu         = SVMR0EnableCpu;
    557         g_HvmR0.pfnDisableCpu        = SVMR0DisableCpu;
    558         g_HvmR0.pfnInitVM            = SVMR0InitVM;
    559         g_HvmR0.pfnTermVM            = SVMR0TermVM;
    560         g_HvmR0.pfnSetupVM           = SVMR0SetupVM;
     552        g_HmR0.pfnEnterSession      = SVMR0Enter;
     553        g_HmR0.pfnThreadCtxCallback = SVMR0ThreadCtxCallback;
     554        g_HmR0.pfnSaveHostState     = SVMR0SaveHostState;
     555        g_HmR0.pfnRunGuestCode      = SVMR0RunGuestCode;
     556        g_HmR0.pfnEnableCpu         = SVMR0EnableCpu;
     557        g_HmR0.pfnDisableCpu        = SVMR0DisableCpu;
     558        g_HmR0.pfnInitVM            = SVMR0InitVM;
     559        g_HmR0.pfnTermVM            = SVMR0TermVM;
     560        g_HmR0.pfnSetupVM           = SVMR0SetupVM;
    561561
    562562        /* Query AMD features. */
    563563        uint32_t u32Dummy;
    564         ASMCpuId(0x8000000a, &g_HvmR0.svm.u32Rev, &g_HvmR0.uMaxAsid, &u32Dummy, &g_HvmR0.svm.u32Features);
     564        ASMCpuId(0x8000000a, &g_HmR0.svm.u32Rev, &g_HmR0.uMaxAsid, &u32Dummy, &g_HmR0.svm.u32Features);
    565565
    566566        /*
     
    581581        {
    582582            /* Read the HWCR MSR for diagnostics. */
    583             g_HvmR0.svm.u64MsrHwcr = ASMRdMsr(MSR_K8_HWCR);
    584             g_HvmR0.svm.fSupported = true;
     583            g_HmR0.svm.u64MsrHwcr = ASMRdMsr(MSR_K8_HWCR);
     584            g_HmR0.svm.fSupported = true;
    585585        }
    586586        else
    587587        {
    588             g_HvmR0.lLastError = rc;
     588            g_HmR0.lLastError = rc;
    589589            if (rc == VERR_SVM_DISABLED || rc == VERR_SVM_IN_USE)
    590590                rc = VINF_SUCCESS; /* Don't fail if AMD-V is disabled or in use. */
     
    594594    {
    595595        rc = VINF_SUCCESS;              /* Don't fail if AMD-V is not supported. See @bugref{6785}. */
    596         g_HvmR0.lLastError = VERR_SVM_NO_SVM;
     596        g_HmR0.lLastError = VERR_SVM_NO_SVM;
    597597    }
    598598    return rc;
     
    610610     * Initialize the globals.
    611611     */
    612     g_HvmR0.fEnabled = false;
     612    g_HmR0.fEnabled = false;
    613613    static RTONCE s_OnceInit = RTONCE_INITIALIZER;
    614     g_HvmR0.EnableAllCpusOnce = s_OnceInit;
    615     for (unsigned i = 0; i < RT_ELEMENTS(g_HvmR0.aCpuInfo); i++)
    616     {
    617         g_HvmR0.aCpuInfo[i].hMemObj = NIL_RTR0MEMOBJ;
    618         g_HvmR0.aCpuInfo[i].idCpu   = NIL_RTCPUID;
     614    g_HmR0.EnableAllCpusOnce = s_OnceInit;
     615    for (unsigned i = 0; i < RT_ELEMENTS(g_HmR0.aCpuInfo); i++)
     616    {
     617        g_HmR0.aCpuInfo[i].hMemObj = NIL_RTR0MEMOBJ;
     618        g_HmR0.aCpuInfo[i].idCpu   = NIL_RTCPUID;
    619619    }
    620620
    621621    /* Fill in all callbacks with placeholders. */
    622     g_HvmR0.pfnEnterSession      = hmR0DummyEnter;
    623     g_HvmR0.pfnThreadCtxCallback = hmR0DummyThreadCtxCallback;
    624     g_HvmR0.pfnSaveHostState     = hmR0DummySaveHostState;
    625     g_HvmR0.pfnRunGuestCode      = hmR0DummyRunGuestCode;
    626     g_HvmR0.pfnEnableCpu         = hmR0DummyEnableCpu;
    627     g_HvmR0.pfnDisableCpu        = hmR0DummyDisableCpu;
    628     g_HvmR0.pfnInitVM            = hmR0DummyInitVM;
    629     g_HvmR0.pfnTermVM            = hmR0DummyTermVM;
    630     g_HvmR0.pfnSetupVM           = hmR0DummySetupVM;
     622    g_HmR0.pfnEnterSession      = hmR0DummyEnter;
     623    g_HmR0.pfnThreadCtxCallback = hmR0DummyThreadCtxCallback;
     624    g_HmR0.pfnSaveHostState     = hmR0DummySaveHostState;
     625    g_HmR0.pfnRunGuestCode      = hmR0DummyRunGuestCode;
     626    g_HmR0.pfnEnableCpu         = hmR0DummyEnableCpu;
     627    g_HmR0.pfnDisableCpu        = hmR0DummyDisableCpu;
     628    g_HmR0.pfnInitVM            = hmR0DummyInitVM;
     629    g_HmR0.pfnTermVM            = hmR0DummyTermVM;
     630    g_HmR0.pfnSetupVM           = hmR0DummySetupVM;
    631631
    632632    /* Default is global VT-x/AMD-V init. */
    633     g_HvmR0.fGlobalInit         = true;
     633    g_HmR0.fGlobalInit         = true;
    634634
    635635    /*
    636636     * Make sure aCpuInfo is big enough for all the CPUs on this system.
    637637     */
    638     if (RTMpGetArraySize() > RT_ELEMENTS(g_HvmR0.aCpuInfo))
    639     {
    640         LogRel(("HM: Too many real CPUs/cores/threads - %u, max %u\n", RTMpGetArraySize(), RT_ELEMENTS(g_HvmR0.aCpuInfo)));
     638    if (RTMpGetArraySize() > RT_ELEMENTS(g_HmR0.aCpuInfo))
     639    {
     640        LogRel(("HM: Too many real CPUs/cores/threads - %u, max %u\n", RTMpGetArraySize(), RT_ELEMENTS(g_HmR0.aCpuInfo)));
    641641        return VERR_TOO_MANY_CPUS;
    642642    }
     
    660660            if (ASMIsValidExtRange(uMaxExtLeaf))
    661661                ASMCpuId(0x80000001, &u32Dummy, &u32Dummy,
    662                          &g_HvmR0.cpuid.u32AMDFeatureECX,
    663                          &g_HvmR0.cpuid.u32AMDFeatureEDX);
     662                         &g_HmR0.cpuid.u32AMDFeatureECX,
     663                         &g_HmR0.cpuid.u32AMDFeatureEDX);
    664664            else
    665                 g_HvmR0.cpuid.u32AMDFeatureECX = g_HvmR0.cpuid.u32AMDFeatureEDX = 0;
     665                g_HmR0.cpuid.u32AMDFeatureECX = g_HmR0.cpuid.u32AMDFeatureEDX = 0;
    666666
    667667            /* Go to CPU specific initialization code. */
     
    680680            }
    681681            else
    682                 g_HvmR0.lLastError = VERR_HM_UNKNOWN_CPU;
     682                g_HmR0.lLastError = VERR_HM_UNKNOWN_CPU;
    683683        }
    684684        else
    685             g_HvmR0.lLastError = VERR_HM_UNKNOWN_CPU;
     685            g_HmR0.lLastError = VERR_HM_UNKNOWN_CPU;
    686686    }
    687687    else
    688         g_HvmR0.lLastError = VERR_HM_NO_CPUID;
     688        g_HmR0.lLastError = VERR_HM_NO_CPUID;
    689689
    690690    /*
     
    692692     * when brought offline/online or suspending/resuming.
    693693     */
    694     if (!g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     694    if (!g_HmR0.vmx.fUsingSUPR0EnableVTx)
    695695    {
    696696        rc = RTMpNotificationRegister(hmR0MpEventCallback, NULL);
     
    715715{
    716716    int rc;
    717     if (   g_HvmR0.vmx.fSupported
    718         && g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     717    if (   g_HmR0.vmx.fSupported
     718        && g_HmR0.vmx.fUsingSUPR0EnableVTx)
    719719    {
    720720        /*
    721721         * Simple if the host OS manages VT-x.
    722722         */
    723         Assert(g_HvmR0.fGlobalInit);
     723        Assert(g_HmR0.fGlobalInit);
    724724        rc = SUPR0EnableVTx(false /* fEnable */);
    725725
    726         for (unsigned iCpu = 0; iCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo); iCpu++)
     726        for (unsigned iCpu = 0; iCpu < RT_ELEMENTS(g_HmR0.aCpuInfo); iCpu++)
    727727        {
    728             g_HvmR0.aCpuInfo[iCpu].fConfigured = false;
    729             Assert(g_HvmR0.aCpuInfo[iCpu].hMemObj == NIL_RTR0MEMOBJ);
     728            g_HmR0.aCpuInfo[iCpu].fConfigured = false;
     729            Assert(g_HmR0.aCpuInfo[iCpu].hMemObj == NIL_RTR0MEMOBJ);
    730730        }
    731731    }
    732732    else
    733733    {
    734         Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     734        Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    735735
    736736        /* Doesn't really matter if this fails. */
     
    741741         * Disable VT-x/AMD-V on all CPUs if we enabled it before.
    742742         */
    743         if (g_HvmR0.fGlobalInit)
     743        if (g_HmR0.fGlobalInit)
    744744        {
    745745            HMR0FIRSTRC FirstRc;
     
    754754         * Free the per-cpu pages used for VT-x and AMD-V.
    755755         */
    756         for (unsigned i = 0; i < RT_ELEMENTS(g_HvmR0.aCpuInfo); i++)
     756        for (unsigned i = 0; i < RT_ELEMENTS(g_HmR0.aCpuInfo); i++)
    757757        {
    758             if (g_HvmR0.aCpuInfo[i].hMemObj != NIL_RTR0MEMOBJ)
     758            if (g_HmR0.aCpuInfo[i].hMemObj != NIL_RTR0MEMOBJ)
    759759            {
    760                 RTR0MemObjFree(g_HvmR0.aCpuInfo[i].hMemObj, false);
    761                 g_HvmR0.aCpuInfo[i].hMemObj = NIL_RTR0MEMOBJ;
     760                RTR0MemObjFree(g_HmR0.aCpuInfo[i].hMemObj, false);
     761                g_HmR0.aCpuInfo[i].hMemObj = NIL_RTR0MEMOBJ;
    762762            }
    763763        }
     
    768768     *        should move into their respective modules. */
    769769    /* Finally, call global VT-x/AMD-V termination. */
    770     if (g_HvmR0.vmx.fSupported)
     770    if (g_HmR0.vmx.fSupported)
    771771        VMXR0GlobalTerm();
    772     else if (g_HvmR0.svm.fSupported)
     772    else if (g_HmR0.svm.fSupported)
    773773        SVMR0GlobalTerm();
    774774
     
    828828static int hmR0EnableCpu(PVM pVM, RTCPUID idCpu)
    829829{
    830     PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[idCpu];
     830    PHMGLOBALCPUINFO pCpu = &g_HmR0.aCpuInfo[idCpu];
    831831
    832832    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    833     Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
     833    Assert(idCpu < RT_ELEMENTS(g_HmR0.aCpuInfo));
    834834    Assert(!pCpu->fConfigured);
    835835    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
     
    839839
    840840    int rc;
    841     if (g_HvmR0.vmx.fSupported && g_HvmR0.vmx.fUsingSUPR0EnableVTx)
    842         rc = g_HvmR0.pfnEnableCpu(pCpu, pVM, NULL /* pvCpuPage */, NIL_RTHCPHYS, true, &g_HvmR0.vmx.Msrs);
     841    if (g_HmR0.vmx.fSupported && g_HmR0.vmx.fUsingSUPR0EnableVTx)
     842        rc = g_HmR0.pfnEnableCpu(pCpu, pVM, NULL /* pvCpuPage */, NIL_RTHCPHYS, true, &g_HmR0.vmx.Msrs);
    843843    else
    844844    {
     
    847847        RTHCPHYS HCPhysCpuPage = RTR0MemObjGetPagePhysAddr(pCpu->hMemObj, 0 /* iPage */);
    848848
    849         if (g_HvmR0.vmx.fSupported)
    850             rc = g_HvmR0.pfnEnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, &g_HvmR0.vmx.Msrs);
     849        if (g_HmR0.vmx.fSupported)
     850            rc = g_HmR0.pfnEnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, &g_HmR0.vmx.Msrs);
    851851        else
    852             rc = g_HvmR0.pfnEnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, NULL /* pvArg */);
     852            rc = g_HmR0.pfnEnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, NULL /* pvArg */);
    853853    }
    854854    if (RT_SUCCESS(rc))
     
    870870    PVM             pVM      = (PVM)pvUser1;     /* can be NULL! */
    871871    PHMR0FIRSTRC    pFirstRc = (PHMR0FIRSTRC)pvUser2;
    872     AssertReturnVoid(g_HvmR0.fGlobalInit);
     872    AssertReturnVoid(g_HmR0.fGlobalInit);
    873873    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    874874    hmR0FirstRcSetStatus(pFirstRc, hmR0EnableCpu(pVM, idCpu));
     
    893893     *       notification.  Kind of unlikely though, so ignored for now.
    894894     */
    895     AssertReturn(!g_HvmR0.fEnabled, VERR_HM_ALREADY_ENABLED_IPE);
    896     ASMAtomicWriteBool(&g_HvmR0.fEnabled, true);
     895    AssertReturn(!g_HmR0.fEnabled, VERR_HM_ALREADY_ENABLED_IPE);
     896    ASMAtomicWriteBool(&g_HmR0.fEnabled, true);
    897897
    898898    /*
    899899     * The global init variable is set by the first VM.
    900900     */
    901     g_HvmR0.fGlobalInit = pVM->hm.s.fGlobalInit;
     901    g_HmR0.fGlobalInit = pVM->hm.s.fGlobalInit;
    902902
    903903#ifdef VBOX_STRICT
    904     for (unsigned i = 0; i < RT_ELEMENTS(g_HvmR0.aCpuInfo); i++)
    905     {
    906         Assert(g_HvmR0.aCpuInfo[i].hMemObj == NIL_RTR0MEMOBJ);
    907         Assert(!g_HvmR0.aCpuInfo[i].fConfigured);
    908         Assert(!g_HvmR0.aCpuInfo[i].cTlbFlushes);
    909         Assert(!g_HvmR0.aCpuInfo[i].uCurrentAsid);
     904    for (unsigned i = 0; i < RT_ELEMENTS(g_HmR0.aCpuInfo); i++)
     905    {
     906        Assert(g_HmR0.aCpuInfo[i].hMemObj == NIL_RTR0MEMOBJ);
     907        Assert(!g_HmR0.aCpuInfo[i].fConfigured);
     908        Assert(!g_HmR0.aCpuInfo[i].cTlbFlushes);
     909        Assert(!g_HmR0.aCpuInfo[i].uCurrentAsid);
    910910    }
    911911#endif
    912912
    913913    int rc;
    914     if (   g_HvmR0.vmx.fSupported
    915         && g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     914    if (   g_HmR0.vmx.fSupported
     915        && g_HmR0.vmx.fUsingSUPR0EnableVTx)
    916916    {
    917917        /*
     
    922922        {
    923923            /* If the host provides a VT-x init API, then we'll rely on that for global init. */
    924             g_HvmR0.fGlobalInit = pVM->hm.s.fGlobalInit = true;
     924            g_HmR0.fGlobalInit = pVM->hm.s.fGlobalInit = true;
    925925        }
    926926        else
     
    933933         */
    934934        /* Allocate one page per cpu for the global VT-x and AMD-V pages */
    935         for (unsigned i = 0; i < RT_ELEMENTS(g_HvmR0.aCpuInfo); i++)
     935        for (unsigned i = 0; i < RT_ELEMENTS(g_HmR0.aCpuInfo); i++)
    936936        {
    937             Assert(g_HvmR0.aCpuInfo[i].hMemObj == NIL_RTR0MEMOBJ);
     937            Assert(g_HmR0.aCpuInfo[i].hMemObj == NIL_RTR0MEMOBJ);
    938938
    939939            if (RTMpIsCpuPossible(RTMpCpuIdFromSetIndex(i)))
    940940            {
    941                 rc = RTR0MemObjAllocCont(&g_HvmR0.aCpuInfo[i].hMemObj, PAGE_SIZE, false /* executable R0 mapping */);
     941                rc = RTR0MemObjAllocCont(&g_HmR0.aCpuInfo[i].hMemObj, PAGE_SIZE, false /* executable R0 mapping */);
    942942                AssertLogRelRCReturn(rc, rc);
    943943
    944                 void *pvR0 = RTR0MemObjAddress(g_HvmR0.aCpuInfo[i].hMemObj); Assert(pvR0);
     944                void *pvR0 = RTR0MemObjAddress(g_HmR0.aCpuInfo[i].hMemObj); Assert(pvR0);
    945945                ASMMemZeroPage(pvR0);
    946946            }
     
    951951
    952952    if (   RT_SUCCESS(rc)
    953         && g_HvmR0.fGlobalInit)
     953        && g_HmR0.fGlobalInit)
    954954    {
    955955        /* First time, so initialize each cpu/core. */
     
    974974{
    975975    /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */
    976     if (ASMAtomicReadBool(&g_HvmR0.fSuspended))
     976    if (ASMAtomicReadBool(&g_HmR0.fSuspended))
    977977        return VERR_HM_SUSPEND_PENDING;
    978978
    979     return RTOnce(&g_HvmR0.EnableAllCpusOnce, hmR0EnableAllCpuOnce, pVM);
     979    return RTOnce(&g_HmR0.EnableAllCpusOnce, hmR0EnableAllCpuOnce, pVM);
    980980}
    981981
     
    991991static int hmR0DisableCpu(RTCPUID idCpu)
    992992{
    993     PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[idCpu];
    994 
    995     Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     993    PHMGLOBALCPUINFO pCpu = &g_HmR0.aCpuInfo[idCpu];
     994
     995    Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    996996    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    997997    Assert(idCpu == (RTCPUID)RTMpCpuIdToSetIndex(idCpu)); /** @todo fix idCpu == index assumption (rainy day) */
    998     Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
     998    Assert(idCpu < RT_ELEMENTS(g_HmR0.aCpuInfo));
    999999    Assert(!pCpu->fConfigured || pCpu->hMemObj != NIL_RTR0MEMOBJ);
    10001000    AssertRelease(idCpu == RTMpCpuId());
     
    10091009        RTHCPHYS HCPhysCpuPage = RTR0MemObjGetPagePhysAddr(pCpu->hMemObj, 0);
    10101010
    1011         rc = g_HvmR0.pfnDisableCpu(pCpu, pvCpuPage, HCPhysCpuPage);
     1011        rc = g_HmR0.pfnDisableCpu(pCpu, pvCpuPage, HCPhysCpuPage);
    10121012        AssertRCReturn(rc, rc);
    10131013
     
    10321032{
    10331033    PHMR0FIRSTRC pFirstRc = (PHMR0FIRSTRC)pvUser2; NOREF(pvUser1);
    1034     AssertReturnVoid(g_HvmR0.fGlobalInit);
     1034    AssertReturnVoid(g_HmR0.fGlobalInit);
    10351035    hmR0FirstRcSetStatus(pFirstRc, hmR0DisableCpu(idCpu));
    10361036}
     
    10631063{
    10641064    NOREF(pvData);
    1065     Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     1065    Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    10661066
    10671067    /*
     
    11041104{
    11051105    NOREF(pvUser);
    1106     Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     1106    Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    11071107
    11081108#ifdef LOG_ENABLED
     
    11141114
    11151115    if (enmEvent == RTPOWEREVENT_SUSPEND)
    1116         ASMAtomicWriteBool(&g_HvmR0.fSuspended, true);
    1117 
    1118     if (g_HvmR0.fEnabled)
     1116        ASMAtomicWriteBool(&g_HmR0.fSuspended, true);
     1117
     1118    if (g_HmR0.fEnabled)
    11191119    {
    11201120        int         rc;
     
    11241124        if (enmEvent == RTPOWEREVENT_SUSPEND)
    11251125        {
    1126             if (g_HvmR0.fGlobalInit)
     1126            if (g_HmR0.fGlobalInit)
    11271127            {
    11281128                /* Turn off VT-x or AMD-V on all CPUs. */
     
    11361136            /* Reinit the CPUs from scratch as the suspend state might have
    11371137               messed with the MSRs. (lousy BIOSes as usual) */
    1138             if (g_HvmR0.vmx.fSupported)
     1138            if (g_HmR0.vmx.fSupported)
    11391139                rc = RTMpOnAll(hmR0InitIntelCpu, &FirstRc, NULL);
    11401140            else
     
    11471147                SUPR0Printf("hmR0PowerCallback hmR0InitXxxCpu failed with %Rc\n", rc);
    11481148#endif
    1149             if (g_HvmR0.fGlobalInit)
     1149            if (g_HmR0.fGlobalInit)
    11501150            {
    11511151                /* Turn VT-x or AMD-V back on on all CPUs. */
     
    11581158
    11591159    if (enmEvent == RTPOWEREVENT_RESUME)
    1160         ASMAtomicWriteBool(&g_HvmR0.fSuspended, false);
     1160        ASMAtomicWriteBool(&g_HmR0.fSuspended, false);
    11611161}
    11621162
     
    11831183
    11841184    /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */
    1185     if (ASMAtomicReadBool(&g_HvmR0.fSuspended))
     1185    if (ASMAtomicReadBool(&g_HmR0.fSuspended))
    11861186        return VERR_HM_SUSPEND_PENDING;
    11871187
     
    11891189     * Copy globals to the VM structure.
    11901190     */
    1191     pVM->hm.s.vmx.fSupported            = g_HvmR0.vmx.fSupported;
    1192     pVM->hm.s.svm.fSupported            = g_HvmR0.svm.fSupported;
    1193 
    1194     pVM->hm.s.vmx.fUsePreemptTimer     &= g_HvmR0.vmx.fUsePreemptTimer;     /* Can be overridden by CFGM. See HMR3Init(). */
    1195     pVM->hm.s.vmx.cPreemptTimerShift    = g_HvmR0.vmx.cPreemptTimerShift;
    1196     pVM->hm.s.vmx.u64HostCr4            = g_HvmR0.vmx.u64HostCr4;
    1197     pVM->hm.s.vmx.u64HostEfer           = g_HvmR0.vmx.u64HostEfer;
    1198     pVM->hm.s.vmx.Msrs                  = g_HvmR0.vmx.Msrs;
    1199     pVM->hm.s.svm.u64MsrHwcr            = g_HvmR0.svm.u64MsrHwcr;
    1200     pVM->hm.s.svm.u32Rev                = g_HvmR0.svm.u32Rev;
    1201     pVM->hm.s.svm.u32Features           = g_HvmR0.svm.u32Features;
    1202     pVM->hm.s.cpuid.u32AMDFeatureECX    = g_HvmR0.cpuid.u32AMDFeatureECX;
    1203     pVM->hm.s.cpuid.u32AMDFeatureEDX    = g_HvmR0.cpuid.u32AMDFeatureEDX;
    1204     pVM->hm.s.lLastError                = g_HvmR0.lLastError;
    1205     pVM->hm.s.uMaxAsid                  = g_HvmR0.uMaxAsid;
     1191    pVM->hm.s.vmx.fSupported            = g_HmR0.vmx.fSupported;
     1192    pVM->hm.s.svm.fSupported            = g_HmR0.svm.fSupported;
     1193
     1194    pVM->hm.s.vmx.fUsePreemptTimer     &= g_HmR0.vmx.fUsePreemptTimer;     /* Can be overridden by CFGM. See HMR3Init(). */
     1195    pVM->hm.s.vmx.cPreemptTimerShift    = g_HmR0.vmx.cPreemptTimerShift;
     1196    pVM->hm.s.vmx.u64HostCr4            = g_HmR0.vmx.u64HostCr4;
     1197    pVM->hm.s.vmx.u64HostEfer           = g_HmR0.vmx.u64HostEfer;
     1198    pVM->hm.s.vmx.Msrs                  = g_HmR0.vmx.Msrs;
     1199    pVM->hm.s.svm.u64MsrHwcr            = g_HmR0.svm.u64MsrHwcr;
     1200    pVM->hm.s.svm.u32Rev                = g_HmR0.svm.u32Rev;
     1201    pVM->hm.s.svm.u32Features           = g_HmR0.svm.u32Features;
     1202    pVM->hm.s.cpuid.u32AMDFeatureECX    = g_HmR0.cpuid.u32AMDFeatureECX;
     1203    pVM->hm.s.cpuid.u32AMDFeatureEDX    = g_HmR0.cpuid.u32AMDFeatureEDX;
     1204    pVM->hm.s.lLastError                = g_HmR0.lLastError;
     1205    pVM->hm.s.uMaxAsid                  = g_HmR0.uMaxAsid;
    12061206
    12071207    if (!pVM->hm.s.cMaxResumeLoops) /* allow ring-3 overrides */
     
    12311231     * Call the hardware specific initialization method.
    12321232     */
    1233     return g_HvmR0.pfnInitVM(pVM);
     1233    return g_HmR0.pfnInitVM(pVM);
    12341234}
    12351235
     
    12521252     * mess with VT-x/AMD-V features on the CPU, currently all they do is free memory so this is safe.
    12531253     */
    1254     return g_HvmR0.pfnTermVM(pVM);
     1254    return g_HmR0.pfnTermVM(pVM);
    12551255}
    12561256
     
    12701270
    12711271    /* Make sure we don't touch HM after we've disabled HM in preparation of a suspend. */
    1272     AssertReturn(!ASMAtomicReadBool(&g_HvmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
     1272    AssertReturn(!ASMAtomicReadBool(&g_HmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
    12731273
    12741274    /* On first entry we'll sync everything. */
     
    12861286    /* Enable VT-x or AMD-V if local init is required. */
    12871287    int rc;
    1288     if (!g_HvmR0.fGlobalInit)
    1289     {
    1290         Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     1288    if (!g_HmR0.fGlobalInit)
     1289    {
     1290        Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    12911291        rc = hmR0EnableCpu(pVM, idCpu);
    12921292        if (RT_FAILURE(rc))
     
    12981298
    12991299    /* Setup VT-x or AMD-V. */
    1300     rc = g_HvmR0.pfnSetupVM(pVM);
     1300    rc = g_HmR0.pfnSetupVM(pVM);
    13011301
    13021302    /* Disable VT-x or AMD-V if local init was done before. */
    1303     if (!g_HvmR0.fGlobalInit)
    1304     {
    1305         Assert(!g_HvmR0.vmx.fSupported || !g_HvmR0.vmx.fUsingSUPR0EnableVTx);
     1303    if (!g_HmR0.fGlobalInit)
     1304    {
     1305        Assert(!g_HmR0.vmx.fSupported || !g_HmR0.vmx.fUsingSUPR0EnableVTx);
    13061306        int rc2 = hmR0DisableCpu(idCpu);
    13071307        AssertRC(rc2);
     
    13281328    int              rc    = VINF_SUCCESS;
    13291329    RTCPUID          idCpu = RTMpCpuId();
    1330     PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[idCpu];
     1330    PHMGLOBALCPUINFO pCpu = &g_HmR0.aCpuInfo[idCpu];
    13311331    AssertPtr(pCpu);
    13321332
     
    13561356{
    13571357    /* Make sure we can't enter a session after we've disabled HM in preparation of a suspend. */
    1358     AssertReturn(!ASMAtomicReadBool(&g_HvmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
     1358    AssertReturn(!ASMAtomicReadBool(&g_HmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
    13591359    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    13601360
     
    13691369
    13701370    RTCPUID          idCpu = RTMpCpuId();
    1371     PHMGLOBALCPUINFO pCpu  = &g_HvmR0.aCpuInfo[idCpu];
     1371    PHMGLOBALCPUINFO pCpu  = &g_HmR0.aCpuInfo[idCpu];
    13721372    Assert(pCpu);
    13731373    Assert(HMCPU_CF_IS_SET(pVCpu, HM_CHANGED_HOST_CONTEXT | HM_CHANGED_HOST_GUEST_SHARED_STATE));
    13741374
    1375     rc = g_HvmR0.pfnEnterSession(pVM, pVCpu, pCpu);
     1375    rc = g_HmR0.pfnEnterSession(pVM, pVCpu, pCpu);
    13761376    AssertMsgRCReturn(rc, ("pfnEnterSession failed. rc=%Rrc pVCpu=%p HostCpuId=%u\n", rc, pVCpu, idCpu), rc);
    13771377
    13781378    /* Load the host-state as we may be resuming code after a longjmp and quite
    13791379       possibly now be scheduled on a different CPU. */
    1380     rc = g_HvmR0.pfnSaveHostState(pVM, pVCpu);
     1380    rc = g_HmR0.pfnSaveHostState(pVM, pVCpu);
    13811381    AssertMsgRCReturn(rc, ("pfnSaveHostState failed. rc=%Rrc pVCpu=%p HostCpuId=%u\n", rc, pVCpu, idCpu), rc);
    13821382
     
    14081408
    14091409    RTCPUID          idCpu = RTMpCpuId();
    1410     PHMGLOBALCPUINFO pCpu  = &g_HvmR0.aCpuInfo[idCpu];
    1411 
    1412     if (   !g_HvmR0.fGlobalInit
     1410    PHMGLOBALCPUINFO pCpu  = &g_HmR0.aCpuInfo[idCpu];
     1411
     1412    if (   !g_HmR0.fGlobalInit
    14131413        && pCpu->fConfigured)
    14141414    {
     
    14391439    PVMCPU pVCpu = (PVMCPU)pvUser;
    14401440    Assert(pVCpu);
    1441     Assert(g_HvmR0.pfnThreadCtxCallback);
    1442 
    1443     g_HvmR0.pfnThreadCtxCallback(enmEvent, pVCpu, g_HvmR0.fGlobalInit);
     1441    Assert(g_HmR0.pfnThreadCtxCallback);
     1442
     1443    g_HmR0.pfnThreadCtxCallback(enmEvent, pVCpu, g_HmR0.fGlobalInit);
    14441444}
    14451445
     
    14611461    if (!RTThreadPreemptIsEnabled(NIL_RTTHREAD))
    14621462    {
    1463         PHMGLOBALCPUINFO pCpu = &g_HvmR0.aCpuInfo[RTMpCpuId()];
     1463        PHMGLOBALCPUINFO pCpu = &g_HmR0.aCpuInfo[RTMpCpuId()];
    14641464        Assert(!VMCPU_FF_IS_PENDING(pVCpu, VMCPU_FF_PGM_SYNC_CR3 | VMCPU_FF_PGM_SYNC_CR3_NON_GLOBAL));
    14651465        Assert(pCpu->fConfigured);
    1466         AssertReturn(!ASMAtomicReadBool(&g_HvmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
     1466        AssertReturn(!ASMAtomicReadBool(&g_HmR0.fSuspended), VERR_HM_SUSPEND_PENDING);
    14671467    }
    14681468#endif
     
    14741474#endif
    14751475
    1476     int rc = g_HvmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu));
     1476    int rc = g_HmR0.pfnRunGuestCode(pVM, pVCpu, CPUMQueryGuestCtxPtr(pVCpu));
    14771477
    14781478#ifdef VBOX_WITH_2X_4GB_ADDR_SPACE
     
    15501550VMMR0_INT_DECL(bool) HMR0SuspendPending(void)
    15511551{
    1552     return ASMAtomicReadBool(&g_HvmR0.fSuspended);
     1552    return ASMAtomicReadBool(&g_HmR0.fSuspended);
    15531553}
    15541554
     
    15641564    Assert(!RTThreadPreemptIsEnabled(NIL_RTTHREAD));
    15651565    RTCPUID idCpu = RTMpCpuId();
    1566     Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
    1567     return &g_HvmR0.aCpuInfo[idCpu];
     1566    Assert(idCpu < RT_ELEMENTS(g_HmR0.aCpuInfo));
     1567    return &g_HmR0.aCpuInfo[idCpu];
    15681568}
    15691569
     
    15781578VMMR0DECL(PHMGLOBALCPUINFO) HMR0GetCurrentCpuEx(RTCPUID idCpu)
    15791579{
    1580     Assert(idCpu < RT_ELEMENTS(g_HvmR0.aCpuInfo));
    1581     return &g_HvmR0.aCpuInfo[idCpu];
     1580    Assert(idCpu < RT_ELEMENTS(g_HmR0.aCpuInfo));
     1581    return &g_HmR0.aCpuInfo[idCpu];
    15821582}
    15831583
     
    16461646
    16471647    /* No such issues with AMD-V */
    1648     if (!g_HvmR0.vmx.fSupported)
     1648    if (!g_HmR0.vmx.fSupported)
    16491649        return VINF_SUCCESS;
    16501650
     
    16681668    /* When using SUPR0EnableVTx we must let the host suspend and resume VT-x,
    16691669       regardless of whether we're currently using VT-x or not. */
    1670     if (g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     1670    if (g_HmR0.vmx.fUsingSUPR0EnableVTx)
    16711671    {
    16721672        *pfVTxDisabled = SUPR0SuspendVTxOnCpu();
     
    16781678
    16791679    /* Nothing to do if we haven't enabled VT-x. */
    1680     if (!g_HvmR0.fEnabled)
     1680    if (!g_HmR0.fEnabled)
    16811681        return VINF_SUCCESS;
    16821682
    16831683    /* Local init implies the CPU is currently not in VMX root mode. */
    1684     if (!g_HvmR0.fGlobalInit)
     1684    if (!g_HmR0.fGlobalInit)
    16851685        return VINF_SUCCESS;
    16861686
     
    17101710        return;         /* nothing to do */
    17111711
    1712     Assert(g_HvmR0.vmx.fSupported);
    1713     if (g_HvmR0.vmx.fUsingSUPR0EnableVTx)
     1712    Assert(g_HmR0.vmx.fSupported);
     1713    if (g_HmR0.vmx.fUsingSUPR0EnableVTx)
    17141714        SUPR0ResumeVTxOnCpu(fVTxDisabled);
    17151715    else
    17161716    {
    1717         Assert(g_HvmR0.fEnabled);
    1718         Assert(g_HvmR0.fGlobalInit);
     1717        Assert(g_HmR0.fEnabled);
     1718        Assert(g_HmR0.fGlobalInit);
    17191719
    17201720        PHMGLOBALCPUINFO pCpu = HMR0GetCurrentCpu();
     
    17231723        void           *pvCpuPage     = RTR0MemObjAddress(pCpu->hMemObj);
    17241724        RTHCPHYS        HCPhysCpuPage = RTR0MemObjGetPagePhysAddr(pCpu->hMemObj, 0);
    1725         VMXR0EnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, &g_HvmR0.vmx.Msrs);
     1725        VMXR0EnableCpu(pCpu, pVM, pvCpuPage, HCPhysCpuPage, false, &g_HmR0.vmx.Msrs);
    17261726    }
    17271727}
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