Handling the migration of TSCs correctly is difficult, in part because Linux does not provide userspace with the ability to retrieve a (TSC, realtime) clock pair for a single instant in time. In lieu of a more convenient facility, KVM can report similar information in the kvm_clock structure. Provide userspace with a host TSC & realtime pair iff the realtime clock is based on the TSC. If userspace provides KVM_SET_CLOCK with a valid realtime value, advance the KVM clock by the amount of elapsed time. Do not step the KVM clock backwards, though, as it is a monotonic oscillator.
Showing the changes to include/uapi (1 of 4 files). Show all
Unified · Split
| @@ -1231,11 +1231,16 @@ struct kvm_irqfd { · 1230 unmodified lines | ||
| 1231 | 1231 | |
| 1232 | 1232 | /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */ |
| 1233 | 1233 | #define KVM_CLOCK_TSC_STABLE 2 |
| 1234 | +#define KVM_CLOCK_REALTIME (1 << 2) | |
| 1235 | +#define KVM_CLOCK_HOST_TSC (1 << 3) | |
| 1234 | 1236 | |
| 1235 | 1237 | struct kvm_clock_data { |
| 1236 | 1238 | __u64 clock; |
| 1237 | 1239 | __u32 flags; |
| 1238 | − __u32 pad[9]; | |
| 1240 | + __u32 pad0; | |
| 1241 | + __u64 realtime; | |
| 1242 | + __u64 host_tsc; | |
| 1243 | + __u32 pad[4]; | |
| 1239 | 1244 | }; |
| 1240 | 1245 | |
| 1241 | 1246 | /* For KVM_CAP_SW_TLB */ |