VirtualBox

Changeset 95256 in vbox


Ignore:
Timestamp:
Jun 13, 2022 10:44:19 AM (3 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
151814
Message:

VMM/CFGM,NEM,HM,ConsoleImpl2: Let CPUM take care of enabling 64-bit guest supported in the CPU features, rather than HM, NEM and other main execution engines. bugref:9898

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vmm/cpum.h

    r95248 r95256  
    15911591VMMR3_INT_DECL(void)   CPUMR3ClearGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
    15921592VMMR3_INT_DECL(bool)   CPUMR3GetGuestCpuIdFeature(PVM pVM, CPUMCPUIDFEATURE enmFeature);
    1593 VMMR3_INT_DECL(void)   CPUMR3CpuIdEnable64BitGuests(PVM pVM);
    15941593VMMDECL(bool)          CPUMSetGuestCpuIdPerCpuApicFeature(PVMCPU pVCpu, bool fVisible);
    15951594VMMDECL(void)          CPUMSetGuestCtx(PVMCPU pVCpu, const PCPUMCTX pCtx);
  • trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp

    r95254 r95256  
    853853    hrc = pMachine->COMGETTER(CPUProfile)(bstrCpuProfile.asOutParam());                     H();
    854854
     855    /* Check if long mode is enabled. */
     856    BOOL fIsGuest64Bit;
     857    hrc = pMachine->GetCPUProperty(CPUPropertyType_LongMode, &fIsGuest64Bit);               H();
     858
    855859    /*
    856860     * Figure out the IOMMU config.
     
    11081112        BOOL fEnablePAE = false;
    11091113        hrc = pMachine->GetCPUProperty(CPUPropertyType_PAE, &fEnablePAE);                   H();
     1114        fEnablePAE |= fIsGuest64Bit;
    11101115        InsertConfigInteger(pRoot, "EnablePAE", fEnablePAE);
     1116
     1117        /* 64-bit guests (long mode) */
     1118        InsertConfigInteger(pCPUM, "Enable64bit", fIsGuest64Bit);
    11111119
    11121120        /* APIC/X2APIC configuration */
     
    11701178         * Hardware virtualization extensions.
    11711179         */
    1172         BOOL fIsGuest64Bit;
    1173         hrc = pMachine->GetCPUProperty(CPUPropertyType_LongMode, &fIsGuest64Bit);           H();
    1174 
    11751180        /* Sanitize valid/useful APIC combinations, see @bugref{8868}. */
    11761181        if (!fEnableAPIC)
  • trunk/src/VBox/VMM/VMMR3/CPUMR3CpuId.cpp

    r95248 r95256  
    31533153         * unrestricted-guest execution, CR4 feature bits and possibly more in the future.
    31543154         */
     3155        /** @todo r=bird: given that long mode never used to be enabled before the
     3156         *        VMINITCOMPLETED_RING0 state, and we're a lot earlier here in ring-3
     3157         *        init, the above comment cannot be entirely accurate. */
    31553158        if (pVM->cpum.s.GuestFeatures.fVmx)
    31563159        {
     
    31723175         */
    31733176
     3177        /* Check if 64-bit guest supported was enabled. */
     3178        bool fEnable64bit;
     3179        rc = CFGMR3QueryBoolDef(pCpumCfg, "Enable64bit", &fEnable64bit, false);
     3180        AssertRCReturn(rc, rc);
     3181        if (fEnable64bit)
     3182        {
     3183            /* In case of a CPU upgrade: */
     3184            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
     3185            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);      /* (Long mode only on Intel CPUs.) */
     3186            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
     3187            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
     3188            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
     3189
     3190            /* The actual feature: */
     3191            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
     3192        }
     3193
    31743194        /* Check if PAE was explicitely enabled by the user. */
    31753195        bool fEnable;
    3176         rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "EnablePAE", &fEnable, false);
     3196        rc = CFGMR3QueryBoolDef(CFGMR3GetRoot(pVM), "EnablePAE", &fEnable, fEnable64bit);
    31773197        AssertRCReturn(rc, rc);
    3178         if (fEnable)
     3198        if (fEnable && !pVM->cpum.s.GuestFeatures.fPae)
    31793199            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
    31803200
    31813201        /* We don't normally enable NX for raw-mode, so give the user a chance to force it on. */
    3182         rc = CFGMR3QueryBoolDef(pCpumCfg, "EnableNX", &fEnable, false);
     3202        rc = CFGMR3QueryBoolDef(pCpumCfg, "EnableNX", &fEnable, fEnable64bit);
    31833203        AssertRCReturn(rc, rc);
    3184         if (fEnable)
     3204        if (fEnable && !pVM->cpum.s.GuestFeatures.fNoExecute)
    31853205            CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    31863206
     
    37063726        pVCpu->cpum.s.fChanged |= CPUM_CHANGED_CPUID;
    37073727    }
    3708 }
    3709 
    3710 
    3711 /**
    3712  * Enables 64-bit guest support for the CPU.
    3713  *
    3714  * @param   pVM                 The cross context VM structure.
    3715  */
    3716 VMMR3_INT_DECL(void) CPUMR3CpuIdEnable64BitGuests(PVM pVM)
    3717 {
    3718     /* In case of a CPU upgrade: */
    3719     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SEP);
    3720     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_SYSCALL);      /* (Long mode only on Intel CPUs.) */
    3721     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_PAE);
    3722     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LAHF);
    3723     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_NX);
    3724 
    3725     /* The actual feature: */
    3726     CPUMR3SetGuestCpuIdFeature(pVM, CPUMCPUIDFEATURE_LONG_MODE);
    37273728}
    37283729
  • trunk/src/VBox/VMM/VMMR3/HM.cpp

    r95248 r95256  
    17391739
    17401740    /*
    1741      * Change the CPU features.
    1742      */
    1743     if (pVM->hm.s.fAllow64BitGuestsCfg)
    1744         CPUMR3CpuIdEnable64BitGuests(pVM);
    1745 
    1746     /*
    17471741     * Log configuration details.
    17481742     */
     
    19481942
    19491943    hmR3DisableRawMode(pVM);
    1950 
    1951     /*
    1952      * Change the CPU features.
    1953      */
    1954     if (pVM->hm.s.fAllow64BitGuestsCfg)
    1955         CPUMR3CpuIdEnable64BitGuests(pVM);
    19561944
    19571945    LogRel((pVM->hm.s.fTprPatchingAllowed ? "HM: Enabled TPR patching\n"
  • trunk/src/VBox/VMM/VMMR3/NEMR3.cpp

    r95248 r95256  
    209209    if (pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NATIVE_API)
    210210    {
    211         if (pVM->nem.s.fAllow64BitGuests)
    212             CPUMR3CpuIdEnable64BitGuests(pVM);
    213 
    214211        /*
    215212         * Do native after-CPUM init.
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