VirtualBox

Changeset 99370 in vbox


Ignore:
Timestamp:
Apr 11, 2023 12:32:33 AM (23 months ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156785
Message:

VMM/NEM-win: Disable MONITOR/MWAIT CPUID flag as it seems Hyper-V never implements MONITOR and only sometimes MWAIT. Reportely causes troubles for Solaris guests. Untested!

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

Legend:

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

    r98103 r99370  
    5050
    5151#include <iprt/asm.h>
     52#include <iprt/string.h>
    5253
    5354
     
    535536#endif
    536537}
     538
     539
     540/**
     541 * Disables a CPU ISA extension, like MONITOR/MWAIT.
     542 *
     543 * @returns VBox status code
     544 * @param   pVM             The cross context VM structure.
     545 * @param   pszIsaExt       The ISA extension name in the config tree.
     546 */
     547int nemR3DisableCpuIsaExt(PVM pVM, const char *pszIsaExt)
     548{
     549    /*
     550     * Get IsaExts config node under CPUM.
     551     */
     552    PCFGMNODE pIsaExts = CFGMR3GetChild(CFGMR3GetRoot(pVM), "/CPUM/IsaExts");
     553    if (!pIsaExts)
     554    {
     555        int rc = CFGMR3InsertNode(CFGMR3GetRoot(pVM), "/CPUM/IsaExts", &pIsaExts);
     556        AssertLogRelMsgReturn(RT_SUCCESS(rc), ("CFGMR3InsertNode: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt), rc);
     557    }
     558
     559    /*
     560     * Look for a value by the given name (pszIsaExt).
     561     */
     562    /* Integer values 1 (CPUMISAEXTCFG_ENABLED_SUPPORTED) and 9 (CPUMISAEXTCFG_ENABLED_PORTABLE) will be replaced. */
     563    uint64_t u64Value;
     564    int rc = CFGMR3QueryInteger(pIsaExts, pszIsaExt, &u64Value);
     565    if (RT_SUCCESS(rc))
     566    {
     567        if (u64Value != 1 && u64Value != 9)
     568        {
     569            LogRel(("NEM: Not disabling IsaExt '%s', already configured with int value %lld\n", pszIsaExt, u64Value));
     570            return VINF_SUCCESS;
     571        }
     572        CFGMR3RemoveValue(pIsaExts, pszIsaExt);
     573    }
     574    /* String value 'default', 'enabled' and 'portable' will be replaced. */
     575    else if (rc == VERR_CFGM_NOT_INTEGER)
     576    {
     577        char szValue[32];
     578        rc = CFGMR3QueryString(pIsaExts, pszIsaExt, szValue, sizeof(szValue));
     579        AssertRCReturn(rc, VINF_SUCCESS);
     580
     581        if (   RTStrICmpAscii(szValue, "default")  != 0
     582            && RTStrICmpAscii(szValue, "def")      != 0
     583            && RTStrICmpAscii(szValue, "enabled")  != 0
     584            && RTStrICmpAscii(szValue, "enable")   != 0
     585            && RTStrICmpAscii(szValue, "on")       != 0
     586            && RTStrICmpAscii(szValue, "yes")      != 0
     587            && RTStrICmpAscii(szValue, "portable") != 0)
     588        {
     589            LogRel(("NEM: Not disabling IsaExt '%s', already configured with string value '%s'\n", pszIsaExt, szValue));
     590            return VINF_SUCCESS;
     591        }
     592        CFGMR3RemoveValue(pIsaExts, pszIsaExt);
     593    }
     594    else
     595        AssertLogRelMsgReturn(rc == VERR_CFGM_VALUE_NOT_FOUND, ("CFGMR3QueryInteger: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt),
     596                              VERR_NEM_IPE_8);
     597
     598    /*
     599     * Insert the disabling value.
     600     */
     601    rc = CFGMR3InsertInteger(pIsaExts, pszIsaExt, 0 /* disabled */);
     602    AssertLogRelMsgReturn(RT_SUCCESS(rc), ("CFGMR3InsertInteger: rc=%Rrc pszIsaExt=%s\n", rc, pszIsaExt), rc);
     603
     604    return VINF_SUCCESS;
     605}
     606
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r98103 r99370  
    13191319                    Log(("NEM: Marked active!\n"));
    13201320                    nemR3WinDisableX2Apic(pVM);
     1321                    nemR3DisableCpuIsaExt(pVM, "MONITOR"); /* MONITOR is not supported by Hyper-V (MWAIT is sometimes). */
    13211322                    PGMR3EnableNemMode(pVM);
    13221323
     
    15681569    /*
    15691570     * Adjust features.
    1570      * Note! We've already disabled X2APIC via CFGM during the first init call.
    1571      */
     1571     *
     1572     * Note! We've already disabled X2APIC and MONITOR/MWAIT via CFGM during
     1573     *       the first init call.
     1574     */
     1575
    15721576    return VINF_SUCCESS;
    15731577}
  • trunk/src/VBox/VMM/include/NEMInternal.h

    r99051 r99370  
    623623
    624624#ifdef IN_RING3
     625
     626int     nemR3DisableCpuIsaExt(PVM pVM, const char *pszIsaExt);
     627
    625628int     nemR3NativeInit(PVM pVM, bool fFallback, bool fForced);
    626629int     nemR3NativeInitAfterCPUM(PVM pVM);
     
    667670 */
    668671DECLHIDDEN(bool) nemR3NativeNotifyDebugEventChangedPerCpu(PVM pVM, PVMCPU pVCpu, bool fUseDebugLoop);
    669 #endif
     672
     673#endif /* IN_RING3 */
    670674
    671675void    nemHCNativeNotifyHandlerPhysicalRegister(PVMCC pVM, PGMPHYSHANDLERKIND enmKind, RTGCPHYS GCPhys, RTGCPHYS cb);
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