VirtualBox

Changeset 70918 in vbox for trunk/src/VBox/VMM/VMMR3


Ignore:
Timestamp:
Feb 8, 2018 4:11:47 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
120746
Message:

VMM: NEM kick off.

Location:
trunk/src/VBox/VMM/VMMR3
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r70606 r70918  
    5151#include <VBox/vmm/csam.h>
    5252#include <VBox/vmm/selm.h>
     53#include <VBox/vmm/nem.h>
    5354#ifdef VBOX_WITH_REM
    5455# include <VBox/vmm/rem.h>
     
    394395 * Initializes the HM.
    395396 *
    396  * This reads the config and check whether VT-x or AMD-V hardware is available
    397  * if configured to use it.  This is one of the very first components to be
    398  * initialized after CFGM, so that we can fall back to raw-mode early in the
    399  * initialization process.
     397 * This is the very first component to really do init after CFGM so that we can
     398 * establish the predominat execution engine for the VM prior to initializing
     399 * other modules.  It takes care of NEM initialization if needed (HM disabled or
     400 * not available in HW).
     401 *
     402 * If VT-x or AMD-V hardware isn't available, HM will try fall back on a native
     403 * hypervisor API via NEM, and then back on raw-mode if that isn't available
     404 * either.  The fallback to raw-mode will not happen if /HM/HMForced is set
     405 * (like for guest using SMP or 64-bit as well as for complicated guest like OS
     406 * X, OS/2 and others).
    400407 *
    401408 * Note that a lot of the set up work is done in ring-0 and thus postponed till
     
    449456    rc = CFGMR3ValidateConfig(pCfgHm, "/HM/",
    450457                              "HMForced"
     458                              "|UseNEMInstead"
     459                              "|FallbackToNEM"
    451460                              "|EnableNestedPaging"
    452461                              "|EnableUX"
     
    492501#endif /* !VBOX_WITH_RAW_MODE */
    493502
     503    /** @cfgm{/HM/UseNEMInstead, bool, true}
     504     * Don't use HM, use NEM instead. */
     505    bool fUseNEMInstead = false;
     506    rc = CFGMR3QueryBoolDef(pCfgHm, "UseNEMInstead", &fUseNEMInstead, false);
     507    AssertRCReturn(rc, rc);
     508    if (fUseNEMInstead && pVM->fHMEnabled)
     509    {
     510        LogRel(("HM: Setting fHMEnabled to false because fUseNEMInstead is set.\n"));
     511        pVM->fHMEnabled = false;
     512    }
     513
     514    /** @cfgm{/HM/FallbackToNEM, bool, true}
     515     * Enables fallback on NEM. */
     516    bool fFallbackToNEM = true;
     517    rc = CFGMR3QueryBoolDef(pCfgHm, "FallbackToNEM", &fFallbackToNEM, true);
     518    AssertRCReturn(rc, rc);
     519
    494520    /** @cfgm{/HM/EnableNestedPaging, bool, false}
    495521     * Enables nested paging (aka extended page tables). */
     
    643669            else if (fCaps & SUPVTCAPS_VT_X)
    644670            {
    645                 rc = SUPR3QueryVTxSupported();
     671                const char *pszWhy;
     672                rc = SUPR3QueryVTxSupported(&pszWhy);
    646673                if (RT_SUCCESS(rc))
    647674                {
     
    654681                else
    655682                {
    656 #ifdef RT_OS_LINUX
    657                     const char *pszMinReq = " Linux 2.6.13 or newer required!";
    658 #else
    659                     const char *pszMinReq = "";
    660 #endif
    661                     if (fHMForced)
    662                         return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x.%s\n", pszMinReq);
    663 
    664                     /* Fall back to raw-mode. */
    665                     LogRel(("HM: HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x.%s\n", pszMinReq));
     683                    /*
     684                     * Before failing, try fallback to NEM if we're allowed to do that.
     685                     */
    666686                    pVM->fHMEnabled = false;
     687                    if (fFallbackToNEM)
     688                    {
     689                        LogRel(("HM: HMR3Init: Attempting fall back to NEM: The host kernel does not support VT-x - %s\n", pszWhy));
     690                        int rc2 = NEMR3Init(pVM, true /*fFallback*/, fHMForced);
     691                        if (   RT_SUCCESS(rc2)
     692                            && pVM->fNEMActive)
     693                            rc = VINF_SUCCESS;
     694                    }
     695                    if (RT_FAILURE(rc))
     696                    {
     697                        if (fHMForced)
     698                            return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x: %s\n", pszWhy);
     699
     700                        /* Fall back to raw-mode. */
     701                        LogRel(("HM: HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x - %s\n", pszWhy));
     702                    }
    667703                }
    668704            }
     
    738774
    739775                default:
    740                     pszMsg = NULL;
    741                     break;
     776                    return VMSetError(pVM, rc, RT_SRC_POS, "SUPR3QueryVTCaps failed with %Rrc", rc);
    742777            }
    743             if (fHMForced && pszMsg)
    744                 return VM_SET_ERROR(pVM, rc, pszMsg);
    745             if (!pszMsg)
    746                 return VMSetError(pVM, rc, RT_SRC_POS, "SUPR3QueryVTCaps failed with %Rrc", rc);
    747 
    748             /* Fall back to raw-mode. */
    749             LogRel(("HM: HMR3Init: Falling back to raw-mode: %s\n", pszMsg));
     778
     779            /*
     780             * Before failing, try fallback to NEM if we're allowed to do that.
     781             */
    750782            pVM->fHMEnabled = false;
     783            if (fFallbackToNEM)
     784            {
     785                LogRel(("HM: HMR3Init: Attempting fall back to NEM: %s\n", pszMsg));
     786                int rc2 = NEMR3Init(pVM, true /*fFallback*/, fHMForced);
     787                if (   RT_SUCCESS(rc2)
     788                    && pVM->fNEMActive)
     789                    rc = VINF_SUCCESS;
     790            }
     791            if (RT_FAILURE(rc))
     792            {
     793                if (fHMForced)
     794                    return VM_SET_ERROR(pVM, rc, pszMsg);
     795
     796                LogRel(("HM: HMR3Init: Falling back to raw-mode: %s\n", pszMsg));
     797            }
    751798        }
     799    }
     800    /*
     801     * If NEM is supposed to be used instead, initialize it instead.
     802     */
     803    else if (fUseNEMInstead)
     804    {
     805        rc = NEMR3Init(pVM, false /*fFallback*/, fHMForced);
     806        if (RT_FAILURE(rc))
     807            return rc;
    752808    }
    753809
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r69111 r70918  
    6161# include <VBox/vmm/rem.h>
    6262#endif
     63#include <VBox/vmm/nem.h>
    6364#include <VBox/vmm/apic.h>
    6465#include <VBox/vmm/tm.h>
     
    925926    /*
    926927     * Init all R3 components, the order here might be important.
    927      * HM shall be initialized first!
    928      */
    929     rc = HMR3Init(pVM);
     928     * NEM and HM shall be initialized first!
     929     */
     930    rc = NEMR3InitConfig(pVM);
     931    if (RT_SUCCESS(rc))
     932        rc = HMR3Init(pVM);
    930933    if (RT_SUCCESS(rc))
    931934    {
     
    10761079        AssertRC(rc2);
    10771080    }
    1078 
     1081    NEMR3Term(pVM);
    10791082
    10801083    LogFlow(("vmR3InitRing3: returns %Rrc\n", rc));
     
    11681171    if (RT_SUCCESS(rc))
    11691172        rc = HMR3InitCompleted(pVM, enmWhat);
     1173    if (RT_SUCCESS(rc))
     1174        rc = NEMR3InitCompleted(pVM, enmWhat);
    11701175    if (RT_SUCCESS(rc))
    11711176        rc = PGMR3InitCompleted(pVM, enmWhat);
     
    25162521        rc = HMR3Term(pVM);
    25172522        AssertRC(rc);
     2523        rc = NEMR3Term(pVM);
     2524        AssertRC(rc);
    25182525        rc = PGMR3Term(pVM);
    25192526        AssertRC(rc);
     
    28042811        EMR3Reset(pVM);
    28052812        HMR3Reset(pVM);                 /* This must come *after* PATM, CSAM, CPUM, SELM and TRPM. */
     2813        NEMR3Reset(pVM);
    28062814
    28072815        /*
     
    29072915        EMR3Reset(pVM);
    29082916        HMR3Reset(pVM);                 /* This must come *after* PATM, CSAM, CPUM, SELM and TRPM. */
     2917        NEMR3Reset(pVM);
    29092918
    29102919        /*
     
    46324641    EMR3ResetCpu(pVCpu);
    46334642    HMR3ResetCpu(pVCpu);
     4643    NEMR3ResetCpu(pVCpu);
    46344644    return VINF_EM_WAIT_SIPI;
    46354645}
  • trunk/src/VBox/VMM/VMMR3/VMM.cpp

    r70917 r70918  
    112112#include <VBox/vmm/gim.h>
    113113#include <VBox/vmm/mm.h>
     114#include <VBox/vmm/nem.h>
    114115#include <VBox/vmm/iom.h>
    115116#include <VBox/vmm/trpm.h>
     
    14941495    EMR3ResetCpu(pVCpu);
    14951496    HMR3ResetCpu(pVCpu);
     1497    NEMR3ResetCpu(pVCpu);
    14961498
    14971499    /* This will trickle up on the target EMT. */
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