kvm/x86: Hyper-V internal helper to read MSR HV_X64_MSR_TIME_REF_COUNT
authorAndrey Smetanin <asmetanin@virtuozzo.com>
Mon, 30 Nov 2015 16:22:19 +0000 (19:22 +0300)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 16 Dec 2015 17:49:43 +0000 (18:49 +0100)
This helper will be used also in Hyper-V SynIC timers implementation.

Signed-off-by: Andrey Smetanin <asmetanin@virtuozzo.com>
Reviewed-by: Roman Kagan <rkagan@virtuozzo.com>
CC: Gleb Natapov <gleb@kernel.org>
CC: Paolo Bonzini <pbonzini@redhat.com>
CC: "K. Y. Srinivasan" <kys@microsoft.com>
CC: Haiyang Zhang <haiyangz@microsoft.com>
CC: Vitaly Kuznetsov <vkuznets@redhat.com>
CC: Roman Kagan <rkagan@virtuozzo.com>
CC: Denis V. Lunev <den@openvz.org>
CC: qemu-devel@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/hyperv.c

index 41869a9d43f8b043193411ebb11990c9c901a932..99589268fe5d923eae3ca315d8dca47c438a40c9 100644 (file)
@@ -335,6 +335,11 @@ static void synic_init(struct kvm_vcpu_hv_synic *synic)
        }
 }
 
+static u64 get_time_ref_counter(struct kvm *kvm)
+{
+       return div_u64(get_kernel_ns() + kvm->arch.kvmclock_offset, 100);
+}
+
 void kvm_hv_vcpu_init(struct kvm_vcpu *vcpu)
 {
        synic_init(vcpu_to_synic(vcpu));
@@ -576,11 +581,9 @@ static int kvm_hv_get_msr_pw(struct kvm_vcpu *vcpu, u32 msr, u64 *pdata)
        case HV_X64_MSR_HYPERCALL:
                data = hv->hv_hypercall;
                break;
-       case HV_X64_MSR_TIME_REF_COUNT: {
-               data =
-                    div_u64(get_kernel_ns() + kvm->arch.kvmclock_offset, 100);
+       case HV_X64_MSR_TIME_REF_COUNT:
+               data = get_time_ref_counter(kvm);
                break;
-       }
        case HV_X64_MSR_REFERENCE_TSC:
                data = hv->hv_tsc_page;
                break;