VirtualBox

Changeset 53325 in vbox for trunk


Ignore:
Timestamp:
Nov 14, 2014 1:46:38 PM (10 years ago)
Author:
vboxsync
Message:

VMM: Fix sign inconsistency in the RealUseTSC case.

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

Legend:

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

    r53235 r53325  
    267267            /* The source is the real TSC. */
    268268            if (pVM->tm.s.fTSCVirtualized)
    269                 *poffRealTSC = pVCpu->tm.s.offTSCRawSrc;
     269                *poffRealTSC = 0 - pVCpu->tm.s.offTSCRawSrc;
    270270            else
    271271                *poffRealTSC = 0;
     
    365365            /* The source is the real TSC. */
    366366            if (pVM->tm.s.fTSCVirtualized)
    367                 *poffRealTSC = pVCpu->tm.s.offTSCRawSrc;
     367                *poffRealTSC = 0 - pVCpu->tm.s.offTSCRawSrc;
    368368            else
    369369                *poffRealTSC = 0;
  • trunk/src/VBox/VMM/VMMR0/HMSVMR0.cpp

    r53235 r53325  
    22632263        uint64_t u64LastTick = TMCpuTickGetLastSeen(pVCpu);
    22642264
    2265         if (u64CurTSC - pVmcb->ctrl.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))
     2265        if (u64CurTSC + pVmcb->ctrl.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))
    22662266        {
    22672267            pVmcb->ctrl.u32InterceptCtrl1 &= ~SVM_CTRL1_INTERCEPT_RDTSC;
     
    31993199    }
    32003200
     3201    /** @todo Last-seen-tick shouldn't be necessary when TM supports invariant
     3202     *        mode. */
    32013203    if (!(pVmcb->ctrl.u32InterceptCtrl1 & SVM_CTRL1_INTERCEPT_RDTSC))
    3202     {
    3203         /** @todo Find a way to fix hardcoding a guestimate.  */
    3204         TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() - pVmcb->ctrl.u64TSCOffset - 0x400);
    3205     }
     3204        TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVmcb->ctrl.u64TSCOffset);
    32063205
    32073206    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatExit1, x);
  • trunk/src/VBox/VMM/VMMR0/HMVMXR0.cpp

    r53235 r53325  
    56305630    {
    56315631        uint64_t u64CurTSC = ASMReadTSC();
    5632         if (u64CurTSC - pVCpu->hm.s.vmx.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))
     5632        if (u64CurTSC + pVCpu->hm.s.vmx.u64TSCOffset >= TMCpuTickGetLastSeen(pVCpu))
    56335633        {
    56345634            /* Note: VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT takes precedence over TSC_OFFSET, applies to RDTSCP too. */
    5635             rc = VMXWriteVmcs64(VMX_VMCS64_CTRL_TSC_OFFSET_FULL, 0 - pVCpu->hm.s.vmx.u64TSCOffset); AssertRC(rc);
     5635            rc = VMXWriteVmcs64(VMX_VMCS64_CTRL_TSC_OFFSET_FULL, pVCpu->hm.s.vmx.u64TSCOffset);    AssertRC(rc);
    56365636
    56375637            pVCpu->hm.s.vmx.u32ProcCtls &= ~VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT;
     
    87078707    pVmxTransient->fVectoringDoublePF  = false;                 /* Vectoring double page-fault needs to be determined later. */
    87088708
     8709    /** @todo Last-seen-tick shouldn't be necessary when TM supports invariant
     8710     *        mode. */
    87098711    if (!(pVCpu->hm.s.vmx.u32ProcCtls & VMX_VMCS_CTRL_PROC_EXEC_RDTSC_EXIT))
    8710     {
    8711         /** @todo Find a way to fix hardcoding a guestimate.  */
    8712         TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() - pVCpu->hm.s.vmx.u64TSCOffset
    8713                              - 0x400  /* guestimate of world switch overhead in clock ticks */);
    8714     }
     8712        TMCpuTickSetLastSeen(pVCpu, ASMReadTSC() + pVCpu->hm.s.vmx.u64TSCOffset);
    87158713
    87168714    STAM_PROFILE_ADV_STOP_START(&pVCpu->hm.s.StatInGC, &pVCpu->hm.s.StatExit1, x);
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