VirtualBox

Changeset 53438 in vbox


Ignore:
Timestamp:
Dec 3, 2014 7:13:54 PM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97134
Message:

TM: Use CFGMR3Exists. Moved the do-not-use-dynamic-mode-with-SMP-VMs to the case where 'TSCMode' isn't specified. If someone want to experiment with SMP and the 'Dynamic' mode, I don't see why we should prevent them. (I don't expect anyone to do it unless we tell them to.)

File:
1 edited

Legend:

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

    r53433 r53438  
    313313
    314314    /*
    315      * Handle deprecated TM settings.
    316      */
    317     do
    318     {
    319         /** @todo make these runtime warnings instead of errors that refuse to start
    320          *        the VM? */
    321         bool fTSCVirtualized;
    322         rc = CFGMR3QueryBool(pCfgHandle, "TSCVirtualized", &fTSCVirtualized);
    323         if (RT_SUCCESS(rc))
    324             return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
    325                               N_("Configuration error: TM setting \"TSCVirtualized\" is no longer supported. Use the \"Mode\" setting instead."));
    326 
    327         bool fForceUseRealTSC;
    328         rc = CFGMR3QueryBool(pCfgHandle, "UseRealTSC", &fForceUseRealTSC);
    329         if (RT_SUCCESS(rc))
    330             return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
    331                               N_("Configuration error: TM setting \"UseRealTSC\" is no longer supported. Use the \"Mode\" setting instead."));
    332 
    333         bool fMaybeUseOffsettedHostTSC;
    334         rc = CFGMR3QueryBool(pCfgHandle, "MaybeUseOffsettedHostTSC", &fMaybeUseOffsettedHostTSC);
    335         if (RT_SUCCESS(rc))
    336             return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
    337                               N_("Configuration error: TM setting \"MaybeUseOffsettedHostTSC\" is no longer supported. Use the \"Mode\" setting instead."));
    338     } while(0);
     315     * Specific errors about some obsolete TM settings (remove after 2015-12-03).
     316     */
     317    if (CFGMR3Exists(pCfgHandle, "TSCVirtualized"))
     318        return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
     319                          N_("Configuration error: TM setting \"TSCVirtualized\" is no longer supported. Use the \"Mode\" setting instead."));
     320    if (CFGMR3Exists(pCfgHandle, "UseRealTSC"))
     321        return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
     322                          N_("Configuration error: TM setting \"UseRealTSC\" is no longer supported. Use the \"Mode\" setting instead."));
     323
     324    if (CFGMR3Exists(pCfgHandle, "MaybeUseOffsettedHostTSC"))
     325        return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_VALUE, RT_SRC_POS,
     326                          N_("Configuration error: TM setting \"MaybeUseOffsettedHostTSC\" is no longer supported. Use the \"Mode\" setting instead."));
    339327
    340328    /*
    341329     * Validate the rest of the TM settings.
    342330     */
    343     if (!CFGMR3AreValuesValid(pCfgHandle,
    344                               "Mode\0"
    345                               "TSCTicksPerSecond\0"
    346                               "TSCTiedToExecution\0"
    347                               "TSCNotTiedToHalt\0"
    348                               "ScheduleSlack\0"
    349                               "CatchUpStopThreshold\0"
    350                               "CatchUpGiveUpThreshold\0"
    351                               "CatchUpStartThreshold0\0CatchUpStartThreshold1\0CatchUpStartThreshold2\0CatchUpStartThreshold3\0"
    352                               "CatchUpStartThreshold4\0CatchUpStartThreshold5\0CatchUpStartThreshold6\0CatchUpStartThreshold7\0"
    353                               "CatchUpStartThreshold8\0CatchUpStartThreshold9\0"
    354                               "CatchUpPrecentage0\0CatchUpPrecentage1\0CatchUpPrecentage2\0CatchUpPrecentage3\0"
    355                               "CatchUpPrecentage4\0CatchUpPrecentage5\0CatchUpPrecentage6\0CatchUpPrecentage7\0"
    356                               "CatchUpPrecentage8\0CatchUpPrecentage9\0"
    357                               "UTCOffset\0"
    358                               "WarpDrivePercentage\0"
    359                               "HostHzMax\0"
    360                               "HostHzFudgeFactorTimerCpu\0"
    361                               "HostHzFudgeFactorOtherCpu\0"
    362                               "HostHzFudgeFactorCatchUp100\0"
    363                               "HostHzFudgeFactorCatchUp200\0"
    364                               "HostHzFudgeFactorCatchUp400\0"
    365                               "TimerMillies\0"
    366                               ))
    367         return VMSetError(pVM, VERR_CFGM_CONFIG_UNKNOWN_NODE, RT_SRC_POS, N_("Configuration error: Invalid config key for TM."));
     331    rc = CFGMR3ValidateConfig(pCfgHandle, "/",
     332                              "Mode|"
     333                              "TSCTicksPerSecond|"
     334                              "TSCTiedToExecution|"
     335                              "TSCNotTiedToHalt|"
     336                              "ScheduleSlack|"
     337                              "CatchUpStopThreshold|"
     338                              "CatchUpGiveUpThreshold|"
     339                              "CatchUpStartThreshold0|CatchUpStartThreshold1|CatchUpStartThreshold2|CatchUpStartThreshold3|"
     340                              "CatchUpStartThreshold4|CatchUpStartThreshold5|CatchUpStartThreshold6|CatchUpStartThreshold7|"
     341                              "CatchUpStartThreshold8|CatchUpStartThreshold9|"
     342                              "CatchUpPrecentage0|CatchUpPrecentage1|CatchUpPrecentage2|CatchUpPrecentage3|"
     343                              "CatchUpPrecentage4|CatchUpPrecentage5|CatchUpPrecentage6|CatchUpPrecentage7|"
     344                              "CatchUpPrecentage8|CatchUpPrecentage9|"
     345                              "UTCOffset|"
     346                              "WarpDrivePercentage|"
     347                              "HostHzMax|"
     348                              "HostHzFudgeFactorTimerCpu|"
     349                              "HostHzFudgeFactorOtherCpu|"
     350                              "HostHzFudgeFactorCatchUp100|"
     351                              "HostHzFudgeFactorCatchUp200|"
     352                              "HostHzFudgeFactorCatchUp400|"
     353                              "TimerMillies",
     354                              "",
     355                              "TM", 0);
     356    if (RT_FAILURE(rc))
     357        return rc;
    368358
    369359    /*
    370360     * Determine the TSC configuration and frequency.
    371361     */
    372     /** @cfgm{/TM/Mode, string}
    373      *  The name of the time-keeping mode. The default is picked dynamically based
    374      *  on configuration of the VM. */
     362    /** @cfgm{/TM/Mode, string, Depends on the CPU and VM config}
     363     * The name of the TSC mode to use: VirtTSCEmulated, RealTSCOffset or Dyamic.
     364     * The default depends on the VM configuration and the capabilities of the
     365     * host CPU.  Other config options or runtime changes may override the TSC
     366     * mode specified here.
     367     * @todo r=bird: s/Mode/TSCMode/g */
    375368    char szMode[32];
    376369    rc = CFGMR3QueryString(pCfgHandle, "Mode", szMode, sizeof(szMode));
    377370    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    378         pVM->tm.s.enmMode = tmR3HasFixedTSC(pVM) ? TMMODE_DYNAMIC : TMMODE_VIRT_TSC_EMULATED;
     371    {
     372        /** @todo Rainy-day/never: Dynamic mode isn't currently suitable for SMP VMs, so
     373         * fall back on the more expensive emulated mode. With the current TSC handling
     374         * (frequent switching between offsetted mode and taking VM exits, on all VCPUs
     375         * without any kind of coordination) will lead to inconsistent TSC behavior with
     376         * guest SMP, including TSC going backwards. */
     377        pVM->tm.s.enmMode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMMODE_DYNAMIC : TMMODE_VIRT_TSC_EMULATED;
     378    }
    379379    else if (RT_FAILURE(rc))
    380380        return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Failed to querying string value \"Mode\""));
    381381    else
    382382    {
    383         AssertRC(rc);
    384383        if (!RTStrCmp(szMode, "VirtTSCEmulated"))
    385384            pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
     
    391390            return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM mode value \"%s\""), szMode);
    392391    }
    393 
    394     /** @todo needs a better fix, for now disable offsetted mode for VMs
    395      * with more than one VCPU. With the current TSC handling (frequent
    396      * switching between offsetted mode and taking VM exits, on all VCPUs
    397      * without any kind of coordination) it will lead to inconsistent TSC
    398      * behavior with guest SMP, including TSC going backwards. */
    399     if (   pVM->cCpus != 1
    400         && pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET)
    401         pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
    402392
    403393    /** @cfgm{/TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP}
     
    28542844        TMR3NotifySuspend(pVM, pVCpu);
    28552845
    2856     /** @todo should probably switch TM mode to virt-tsc-emulated if it isn't
    2857      *        already. */
     2846    /** @todo Should switch TM mode to virt-tsc-emulated if it isn't alread!. */
    28582847    pVM->tm.s.u32VirtualWarpDrivePercentage = u32Percent;
    28592848    pVM->tm.s.fVirtualWarpDrive = u32Percent != 100;
     
    32573246 * @param   pVM      Pointer to the VM.
    32583247 */
    3259 static const char * tmR3GetModeName(PVM pVM)
     3248static const char *tmR3GetModeName(PVM pVM)
    32603249{
    32613250    Assert(pVM);
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