Changeset 51852 in vbox for trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
- Timestamp:
- Jul 3, 2014 3:09:01 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 94703
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/TMAllCpu.cpp
r51643 r51852 80 80 } 81 81 82 /** 83 * Resumes the CPU timestamp counter ticking. 84 * 85 * @returns VINF_SUCCESS or VERR_TM_VIRTUAL_TICKING_IPE (asserted). 86 * @param pVM Pointer to the VM. 87 * @param pVCpu Pointer to the VCPU. 88 */ 89 int tmCpuTickResumeLocked(PVM pVM, PVMCPU pVCpu) 90 { 91 if (!pVCpu->tm.s.fTSCTicking) 92 { 93 /* TSC must be ticking before calling tmCpuTickGetRawVirtual()! */ 94 pVCpu->tm.s.fTSCTicking = true; 95 if (pVM->tm.s.fTSCVirtualized) 96 { 97 uint32_t c = ASMAtomicIncU32(&pVM->tm.s.cTSCsTicking); 98 AssertMsgReturn(c <= pVM->cCpus, ("%u vs %u\n", c, pVM->cCpus), VERR_TM_VIRTUAL_TICKING_IPE); 99 if (c == 1) 100 { 101 /* The first VCPU to resume. */ 102 uint64_t offTSCRawSrcOld = pVCpu->tm.s.offTSCRawSrc; 103 104 STAM_COUNTER_INC(&pVM->tm.s.StatTSCResume); 105 106 /* When resuming, use the TSC value of the last stopped VCPU to avoid the TSC going back. */ 107 if (pVM->tm.s.fTSCUseRealTSC) 108 pVCpu->tm.s.offTSCRawSrc = ASMReadTSC() - pVM->tm.s.u64LastPausedTSC; 109 else 110 pVCpu->tm.s.offTSCRawSrc = tmCpuTickGetRawVirtual(pVM, false /* don't check for pending timers */) 111 - pVM->tm.s.u64LastPausedTSC; 112 113 /* Calculate the offset for other VCPUs to use. */ 114 pVM->tm.s.offTSCPause = pVCpu->tm.s.offTSCRawSrc - offTSCRawSrcOld; 115 } 116 else 117 { 118 /* All other VCPUs (if any). */ 119 pVCpu->tm.s.offTSCRawSrc += pVM->tm.s.offTSCPause; 120 } 121 } 122 } 123 return VINF_SUCCESS; 124 } 125 82 126 83 127 /** … … 94 138 pVCpu->tm.s.u64TSC = TMCpuTickGetNoCheck(pVCpu); 95 139 pVCpu->tm.s.fTSCTicking = false; 140 return VINF_SUCCESS; 141 } 142 AssertFailed(); 143 return VERR_TM_TSC_ALREADY_PAUSED; 144 } 145 146 /** 147 * Pauses the CPU timestamp counter ticking. 148 * 149 * @returns VBox status code. 150 * @param pVM Pointer to the VM. 151 * @param pVCpu Pointer to the VMCPU. 152 * @internal 153 */ 154 int tmCpuTickPauseLocked(PVM pVM, PVMCPU pVCpu) 155 { 156 if (pVCpu->tm.s.fTSCTicking) 157 { 158 pVCpu->tm.s.u64TSC = TMCpuTickGetNoCheck(pVCpu); 159 pVCpu->tm.s.fTSCTicking = false; 160 161 uint32_t c = ASMAtomicDecU32(&pVM->tm.s.cTSCsTicking); 162 AssertMsgReturn(c < pVM->cCpus, ("%u vs %u\n", c, pVM->cCpus), VERR_TM_VIRTUAL_TICKING_IPE); 163 if (c == 0) 164 { 165 /* When the last TSC stops, remember the value. */ 166 STAM_COUNTER_INC(&pVM->tm.s.StatTSCPause); 167 pVM->tm.s.u64LastPausedTSC = pVCpu->tm.s.u64TSC; 168 } 96 169 return VINF_SUCCESS; 97 170 }
Note:
See TracChangeset
for help on using the changeset viewer.