VirtualBox

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


Ignore:
Timestamp:
May 25, 2018 1:24:28 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
122799
Message:

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

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

Legend:

Unmodified
Added
Removed
  • 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
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