VirtualBox

Changeset 80080 in vbox for trunk/src/VBox/VMM/VMMR3/HM.cpp


Ignore:
Timestamp:
Jul 31, 2019 4:12:31 PM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
132520
Message:

VMM: Kicking out raw-mode and 32-bit hosts - HM, VMMSWITCHER, ++. bugref:9517 bugref:9511

File:
1 edited

Legend:

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

    r80052 r80080  
    219219     */
    220220    rc = CFGMR3ValidateConfig(pCfgHm, "/HM/",
    221                               "HMForced"
     221                              "HMForced"  /* implied 'true' these days */
    222222                              "|UseNEMInstead"
    223223                              "|FallbackToNEM"
     
    253253     * enabled, i.e. /HMEnabled must be true. */
    254254    bool fHMForced;
    255 #ifdef VBOX_WITH_RAW_MODE
    256     rc = CFGMR3QueryBoolDef(pCfgHm, "HMForced", &fHMForced, false);
    257     AssertRCReturn(rc, rc);
    258     AssertLogRelMsgReturn(!fHMForced || pVM->fHMEnabled, ("Configuration error: HM forced but not enabled!\n"),
    259                           VERR_INVALID_PARAMETER);
    260 # if defined(RT_OS_DARWIN)
    261     if (pVM->fHMEnabled)
    262         fHMForced = true;
    263 # endif
    264     AssertLogRelMsgReturn(pVM->cCpus == 1 || pVM->fHMEnabled, ("Configuration error: SMP requires HM to be enabled!\n"),
    265                           VERR_INVALID_PARAMETER);
    266     if (pVM->cCpus > 1)
    267         fHMForced = true;
    268 #else  /* !VBOX_WITH_RAW_MODE */
    269255    AssertRelease(pVM->fHMEnabled);
    270256    fHMForced = true;
    271 #endif /* !VBOX_WITH_RAW_MODE */
    272257
    273258    /** @cfgm{/HM/UseNEMInstead, bool, true}
     
    318303     * On 32-bit hosts this isn't default and require host CPU support. 64-bit hosts
    319304     * already have the support. */
    320 #ifdef VBOX_ENABLE_64_BITS_GUESTS
     305#ifdef VBOX_WITH_64_BITS_GUESTS
    321306    rc = CFGMR3QueryBoolDef(pCfgHm, "64bitEnabled", &pVM->hm.s.fAllow64BitGuests, HC_ARCH_BITS == 64);
    322307    AssertLogRelRCReturn(rc, rc);
     
    516501                    }
    517502                    if (RT_FAILURE(rc))
    518                     {
    519                         if (fHMForced)
    520                             return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x: %s\n", pszWhy);
    521 
    522                         /* Fall back to raw-mode. */
    523                         LogRel(("HM: HMR3Init: Falling back to raw-mode: The host kernel does not support VT-x - %s\n", pszWhy));
    524                         VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_RAW_MODE);
    525                     }
     503                        return VMSetError(pVM, rc, RT_SRC_POS, "The host kernel does not support VT-x: %s\n", pszWhy);
    526504                }
    527505            }
     
    529507                AssertLogRelMsgFailedReturn(("SUPR3QueryVTCaps didn't return either AMD-V or VT-x flag set (%#x)!\n", fCaps),
    530508                                            VERR_INTERNAL_ERROR_5);
    531 
    532             /*
    533              * Do we require a little bit or raw-mode for 64-bit guest execution?
    534              */
    535             pVM->fHMNeedRawModeCtx = HC_ARCH_BITS == 32
    536                                   && pVM->fHMEnabled
    537                                   && pVM->hm.s.fAllow64BitGuests;
    538509
    539510            /*
     
    593564            }
    594565            if (RT_FAILURE(rc))
    595             {
    596                 if (fHMForced)
    597                     return VM_SET_ERROR(pVM, rc, pszMsg);
    598 
    599                 LogRel(("HM: HMR3Init: Falling back to raw-mode: %s\n", pszMsg));
    600                 VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_RAW_MODE);
    601             }
     566                return VM_SET_ERROR(pVM, rc, pszMsg);
    602567        }
    603568    }
     
    607572         * Disabled HM mean raw-mode, unless NEM is supposed to be used.
    608573         */
    609         if (!fUseNEMInstead)
    610             VM_SET_MAIN_EXECUTION_ENGINE(pVM, VM_EXEC_ENGINE_RAW_MODE);
    611         else
     574        if (fUseNEMInstead)
    612575        {
    613576            rc = NEMR3Init(pVM, false /*fFallback*/, true);
     
    616579                return rc;
    617580        }
    618     }
    619 
     581        if (   pVM->bMainExecutionEngine == VM_EXEC_ENGINE_NOT_SET
     582            || pVM->bMainExecutionEngine == VM_EXEC_ENGINE_RAW_MODE
     583            || pVM->bMainExecutionEngine == VM_EXEC_ENGINE_HW_VIRT /* paranoia */)
     584            return VM_SET_ERROR(pVM, rc, "Misconfigured VM: No guest execution engine available!");
     585    }
     586
     587    Assert(pVM->bMainExecutionEngine != VM_EXEC_ENGINE_NOT_SET);
     588    Assert(pVM->bMainExecutionEngine != VM_EXEC_ENGINE_RAW_MODE);
    620589    return VINF_SUCCESS;
    621590}
     
    716685                             "/PROF/CPU%d/HM/InGC", i);
    717686        AssertRC(rc);
    718 
    719 # if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
    720         rc = STAMR3RegisterF(pVM, &pVCpu->hm.s.StatWorldSwitch3264, STAMTYPE_PROFILE, STAMVISIBILITY_USED,
    721                              STAMUNIT_TICKS_PER_CALL, "Profiling of the 32/64 switcher.",
    722                              "/PROF/CPU%d/HM/Switcher3264", i);
    723         AssertRC(rc);
    724 # endif
    725687
    726688# ifdef HM_PROFILE_EXIT_DISPATCH
     
    857819        HM_REG_COUNTER(&pVCpu->hm.s.StatVmxCheckPmOk,           "/HM/CPU%d/VMXCheck/VMX_PM", "VMX execution in protected mode OK.");
    858820
    859 #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
    860         HM_REG_COUNTER(&pVCpu->hm.s.StatFpu64SwitchBack,        "/HM/CPU%d/Switch64/Fpu", "Saving guest FPU/XMM state.");
    861         HM_REG_COUNTER(&pVCpu->hm.s.StatDebug64SwitchBack,      "/HM/CPU%d/Switch64/Debug", "Saving guest debug state.");
    862 #endif
    863 
    864821#undef HM_REG_COUNTER
    865822
     
    17501707            LogRel(("HM: Enabled unrestricted guest execution\n"));
    17511708
    1752 #if HC_ARCH_BITS == 64
    17531709        if (pVM->hm.s.fLargePages)
    17541710        {
     
    17571713            LogRel(("HM: Enabled large page support\n"));
    17581714        }
    1759 #endif
    17601715    }
    17611716    else
     
    18921847         * Enable large pages (2 MB) if applicable.
    18931848         */
    1894 #if HC_ARCH_BITS == 64
    18951849        if (pVM->hm.s.fLargePages)
    18961850        {
     
    18981852            LogRel(("HM:   Enabled large page support\n"));
    18991853        }
    1900 #endif
    19011854    }
    19021855
     
    19541907        }
    19551908    }
    1956 #if HC_ARCH_BITS == 32 && defined(VBOX_ENABLE_64_BITS_GUESTS)
    1957     if (HMIsEnabled(pVM))
    1958     {
    1959         switch (PGMGetHostMode(pVM))
    1960         {
    1961             case PGMMODE_32_BIT:
    1962                 pVM->hm.s.pfnHost32ToGuest64R0 = VMMR3GetHostToGuestSwitcher(pVM, VMMSWITCHER_32_TO_AMD64);
    1963                 break;
    1964 
    1965             case PGMMODE_PAE:
    1966             case PGMMODE_PAE_NX:
    1967                 pVM->hm.s.pfnHost32ToGuest64R0 = VMMR3GetHostToGuestSwitcher(pVM, VMMSWITCHER_PAE_TO_AMD64);
    1968                 break;
    1969 
    1970             default:
    1971                 AssertFailed();
    1972                 break;
    1973         }
    1974     }
    1975 #endif
    1976     return;
    19771909}
    19781910
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