KVM: x86: hyper-v: Track Hyper-V TSC page status
authorVitaly Kuznetsov <vkuznets@redhat.com>
Tue, 16 Mar 2021 14:37:35 +0000 (15:37 +0100)
committerPaolo Bonzini <pbonzini@redhat.com>
Thu, 18 Mar 2021 12:02:46 +0000 (08:02 -0400)
commitcc9cfddb0433961107bb156fa769fdd7eb6718de
tree94155bc1737da39f522c5b59848fc451c5cb03c1
parente880c6ea55b9805294ecc100ee95e0c9860ae90e
KVM: x86: hyper-v: Track Hyper-V TSC page status

Create an infrastructure for tracking Hyper-V TSC page status, i.e. if it
was updated from guest/host side or if we've failed to set it up (because
e.g. guest wrote some garbage to HV_X64_MSR_REFERENCE_TSC) and there's no
need to retry.

Also, in a hypothetical situation when we are in 'always catchup' mode for
TSC we can now avoid contending 'hv->hv_lock' on every guest enter by
setting the state to HV_TSC_PAGE_BROKEN after compute_tsc_page_parameters()
returns false.

Check for HV_TSC_PAGE_SET state instead of '!hv->tsc_ref.tsc_sequence' in
get_time_ref_counter() to properly handle the situation when we failed to
write the updated TSC page values to the guest.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Message-Id: <20210316143736.964151-4-vkuznets@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/hyperv.c