VirtualBox

Changeset 54219 in vbox for trunk/include/VBox


Ignore:
Timestamp:
Feb 16, 2015 3:27:29 PM (10 years ago)
Author:
vboxsync
Message:

HostDrivers/support: TSC-delta bits.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/sup.h

    r54215 r54219  
    16161616# ifdef IN_RING3
    16171617    Assert(GIP_ARE_TSC_DELTAS_APPLICABLE(g_pSUPGlobalInfoPage));
    1618     return SUPR3ReadTsc(puTsc, pidApic);
     1618
     1619    /** @todo Use rdtscp after figuring out what the host OS has stuffed into the
     1620     *        TSC_AUX msr, otherwise use the fallback below. */
     1621    int cTries = 10;
     1622    do
     1623    {
     1624        uint16_t idApicBefore;
     1625        uint16_t idApicAfter;
     1626
     1627        /* The chance of getting preempted twice here is rather low, hence we
     1628           take this approach. Performance matters, see @bugref{6710} comment #24. */
     1629        idApicBefore = ASMGetApicId();
     1630        *puTsc       = ASMReadTSC();
     1631        idApicAfter  = ASMGetApicId();
     1632        if (RT_LIKELY(idApicBefore == idApicAfter))
     1633        {
     1634            SUPTscDeltaApply(g_pSUPGlobalInfoPage, puTsc, idApicBefore, NULL);
     1635            if (pidApic)
     1636                *pidApic = idApicBefore;
     1637            return VINF_SUCCESS;
     1638        }
     1639    } while (cTries-- > 0);
     1640    *puTsc = 0;
     1641    return VERR_SUPDRV_TSC_READ_FAILED;
     1642
     1643    /** @todo get rid of SUPR3ReadTsc(). */
     1644    //return SUPR3ReadTsc(puTsc, pidApic);
    16191645# else
    16201646    RTCCUINTREG uFlags;
     
    16221648    bool        fDeltaApplied;
    16231649    int         rc;
     1650
     1651    /** @todo Use rdtscp after figuring out what the host OS has stuffed into the
     1652     *        TSC_AUX msr, otherwise use the fallback below. */
    16241653
    16251654    /* Validate. */
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