KVM: x86: Report host tsc and realtime values in KVM_GET_CLOCK
authorOliver Upton <oupton@google.com>
Thu, 16 Sep 2021 18:15:35 +0000 (18:15 +0000)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 18 Oct 2021 18:43:44 +0000 (14:43 -0400)
commitc68dc1b577eabd5605c6c7c08f3e07ae18d30d5d
treee7d06e5afc7e9eda6259256c18da24fe42c9a327
parent3d5e7a28b1ea2d603dea478e58e37ce75b9597ab
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.

Suggested-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Oliver Upton <oupton@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <20210916181538.968978-5-oupton@google.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Documentation/virt/kvm/api.rst
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c
include/uapi/linux/kvm.h