History

KVM: x86: Report host tsc and realtime values in KVM_GET_CLOCK

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.

Oliver Upton committed 5 years ago

Commit c68dc1b1 parent 3d5e7a24 files · +81 −24Browse files

Showing the changes to include/uapi (1 of 4 files). Show all

Unified · Split

include/uapi/linux/kvm.h+6−1
@@ -1231,11 +1231,16 @@ struct kvm_irqfd { · 1230 unmodified lines
12311231
12321232 /* Do not use 1, KVM_CHECK_EXTENSION returned it before we had flags. */
12331233 #define KVM_CLOCK_TSC_STABLE 2
1234+#define KVM_CLOCK_REALTIME (1 << 2)
1235+#define KVM_CLOCK_HOST_TSC (1 << 3)
12341236
12351237 struct kvm_clock_data {
12361238 __u64 clock;
12371239 __u32 flags;
1238− __u32 pad[9];
1240+ __u32 pad0;
1241+ __u64 realtime;
1242+ __u64 host_tsc;
1243+ __u32 pad[4];
12391244 };
12401245
12411246 /* For KVM_CAP_SW_TLB */

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t