diff options
author | Andrey Smetanin <[email protected]> | 2015-11-30 19:22:19 +0300 |
---|---|---|
committer | Paolo Bonzini <[email protected]> | 2015-12-16 18:49:43 +0100 |
commit | 93bf4172481c4b2a8544c83a687946252563edd0 (patch) | |
tree | 29815ca08330bf1518cb40801f6bcfaafeaf6c1f | |
parent | 0ae80384b257b0a1ffa4e5d9eab2eb559bb063c5 (diff) |
kvm/x86: Hyper-V internal helper to read MSR HV_X64_MSR_TIME_REF_COUNT
This helper will be used also in Hyper-V SynIC timers implementation.
Signed-off-by: Andrey Smetanin <[email protected]>
Reviewed-by: Roman Kagan <[email protected]>
CC: Gleb Natapov <[email protected]>
CC: Paolo Bonzini <[email protected]>
CC: "K. Y. Srinivasan" <[email protected]>
CC: Haiyang Zhang <[email protected]>
CC: Vitaly Kuznetsov <[email protected]>
CC: Roman Kagan <[email protected]>
CC: Denis V. Lunev <[email protected]>
CC: [email protected]
Signed-off-by: Paolo Bonzini <[email protected]>
-rw-r--r-- | arch/x86/kvm/hyperv.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/arch/x86/kvm/hyperv.c b/arch/x86/kvm/hyperv.c index 41869a9d43f8..99589268fe5d 100644 --- a/arch/x86/kvm/hyperv.c +++ b/arch/x86/kvm/hyperv.c @@ -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; |