VirtualBox

Changeset 22242 in vbox for trunk/src/VBox/VMM/VMMAll


Ignore:
Timestamp:
Aug 13, 2009 3:38:35 PM (15 years ago)
Author:
vboxsync
Message:

Made TSC underflow checking more generic.

File:
1 edited

Legend:

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

    r20689 r22242  
    210210        else
    211211            u64 = ASMReadTSC();
     212
     213        /* Never return a value lower than what the guest has already seen. */
     214        if (u64 < pVCpu->tm.s.u64TSCLastSeen)
     215        {
     216            STAM_COUNTER_INC(&pVM->tm.s.StatTSCUnderflow);
     217            pVCpu->tm.s.u64TSCLastSeen += 64;   /* @todo choose a good increment here */
     218            u64 = pVCpu->tm.s.u64TSCLastSeen;
     219        }
    212220    }
    213221    else
     
    271279}
    272280
     281/**
     282 * Sets the last seen CPU timestamp counter.
     283 *
     284 * @returns VBox status code.
     285 * @param   pVCpu               The virtual CPU to operate on.
     286 * @param   u64LastSeenTick     The last seen timestamp value.
     287 *
     288 * @thread  EMT which TSC is to be set.
     289 */
     290VMMDECL(int) TMCpuTickSetLastSeen(PVMCPU pVCpu, uint64_t u64LastSeenTick)
     291{
     292    VMCPU_ASSERT_EMT(pVCpu);
     293
     294    Assert(pVCpu->tm.s.u64TSCLastSeen < u64LastSeenTick);
     295    pVCpu->tm.s.u64TSCLastSeen = u64LastSeenTick;
     296    return VINF_SUCCESS;
     297}
     298
     299/**
     300 * Gets the last seen CPU timestamp counter.
     301 *
     302 * @returns last seen TSC
     303 * @param   pVCpu               The virtual CPU to operate on.
     304 *
     305 * @thread  EMT which TSC is to be set.
     306 */
     307VMMDECL(uint64_t) TMCpuTickGetLastSeen(PVMCPU pVCpu)
     308{
     309    VMCPU_ASSERT_EMT(pVCpu);
     310
     311    return pVCpu->tm.s.u64TSCLastSeen;
     312}
     313
    273314
    274315/**
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