Timekeeping in virtual machines: Difference between revisions
[unchecked revision] | [unchecked revision] |
Content deleted Content added
mNo edit summary |
→pvclock: Fix some errors |
||
Line 41:
pvclock is a simple protocol and the fastest way to properly track system time in a VM.
To use it, write a 64-bit 4-byte aligned physical address with bit 0 set to 1 to MSR_KVM_SYSTEM_TIME_NEW (<code>0x4b564d01</code>).
The presence of this MSR is indicated by bit 3 in EAX from leaf 0x4000001 of CPUID.
Line 61:
The host will automatically update this structure when necessary (e.g. when finishing a migration).
The system time <b>in nanoseconds</b> is calculated as such:
<source lang="C">
time = rdtsc() - tsc_timestamp
if (tsc_shift >= 0)
time <<= tsc_shift;
else
time >>= -tsc_shift;
time = (time * tsc_to_system_mul) >> 32
time = time + system_time
</source>
The version field is used to detect when the structure has been / is being updated.
|