VirtualBox

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


Ignore:
Timestamp:
Jun 12, 2018 1:06:02 PM (6 years ago)
Author:
vboxsync
Message:

NEM,TM: More TSC adjustments for NEM/win. bugref:9044

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

Legend:

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

    r72470 r72526  
    307307
    308308
     309/**
     310 * Indicates to TM that TMTSCMODE_NATIVE_API should be used for TSC.
     311 *
     312 * @returns true if TMTSCMODE_NATIVE_API must be used, otherwise @c false.
     313 * @param   pVM     The cross context VM structure.
     314 */
     315VMMR3_INT_DECL(bool) NEMR3NeedSpecialTscMode(PVM pVM)
     316{
     317#ifdef VBOX_WITH_NATIVE_NEM
     318# ifdef RT_OS_WINDOWS
     319    if (VM_IS_NEM_ENABLED(pVM))
     320        return true;
     321# endif
     322#else
     323    RT_NOREF(pVM);
     324#endif
     325    return false;
     326}
     327
     328
     329
    309330VMMR3_INT_DECL(VBOXSTRICTRC) NEMR3RunGC(PVM pVM, PVMCPU pVCpu)
    310331{
  • trunk/src/VBox/VMM/VMMR3/NEMR3Native-win.cpp

    r72522 r72526  
    12381238                            STAMR3RegisterF(pVM, &pNemCpu->StatImportOnReturn,      STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of state imports on loop return", "/NEM/CPU%u/ImportOnReturn", iCpu);
    12391239                            STAMR3RegisterF(pVM, &pNemCpu->StatImportOnReturnSkipped, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of skipped state imports on loop return", "/NEM/CPU%u/ImportOnReturnSkipped", iCpu);
     1240                            STAMR3RegisterF(pVM, &pNemCpu->StatQueryCpuTick,        STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TSC queries",                  "/NEM/CPU%u/QueryCpuTick", iCpu);
    12401241                        }
    12411242
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r72522 r72526  
    127127#include <VBox/vmm/mm.h>
    128128#include <VBox/vmm/hm.h>
     129#include <VBox/vmm/nem.h>
    129130#include <VBox/vmm/gim.h>
    130131#include <VBox/vmm/ssm.h>
     
    381382         * without any kind of coordination) will lead to inconsistent TSC behavior with
    382383         * guest SMP, including TSC going backwards. */
    383         pVM->tm.s.enmTSCMode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMTSCMODE_DYNAMIC : TMTSCMODE_VIRT_TSC_EMULATED;
     384        pVM->tm.s.enmTSCMode = NEMR3NeedSpecialTscMode(pVM) ? TMTSCMODE_NATIVE_API
     385                             : pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMTSCMODE_DYNAMIC : TMTSCMODE_VIRT_TSC_EMULATED;
    384386    }
    385387    else if (RT_FAILURE(rc))
     
    395397        else
    396398            return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM TSC mode value \"%s\""), szTSCMode);
     399        if (NEMR3NeedSpecialTscMode(pVM))
     400        {
     401            LogRel(("TM: NEM overrides the /TM/TSCMode=%s settings.\n", szTSCMode));
     402            pVM->tm.s.enmTSCMode = TMTSCMODE_NATIVE_API;
     403        }
    397404    }
    398405
     
    411418    else if (RT_FAILURE(rc))
    412419        return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Failed to querying bool value \"TSCModeSwitchAllowed\""));
     420    if (pVM->tm.s.fTSCModeSwitchAllowed && pVM->tm.s.enmTSCMode == TMTSCMODE_NATIVE_API)
     421    {
     422        LogRel(("TM: NEM overrides the /TM/TSCModeSwitchAllowed setting.\n"));
     423        pVM->tm.s.fTSCModeSwitchAllowed = false;
     424    }
    413425
    414426    /** @cfgm{/TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP}
     
    420432    {
    421433        pVM->tm.s.cTSCTicksPerSecond = tmR3CalibrateTSC();
    422         if (   pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET
     434        if (   (   pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC
     435                || pVM->tm.s.enmTSCMode == TMTSCMODE_VIRT_TSC_EMULATED)
    423436            && pVM->tm.s.cTSCTicksPerSecond >= _4G)
    424437        {
     
    435448                          N_("Configuration error: \"TSCTicksPerSecond\" = %RI64 is not in the range 1MHz..4GHz-1"),
    436449                          pVM->tm.s.cTSCTicksPerSecond);
     450    else if (pVM->tm.s.enmTSCMode != TMTSCMODE_NATIVE_API)
     451        pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    437452    else
    438         pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
     453    {
     454        LogRel(("TM: NEM overrides the /TM/TSCTicksPerSecond=%RU64 setting.\n", pVM->tm.s.cTSCTicksPerSecond));
     455        pVM->tm.s.cTSCTicksPerSecond = tmR3CalibrateTSC();
     456    }
    439457
    440458    /** @cfgm{/TM/TSCTiedToExecution, bool, false}
     
    449467        return VMSetError(pVM, rc, RT_SRC_POS,
    450468                          N_("Configuration error: Failed to querying bool value \"TSCTiedToExecution\""));
     469    if (pVM->tm.s.fTSCTiedToExecution && pVM->tm.s.enmTSCMode == TMTSCMODE_NATIVE_API)
     470        return VMSetError(pVM, VERR_INVALID_PARAMETER, RT_SRC_POS, N_("/TM/TSCTiedToExecution is not supported in NEM mode!"));
    451471    if (pVM->tm.s.fTSCTiedToExecution)
    452472        pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    453473
    454     /** @cfgm{/TM/TSCNotTiedToHalt, bool, true}
    455      * For overriding the default of TM/TSCTiedToExecution, i.e. set this to false
    456      * to make the TSC freeze during HLT. */
     474
     475    /** @cfgm{/TM/TSCNotTiedToHalt, bool, false}
     476     * This is used with /TM/TSCTiedToExecution to control how TSC operates
     477     * accross HLT instructions.  When true HLT is considered execution time and
     478     * TSC continues to run, while when false (default) TSC stops during halt. */
    457479    rc = CFGMR3QueryBoolDef(pCfgHandle, "TSCNotTiedToHalt", &pVM->tm.s.fTSCNotTiedToHalt, false);
    458480    if (RT_FAILURE(rc))
     
    572594    if (pVM->tm.s.fVirtualWarpDrive)
    573595    {
    574         pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    575         LogRel(("TM: Warp-drive active. u32VirtualWarpDrivePercentage=%RI32\n", pVM->tm.s.u32VirtualWarpDrivePercentage));
     596        if (pVM->tm.s.enmTSCMode == TMTSCMODE_NATIVE_API)
     597            LogRel(("TM: Warp-drive active, escept for TSC which is in NEM mode. u32VirtualWarpDrivePercentage=%RI32\n",
     598                    pVM->tm.s.u32VirtualWarpDrivePercentage));
     599        else
     600        {
     601            pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
     602            LogRel(("TM: Warp-drive active. u32VirtualWarpDrivePercentage=%RI32\n", pVM->tm.s.u32VirtualWarpDrivePercentage));
     603        }
    576604    }
    577605
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