VirtualBox

Changeset 53441 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Dec 4, 2014 11:06:26 AM (10 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
97148
Message:

VMM/TM: Rename TMMODE to TMTSCMODE and the corresponding enum and CFGM key. Fixed an endian issue in the assembly code.

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

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp

    r53430 r53441  
    6767        /** @todo Test that pausing and resuming doesn't cause lag! (I.e. that we're
    6868         *        unpaused before the virtual time and stopped after it. */
    69         if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     69        if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    7070            pVCpu->tm.s.offTSCRawSrc = ASMReadTSC() - pVCpu->tm.s.u64TSC;
    7171        else
     
    102102
    103103            /* When resuming, use the TSC value of the last stopped VCPU to avoid the TSC going back. */
    104             if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     104            if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    105105                pVCpu->tm.s.offTSCRawSrc = ASMReadTSC() - pVM->tm.s.u64LastPausedTSC;
    106106            else
     
    182182{
    183183    /* Sample the reason for refusing. */
    184     if (pVM->tm.s.enmMode != TMMODE_DYNAMIC)
     184    if (pVM->tm.s.enmTSCMode != TMTSCMODE_DYNAMIC)
    185185       STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotFixed);
    186186    else if (!pVCpu->tm.s.fTSCTicking)
    187187       STAM_COUNTER_INC(&pVM->tm.s.StatTSCNotTicking);
    188     else if (pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET)
     188    else if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET)
    189189    {
    190190        if (pVM->tm.s.fVirtualSyncCatchUp)
     
    235235     */
    236236    *pfParavirtTsc = GIMIsParavirtTscEnabled(pVM);
    237     if (    pVM->tm.s.enmMode == TMMODE_DYNAMIC
     237    if (    pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC
    238238        &&  RT_LIKELY(pVCpu->tm.s.fTSCTicking)
    239         &&  (   pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET
     239        &&  (   pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET
    240240             || (   !pVM->tm.s.fVirtualSyncCatchUp
    241241                 && RT_LIKELY(pVM->tm.s.fVirtualSyncTicking)
    242242                 && !pVM->tm.s.fVirtualWarpDrive)))
    243243    {
    244         if (pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET)
     244        if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET)
    245245        {
    246246            /* The source is the timer synchronous virtual clock. */
     
    329329     */
    330330    *pfParavirtTsc = GIMIsParavirtTscEnabled(pVM);
    331     if (    pVM->tm.s.enmMode == TMMODE_DYNAMIC
     331    if (    pVM->tm.s.enmTSCMode == TMTSCMODE_DYNAMIC
    332332        &&  RT_LIKELY(pVCpu->tm.s.fTSCTicking)
    333         &&  (   pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET
     333        &&  (   pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET
    334334             || (   !pVM->tm.s.fVirtualSyncCatchUp
    335335                 && RT_LIKELY(pVM->tm.s.fVirtualSyncTicking)
     
    337337    {
    338338        *pfOffsettedTsc = true;
    339         if (pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET)
     339        if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET)
    340340        {
    341341            /* The source is the timer synchronous virtual clock. */
     
    383383    {
    384384        PVM pVM = pVCpu->CTX_SUFF(pVM);
    385         if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     385        if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    386386            u64 = ASMReadTSC();
    387387        else
     
    505505    /** @todo revisit this, not sure why we need to get the rate from GIP for
    506506     *        real-tsc-offset. */
    507     if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     507    if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    508508    {
    509509        uint64_t cTSCTicksPerSecond = SUPGetCpuHzFromGIP(g_pSUPGlobalInfoPage);
  • trunk/src/VBox/VMM/VMMR3/TM.cpp

    r53438 r53441  
    167167*******************************************************************************/
    168168static bool                 tmR3HasFixedTSC(PVM pVM);
    169 static const char *         tmR3GetModeName(PVM pVM);
     169static const char *         tmR3GetTSCModeName(PVM pVM);
    170170static uint64_t             tmR3CalibrateTSC(PVM pVM);
    171171static DECLCALLBACK(int)    tmR3Save(PVM pVM, PSSMHANDLE pSSM);
     
    360360     * Determine the TSC configuration and frequency.
    361361     */
    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.
     362    /** @cfgm{/TM/TSCMode, string, Depends on the CPU and VM config}
     363     * The name of the TSC mode to use: VirtTSCEmulated, RealTSCOffset or Dynamic.
    364364     * The default depends on the VM configuration and the capabilities of the
    365365     * host CPU.  Other config options or runtime changes may override the TSC
    366366     * mode specified here.
    367      * @todo r=bird: s/Mode/TSCMode/g */
    368     char szMode[32];
    369     rc = CFGMR3QueryString(pCfgHandle, "Mode", szMode, sizeof(szMode));
     367     */
     368    char szTSCMode[32];
     369    rc = CFGMR3QueryString(pCfgHandle, "TSCMode", szTSCMode, sizeof(szTSCMode));
    370370    if (rc == VERR_CFGM_VALUE_NOT_FOUND)
    371371    {
     
    375375         * without any kind of coordination) will lead to inconsistent TSC behavior with
    376376         * guest SMP, including TSC going backwards. */
    377         pVM->tm.s.enmMode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMMODE_DYNAMIC : TMMODE_VIRT_TSC_EMULATED;
     377        pVM->tm.s.enmTSCMode = pVM->cCpus == 1 && tmR3HasFixedTSC(pVM) ? TMTSCMODE_DYNAMIC : TMTSCMODE_VIRT_TSC_EMULATED;
    378378    }
    379379    else if (RT_FAILURE(rc))
     
    381381    else
    382382    {
    383         if (!RTStrCmp(szMode, "VirtTSCEmulated"))
    384             pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
    385         else if (!RTStrCmp(szMode, "RealTSCOffset"))
    386             pVM->tm.s.enmMode = TMMODE_REAL_TSC_OFFSET;
    387         else if (!RTStrCmp(szMode, "Dynamic"))
    388             pVM->tm.s.enmMode = TMMODE_DYNAMIC;
     383        if (!RTStrCmp(szTSCMode, "VirtTSCEmulated"))
     384            pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
     385        else if (!RTStrCmp(szTSCMode, "RealTSCOffset"))
     386            pVM->tm.s.enmTSCMode = TMTSCMODE_REAL_TSC_OFFSET;
     387        else if (!RTStrCmp(szTSCMode, "Dynamic"))
     388            pVM->tm.s.enmTSCMode = TMTSCMODE_DYNAMIC;
    389389        else
    390             return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM mode value \"%s\""), szMode);
     390            return VMSetError(pVM, rc, RT_SRC_POS, N_("Configuration error: Unrecognized TM mode value \"%s\""), szTSCMode);
    391391    }
    392392
    393393    /** @cfgm{/TM/TSCTicksPerSecond, uint32_t, Current TSC frequency from GIP}
    394394     * The number of TSC ticks per second (i.e. the TSC frequency). This will
    395      * override TSCtTSC, TSCVirtualized and MaybeUseOffsettedHostTSC.
     395     * override enmTSCMode.
    396396     */
    397397    rc = CFGMR3QueryU64(pCfgHandle, "TSCTicksPerSecond", &pVM->tm.s.cTSCTicksPerSecond);
     
    399399    {
    400400        pVM->tm.s.cTSCTicksPerSecond = tmR3CalibrateTSC(pVM);
    401         if (   pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET
     401        if (   pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET
    402402            && pVM->tm.s.cTSCTicksPerSecond >= _4G)
    403403        {
    404404            pVM->tm.s.cTSCTicksPerSecond = _4G - 1; /* (A limitation of our math code) */
    405             pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
     405            pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    406406        }
    407407    }
     
    416416    else
    417417    {
    418         pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
     418        pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    419419    }
    420420
     
    431431                          N_("Configuration error: Failed to querying bool value \"TSCTiedToExecution\""));
    432432    if (pVM->tm.s.fTSCTiedToExecution)
    433         pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
     433        pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    434434
    435435    /** @cfgm{/TM/TSCNotTiedToHalt, bool, true}
     
    544544    if (pVM->tm.s.fVirtualWarpDrive)
    545545    {
    546         pVM->tm.s.enmMode = TMMODE_VIRT_TSC_EMULATED;
     546        pVM->tm.s.enmTSCMode = TMTSCMODE_VIRT_TSC_EMULATED;
    547547        LogRel(("TM: Warp-drive active. u32VirtualWarpDrivePercentage=%RI32\n", pVM->tm.s.u32VirtualWarpDrivePercentage));
    548548    }
     
    550550    /* Setup and report */
    551551    CPUMR3SetCR4Feature(pVM, X86_CR4_TSD, ~X86_CR4_TSD);
    552     LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmMode=%d (%s)\n"
     552    LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmTSCMode=%d (%s)\n"
    553553            "TM: TSCTiedToExecution=%RTbool TSCNotTiedToHalt=%RTbool\n",
    554             pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmMode, tmR3GetModeName(pVM),
     554            pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM),
    555555            pVM->tm.s.fTSCTiedToExecution, pVM->tm.s.fTSCNotTiedToHalt));
    556556
     
    13171317            pVM->tm.s.u64LastPausedTSC = pVCpu->tm.s.u64TSC;
    13181318
    1319         if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     1319        if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    13201320            pVCpu->tm.s.offTSCRawSrc = 0; /** @todo TSC restore stuff and HWACC. */
    13211321    }
     
    13241324    if (RT_FAILURE(rc))
    13251325        return rc;
    1326     if (pVM->tm.s.enmMode != TMMODE_REAL_TSC_OFFSET)
     1326    if (pVM->tm.s.enmTSCMode != TMTSCMODE_REAL_TSC_OFFSET)
    13271327        pVM->tm.s.cTSCTicksPerSecond = u64Hz;
    13281328    /** @todo Compare with real TSC rate even when restoring with real-tsc-offset
    13291329     *        mode. */
    13301330
    1331     LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmMode=%d (%s) (state load)\n",
    1332             pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmMode, tmR3GetModeName(pVM)));
     1331    LogRel(("TM: cTSCTicksPerSecond=%#RX64 (%'RU64) enmTSCMode=%d (%s) (state load)\n",
     1332            pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.cTSCTicksPerSecond, pVM->tm.s.enmTSCMode, tmR3GetTSCModeName(pVM)));
    13331333
    13341334    /*
     
    28442844        TMR3NotifySuspend(pVM, pVCpu);
    28452845
    2846     /** @todo Should switch TM mode to virt-tsc-emulated if it isn't alread!. */
     2846    /** @todo Should switch TM mode to virt-tsc-emulated if it isn't already! */
    28472847    pVM->tm.s.u32VirtualWarpDrivePercentage = u32Percent;
    28482848    pVM->tm.s.fVirtualWarpDrive = u32Percent != 100;
     
    31933193                        u64TSC, u64TSC, TMCpuTicksPerSecond(pVM),
    31943194                        pVCpu->tm.s.fTSCTicking ? "ticking" : "paused");
    3195         if (pVM->tm.s.enmMode == TMMODE_REAL_TSC_OFFSET)
     3195        if (pVM->tm.s.enmTSCMode == TMTSCMODE_REAL_TSC_OFFSET)
    31963196        {
    31973197            pHlp->pfnPrintf(pHlp, " - real tsc offset");
     
    32413241
    32423242/**
    3243  * Gets the descriptive TM mode name.
     3243 * Gets the descriptive TM TSC mode name.
    32443244 *
    32453245 * @returns The name.
    32463246 * @param   pVM      Pointer to the VM.
    32473247 */
    3248 static const char *tmR3GetModeName(PVM pVM)
     3248static const char *tmR3GetTSCModeName(PVM pVM)
    32493249{
    32503250    Assert(pVM);
    3251     switch (pVM->tm.s.enmMode)
    3252     {
    3253         case TMMODE_REAL_TSC_OFFSET:    return "RealTscOffset";
    3254         case TMMODE_VIRT_TSC_EMULATED:  return "VirtTscEmulated";
    3255         case TMMODE_DYNAMIC:            return "Dynamic";
    3256         default:                        return "?????";
    3257     }
    3258 }
    3259 
     3251    switch (pVM->tm.s.enmTSCMode)
     3252    {
     3253        case TMTSCMODE_REAL_TSC_OFFSET:    return "RealTscOffset";
     3254        case TMTSCMODE_VIRT_TSC_EMULATED:  return "VirtTscEmulated";
     3255        case TMTSCMODE_DYNAMIC:            return "Dynamic";
     3256        default:                           return "?????";
     3257    }
     3258}
     3259
  • trunk/src/VBox/VMM/include/TMInternal.h

    r53439 r53441  
    321321 *
    322322 * The main modes of how TM implements the TSC clock (TMCLOCK_TSC).
    323  * @todo r=bird: s/TMMODE/TMTSCMODE/g
    324  */
    325 typedef enum TMMODE
     323 */
     324typedef enum TMTSCMODE
    326325{
    327326    /** The guest TSC is an emulated virtual TSC. */
    328     TMMODE_VIRT_TSC_EMULATED = 1,
     327    TMTSCMODE_VIRT_TSC_EMULATED = 1,
    329328    /** The guest TSC is an offset of the real TSC. */
    330     TMMODE_REAL_TSC_OFFSET,
     329    TMTSCMODE_REAL_TSC_OFFSET,
    331330    /** The guest TSC is dynamically derived through emulation or offsetting. */
    332     TMMODE_DYNAMIC
    333 } TMMODE;
    334 AssertCompileSize(TMMODE, sizeof(uint32_t));
     331    TMTSCMODE_DYNAMIC
     332} TMTSCMODE;
     333AssertCompileSize(TMTSCMODE, sizeof(uint32_t));
    335334
    336335
     
    354353
    355354    /** The current TSC mode of the VM.
    356      *  Config variable: Mode (string)
    357      * @todo r=bird: s/enmMode/enmTscMode/g */
    358     TMMODE                      enmMode;
     355     *  Config variable: Mode (string). */
     356    TMTSCMODE                   enmTSCMode;
    359357    /** Whether the TSC is tied to the execution of code.
    360358     * Config variable: TSCTiedToExecution (bool) */
     
    370368    /** The number of CPU clock ticks per second (TMCLOCK_TSC).
    371369     * Config variable: TSCTicksPerSecond (64-bit unsigned int)
    372      * The config variable implies @c enmMode would be
    373      * TMMODE_VIRT_TSC_EMULATED. */
     370     * The config variable implies @c enmTSCMode would be
     371     * TMTSCMODE_VIRT_TSC_EMULATED. */
    374372    uint64_t                    cTSCTicksPerSecond;
    375373    /** The TSC difference introduced by pausing the VM. */
  • trunk/src/VBox/VMM/testcase/tstVMStruct.h

    r53430 r53441  
    10111011    GEN_CHECK_OFF(TM, pvGIPRC);
    10121012    GEN_CHECK_OFF(TMCPU, fTSCTicking);
    1013     GEN_CHECK_OFF(TM, enmMode);
     1013    GEN_CHECK_OFF(TM, enmTSCMode);
    10141014    GEN_CHECK_OFF(TM, fTSCTiedToExecution);
    10151015    GEN_CHECK_OFF(TMCPU, offTSCRawSrc);
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