]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: drop TSC offsetting kvm_x86_ops to fix KVM_GET/SET_CLOCK
authorPaolo Bonzini <pbonzini@redhat.com>
Mon, 31 Oct 2016 23:39:48 +0000 (00:39 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 2 Nov 2016 19:03:07 +0000 (20:03 +0100)
commit2da86d5d08c5281dc847b492e46c2b8a7209c9af
treebe3ae8868bd0e93e6029cfd9ce0512fe69dc39ab
parent80d1e357e2ec579827a479cabeb3854322bc8fdd
KVM: x86: drop TSC offsetting kvm_x86_ops to fix KVM_GET/SET_CLOCK

Since commit 243d7e3daabf ("kvm: x86: add tsc_offset field to struct
kvm_vcpu_arch", 2016-09-07) the offset between host and L1 TSC is
cached and need not be fished out of the VMCS or VMCB.  This means
that we can implement adjust_tsc_offset_guest and read_l1_tsc
entirely in generic code.  The simplification is particularly
significant for VMX code, where vmx->nested.vmcs01_tsc_offset
was duplicating what is now in vcpu->arch.tsc_offset.  Therefore
the vmcs01_tsc_offset can be dropped completely.

More importantly, this fixes KVM_GET_CLOCK/KVM_SET_CLOCK
which, after commit 4e7f0f01b367 ("KVM: x86: introduce get_kvmclock_ns",
2016-09-01) called read_l1_tsc while the VMCS was not loaded.
It thus returned bogus values on Intel CPUs.

Fixes: 4e7f0f01b367d95b9149a8ca54151b961d7fd76e
Reported-by: Roman Kagan <rkagan@virtuozzo.com>
Reviewed-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/svm.c
arch/x86/kvm/vmx.c
arch/x86/kvm/x86.c