Changeset 56791 in vbox
- Timestamp:
- Jul 3, 2015 4:19:59 PM (10 years ago)
- svn:sync-xref-src-repo-rev:
- 101441
- Location:
- trunk/src/VBox/VMM
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/VMM/VMMAll/GIMAllKvm.cpp
r55714 r56791 35 35 36 36 #include <iprt/asm-amd64-x86.h> 37 #include <iprt/time.h> 37 38 38 39 … … 226 227 bool fEnable = RT_BOOL(uRawValue & MSR_GIM_KVM_SYSTEM_TIME_ENABLE_BIT); 227 228 #ifndef IN_RING3 229 # ifdef IN_RING0 230 gimR0KvmUpdateSystemTime(pVM, pVCpu); 231 # else 232 Assert(pVM->cCpus == 1); 228 233 if (fEnable) 229 234 { 230 RTCCUINTREG fEFlags 231 pKvmCpu->uTsc = TMCpuTickGetNoCheck(pVCpu) ;232 pKvmCpu->uVirtNanoTS = TMVirtualGetNoCheck(pVM) ;235 RTCCUINTREG fEFlags = ASMIntDisableFlags(); 236 pKvmCpu->uTsc = TMCpuTickGetNoCheck(pVCpu) | UINT64_C(1); 237 pKvmCpu->uVirtNanoTS = TMVirtualGetNoCheck(pVM) | UINT64_C(1); 233 238 ASMSetFlags(fEFlags); 234 239 } 240 # endif 235 241 return VINF_CPUM_R3_MSR_WRITE; 236 242 #else … … 251 257 int rc2 = PGMPhysSimpleReadGCPhys(pVM, &SystemTime, pKvmCpu->GCPhysSystemTime, sizeof(GIMKVMSYSTEMTIME)); 252 258 if (RT_SUCCESS(rc2)) 253 fFlags = (SystemTime.fFlags & GIM_KVM_SYSTEM_TIME_FLAGS_GUEST_PAUSED);259 pKvmCpu->fSystemTimeFlags = (SystemTime.fFlags & GIM_KVM_SYSTEM_TIME_FLAGS_GUEST_PAUSED); 254 260 } 255 261 … … 258 264 pKvmCpu->GCPhysSystemTime = MSR_GIM_KVM_SYSTEM_TIME_GUEST_GPA(uRawValue); 259 265 pKvmCpu->u32SystemTimeVersion += 2; 260 int rc = gimR3KvmEnableSystemTime(pVM, pVCpu , pKvmCpu, fFlags);266 int rc = gimR3KvmEnableSystemTime(pVM, pVCpu); 261 267 if (RT_FAILURE(rc)) 262 268 { … … 282 288 if (RT_SUCCESS(rc)) 283 289 { 284 pKvm->u64WallClockMsr 290 pKvm->u64WallClockMsr = uRawValue; 285 291 return VINF_SUCCESS; 286 292 } -
trunk/src/VBox/VMM/VMMR0/GIMR0.cpp
r54819 r56791 43 43 return gimR0HvInitVM(pVM); 44 44 45 case GIMPROVIDERID_KVM: 46 return gimR0KvmInitVM(pVM); 47 45 48 default: 46 49 break; … … 65 68 case GIMPROVIDERID_HYPERV: 66 69 return gimR0HvTermVM(pVM); 70 71 case GIMPROVIDERID_KVM: 72 return gimR0KvmTermVM(pVM); 67 73 68 74 default: -
trunk/src/VBox/VMM/VMMR3/GIMKvm.cpp
r56693 r56791 358 358 SSMR3GetGCPhys(pSSM, &pKvmCpu->GCPhysSystemTime); 359 359 SSMR3GetU32(pSSM, &pKvmCpu->u32SystemTimeVersion); 360 rc = SSMR3GetU8(pSSM, & fSystemTimeFlags);360 rc = SSMR3GetU8(pSSM, &pKvmCpu->fSystemTimeFlags); 361 361 AssertRCReturn(rc, rc); 362 362 363 363 /* Enable the system-time struct. if necessary. */ 364 /** @todo update guest struct only if cTscTicksPerSecond doesn't match host 365 * anymore. */ 364 366 if (MSR_GIM_KVM_SYSTEM_TIME_IS_ENABLED(pKvmCpu->u64SystemTimeMsr)) 365 367 { 366 368 Assert(!TMVirtualIsTicking(pVM)); /* paranoia. */ 367 369 Assert(!TMCpuTickIsTicking(pVCpu)); 368 rc = gimR3KvmEnableSystemTime(pVM, pVCpu , pKvmCpu, fSystemTimeFlags);370 rc = gimR3KvmEnableSystemTime(pVM, pVCpu); 369 371 AssertRCReturn(rc, rc); 370 372 } … … 388 390 * @param pVM Pointer to the VM. 389 391 * @param pVCpu Pointer to the VMCPU. 390 * @param pKvmCpu Pointer to the GIMKVMCPU with all fields391 * populated by the caller.392 * @param fFlags The system-time struct. flags.393 392 * 394 393 * @remarks Don't do any release assertions here, these can be triggered by 395 394 * guest R0 code. 396 395 */ 397 VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu, PGIMKVMCPU pKvmCpu, uint8_t fFlags) 398 { 396 VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu) 397 { 398 PGIMKVM pKvm = &pVM->gim.s.u.Kvm; 399 PGIMKVMCPU pKvmCpu = &pVCpu->gim.s.u.KvmCpu; 400 399 401 /* 400 402 * Validate the mapping address first. … … 407 409 } 408 410 411 /* 412 * Construct the system-time struct. 413 */ 409 414 GIMKVMSYSTEMTIME SystemTime; 410 415 RT_ZERO(SystemTime); … … 412 417 SystemTime.u64NanoTS = pKvmCpu->uVirtNanoTS; 413 418 SystemTime.u64Tsc = pKvmCpu->uTsc; 414 SystemTime.fFlags = fFlags | GIM_KVM_SYSTEM_TIME_FLAGS_TSC_STABLE;419 SystemTime.fFlags = pKvmCpu->fSystemTimeFlags | GIM_KVM_SYSTEM_TIME_FLAGS_TSC_STABLE; 415 420 416 421 /* … … 424 429 * time = ((tsc * SysTime.u32TscScale) >> 32) + SysTime.u64NanoTS 425 430 */ 426 PGIMKVM pKvm = &pVM->gim.s.u.Kvm;427 431 uint64_t u64TscFreq = pKvm->cTscTicksPerSecond; 428 432 SystemTime.i8TscShift = 0; … … 440 444 SystemTime.u32TscScale = ASMDivU64ByU32RetU32(RT_NS_1SEC_64 << 32, uTscFreqLo); 441 445 446 /* 447 * Update guest memory with the system-time struct. 448 */ 442 449 Assert(!(SystemTime.u32Version & UINT32_C(1))); 443 450 int rc = PGMPhysSimpleWriteGCPhys(pVM, pKvmCpu->GCPhysSystemTime, &SystemTime, sizeof(GIMKVMSYSTEMTIME)); -
trunk/src/VBox/VMM/include/GIMKvmInternal.h
r56677 r56791 203 203 /** The TSC frequency (in HZ) reported to the guest. */ 204 204 uint64_t cTscTicksPerSecond; 205 /** Ring-0 mutex. */ 206 RTSEMFASTMUTEX hFastMtx; 205 207 } GIMKVM; 206 208 /** Pointer to per-VM GIM KVM instance data. */ … … 225 227 /** The guest virtual time while enabling the system-time MSR. */ 226 228 uint64_t uVirtNanoTS; 229 /** The flags of the system-time struct. */ 230 uint8_t fSystemTimeFlags; 227 231 } GIMKVMCPU; 228 232 /** Pointer to per-VCPU GIM KVM instance data. */ … … 235 239 236 240 #ifdef IN_RING0 237 #if 0238 241 VMMR0_INT_DECL(int) gimR0KvmInitVM(PVM pVM); 239 242 VMMR0_INT_DECL(int) gimR0KvmTermVM(PVM pVM); 240 VMMR0_INT_DECL(int) gimR0KvmUpdateParavirtTsc(PVM pVM, uint64_t u64Offset); 241 #endif 243 VMMR0_INT_DECL(int) gimR0KvmUpdateSystemTime(PVM pVM, PVMCPU pVCpu); 242 244 #endif /* IN_RING0 */ 243 245 … … 252 254 253 255 VMMR3_INT_DECL(int) gimR3KvmDisableSystemTime(PVM pVM); 254 VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu , PGIMKVMCPU pKvmCpu, uint8_t fFlags);256 VMMR3_INT_DECL(int) gimR3KvmEnableSystemTime(PVM pVM, PVMCPU pVCpu); 255 257 VMMR3_INT_DECL(int) gimR3KvmEnableWallClock(PVM pVM, RTGCPHYS GCPhysSysTime); 256 258 #endif /* IN_RING3 */
Note:
See TracChangeset
for help on using the changeset viewer.