VirtualBox

Changeset 72343 in vbox for trunk/src


Ignore:
Timestamp:
May 25, 2018 1:24:28 PM (7 years ago)
Author:
vboxsync
Message:

VMM,ConsoleImpl2: NEM and 64-bit guests. Sync NXE state with PGM. bugref:9044

Location:
trunk/src/VBox
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r71146 r72343  
    11151115        InsertConfigInteger(pRoot, "HMEnabled", fHMEnabled);
    11161116
    1117         /* /HM/xzy */
     1117        /* /HM/xyz */
    11181118        PCFGMNODE pHM;
    11191119        InsertConfigNode(pRoot, "HM", &pHM);
     
    11851185        if (i_isResetTurnedIntoPowerOff())
    11861186            InsertConfigInteger(pRoot, "PowerOffInsteadOfReset", 1);
     1187
     1188        /* Use NEM rather than HM. */
     1189        BOOL fUseNativeApi = false;
     1190        hrc = pMachine->GetHWVirtExProperty(HWVirtExPropertyType_UseNativeApi, &fUseNativeApi); H();
     1191        InsertConfigInteger(pHM, "UseNEMInstead", fUseNativeApi);
     1192
     1193        /*
     1194         * NEM
     1195         */
     1196        PCFGMNODE pNEM;
     1197        InsertConfigNode(pRoot, "NEM", &pNEM);
     1198        InsertConfigInteger(pNEM, "Allow64BitGuests", fIsGuest64Bit);
    11871199
    11881200        /*
  • trunk/src/VBox/VMM/VMMAll/HMAll.cpp

    r71910 r72343  
    358358
    359359/**
    360  * Checks if this VM is long-mode capable.
     360 * Checks if this VM is using HM and is long-mode capable.
     361 *
     362 * Use VMR3IsLongModeAllowed() instead of this, when possible.
    361363 *
    362364 * @returns true if long mode is allowed, false otherwise.
    363365 * @param   pVM         The cross context VM structure.
    364  */
    365 /** @todo NEM: Check users of HMIsLongModeAllowed */
     366 * @sa      VMR3IsLongModeAllowed, NEMHCIsLongModeAllowed
     367 */
    366368VMM_INT_DECL(bool) HMIsLongModeAllowed(PVM pVM)
    367369{
  • trunk/src/VBox/VMM/VMMAll/NEMAll.cpp

    r72272 r72343  
    2525#include <VBox/vmm/vm.h>
    2626
     27
     28/**
     29 * Checks if this VM is in NEM mode and is long-mode capable.
     30 *
     31 * Use VMR3IsLongModeAllowed() instead of this, when possible.
     32 *
     33 * @returns true if long mode is allowed, false otherwise.
     34 * @param   pVM         The cross context VM structure.
     35 * @sa      VMR3IsLongModeAllowed, HMIsLongModeAllowed
     36 */
     37VMM_INT_DECL(bool) NEMHCIsLongModeAllowed(PVM pVM)
     38{
     39    return pVM->nem.s.fAllow64BitGuests && VM_IS_NEM_ENABLED(pVM);
     40}
    2741
    2842
  • trunk/src/VBox/VMM/VMMR0/NEMR0Native-win.cpp

    r72304 r72343  
    17841784        if (paValues[iReg].Reg64 != pCtx->msrEFER)
    17851785        {
     1786            if ((paValues[iReg].Reg64 ^ pCtx->msrEFER) & MSR_K6_EFER_NXE)
     1787                PGMNotifyNxeChanged(pVCpu, RT_BOOL(paValues[iReg].Reg64 & MSR_K6_EFER_NXE));
    17861788            pCtx->msrEFER = paValues[iReg].Reg64;
    17871789            fMaybeChangedMode = true;
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r72208 r72343  
    2424#include <VBox/vmm/dbgf.h>
    2525#include <VBox/vmm/hm.h>
     26#include <VBox/vmm/nem.h>
    2627#include <VBox/vmm/ssm.h>
    2728#include "CPUMInternal.h"
     
    40214022                            && pVM->cpum.s.HostFeatures.fOpSysXSaveRstor
    40224023#if HC_ARCH_BITS == 32 /* Seems this may be broken when doing 64-bit on 32-bit, just disable it for now. */
    4023                             && !HMIsLongModeAllowed(pVM)
     4024                            && (   !HMIsLongModeAllowed(pVM)
     4025                                || NEMIsLongModeAllowed(pVM))
    40244026#endif
    40254027                            ;
  • trunk/src/VBox/VMM/VMMR3/NEMR3.cpp

    r72267 r72343  
    7676    int rc = CFGMR3ValidateConfig(pCfgNem,
    7777                                  "/NEM/",
    78                                   "Enabled",
     78                                  "Enabled"
     79                                  "|Allow64BitGuests",
    7980                                  "" /* pszValidNodes */, "NEM" /* pszWho */, 0 /* uInstance */);
    8081    if (RT_FAILURE(rc))
     
    8586    rc = CFGMR3QueryBoolDef(pCfgNem, "Enabled", &pVM->nem.s.fEnabled, true);
    8687    AssertLogRelRCReturn(rc, rc);
     88
     89
     90#ifdef VBOX_WITH_64_BITS_GUESTS
     91    /** @cfgm{/HM/Allow64BitGuests, bool, 32-bit:false, 64-bit:true}
     92     * Enables AMD64 CPU features.
     93     * On 32-bit hosts this isn't default and require host CPU support. 64-bit hosts
     94     * already have the support. */
     95    rc = CFGMR3QueryBoolDef(pCfgNem, "Allow64BitGuests", &pVM->nem.s.fAllow64BitGuests, HC_ARCH_BITS == 64);
     96    AssertLogRelRCReturn(rc, rc);
     97#else
     98    pVM->nem.s.fAllow64BitGuests = false;
     99#endif
     100
    87101
    88102    return VINF_SUCCESS;
     
    151165{
    152166    int rc = VINF_SUCCESS;
    153 #ifdef VBOX_WITH_NATIVE_NEM
    154     if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
     167    if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
     168    {
     169        /*
     170         * Enable CPU features making general ASSUMPTIONS (there are two similar
     171         * blocks of code in HM.cpp), to avoid duplicating this code.  The
     172         * native backend can make check capabilities and adjust as needed.
     173         */
     174        CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
     175        if (CPUMGetGuestCpuVendor(pVM) == CPUMCPUVENDOR_AMD)
     176            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);            /* 64 bits only on Intel CPUs */
     177        if (pVM->nem.s.fAllow64BitGuests)
     178        {
     179            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);
     180            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
     181            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
     182            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
     183            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     184        }
     185        /* Turn on NXE if PAE has been enabled. */
     186        else if (CPUMR3GetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE))
     187            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     188
     189        /*
     190         * Do native after-CPUM init.
     191         */
     192#ifdef VBOX_WITH_NATIVE_NEM
    155193        rc = nemR3NativeInitAfterCPUM(pVM);
    156194#else
    157     RT_NOREF(pVM);
    158 #endif
     195        RT_NOREF(pVM);
     196#endif
     197    }
    159198    return rc;
    160199}
  • trunk/src/VBox/VMM/VMMR3/VM.cpp

    r71699 r72343  
    45304530/**
    45314531 * Checks if the VM is long-mode (64-bit) capable or not.
    4532  * @returns true if VM can operate in long-mode, false
    4533  *        otherwise.
    4534  *
     4532 *
     4533 * @returns true if VM can operate in long-mode, false otherwise.
    45354534 * @param   pVM             The cross context VM structure.
    45364535 */
    45374536VMMR3_INT_DECL(bool) VMR3IsLongModeAllowed(PVM pVM)
    45384537{
    4539 /** @todo NEM: Fixme log mode allowed stuff. */
    4540     if (HMIsEnabled(pVM))
    4541         return HMIsLongModeAllowed(pVM);
    4542     return false;
     4538    switch (pVM->bMainExecutionEngine)
     4539    {
     4540        case VM_EXEC_ENGINE_HW_VIRT:
     4541            return HMIsLongModeAllowed(pVM);
     4542
     4543        case VM_EXEC_ENGINE_NATIVE_API:
     4544#ifndef IN_RC
     4545            return NEMHCIsLongModeAllowed(pVM);
     4546#else
     4547            return false;
     4548#endif
     4549
     4550        case VM_EXEC_ENGINE_NOT_SET:
     4551            AssertFailed();
     4552            RT_FALL_THRU();
     4553        default:
     4554            return false;
     4555    }
    45434556}
    45444557
  • trunk/src/VBox/VMM/include/HMInternal.h

    r72208 r72343  
    4040#endif
    4141
    42 #if HC_ARCH_BITS == 64 || defined (VBOX_WITH_64_BITS_GUESTS)
     42#if HC_ARCH_BITS == 64 || defined(VBOX_WITH_64_BITS_GUESTS)
    4343/* Enable 64 bits guest support. */
    4444# define VBOX_ENABLE_64_BITS_GUESTS
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r72308 r72343  
    108108    /** Set if enabled. */
    109109    bool                        fEnabled;
     110    /** Set if long mode guests are allowed. */
     111    bool                        fAllow64BitGuests;
    110112#ifdef RT_OS_WINDOWS
    111113    /** Set if we've created the EMTs. */
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