VirtualBox

Changeset 36649 in vbox for trunk/src/VBox/Devices/PC


Ignore:
Timestamp:
Apr 12, 2011 10:56:51 AM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
71120
Message:

HPET: fix time jumps

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/PC/DevHPET.cpp

    r35353 r36649  
    741741                break;
    742742            }
    743             // for 8-byte accesses we just split them, happens under lock anyway
    744743            if ((iIndex >= 0x100) && (iIndex < 0x400))
    745744            {
    746745                uint32_t iTimer = (iIndex - 0x100) / 0x20;
    747746                uint32_t iTimerReg = (iIndex - 0x100) % 0x20;
    748 
     747               
     748                /* for most 8-byte accesses we just split them, happens under lock anyway. */
    749749                rc = hpetTimerRegRead32(pThis, iTimer, iTimerReg, &value.u32[0]);
    750750                if (RT_UNLIKELY(rc != VINF_SUCCESS))
     
    754754            else
    755755            {
    756                 rc = hpetConfigRegRead32(pThis, iIndex, &value.u32[0]);
    757                 if (RT_UNLIKELY(rc != VINF_SUCCESS))
    758                     break;
    759                 rc = hpetConfigRegRead32(pThis, iIndex+4, &value.u32[1]);
     756                if (iIndex == HPET_COUNTER)
     757                {
     758                    /* When reading HPET counter we must read it in a single read,
     759                       to avoid unexpected time jumps on 32-bit overflow. */
     760                    value.u64 =
     761                            (pThis->u64HpetConfig & HPET_CFG_ENABLE) != 0
     762                            ?
     763                            hpetGetTicks(pThis)
     764                            :
     765                            pThis->u64HpetCounter;
     766                    rc = VINF_SUCCESS;
     767                }
     768                else
     769                {
     770                    /* for most 8-byte accesses we just split them, happens under lock anyway. */
     771                   
     772                    rc = hpetConfigRegRead32(pThis, iIndex, &value.u32[0]);
     773                    if (RT_UNLIKELY(rc != VINF_SUCCESS))
     774                        break;
     775                    rc = hpetConfigRegRead32(pThis, iIndex+4, &value.u32[1]);
     776                }
    760777            }
    761778            if (rc == VINF_SUCCESS)
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