[Devel] [PATCH vz7.19 1/2] KVM:x86: remnants of get_kvmclock_ns port

Roman Kagan rkagan at virtuozzo.com
Mon Oct 31 10:32:26 PDT 2016


The commit 108b249c453dd7132599ab6dc7e435a7036c193f introducing
get_kvmclock_ns was ported with a few omissions; this patch completes
the process.

Signed-off-by: Roman Kagan <rkagan at virtuozzo.com>
---
 arch/x86/kvm/x86.c | 4 ++--
 arch/x86/kvm/x86.h | 9 ---------
 2 files changed, 2 insertions(+), 11 deletions(-)

diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c
index 1a3bea2..b1618b5 100644
--- a/arch/x86/kvm/x86.c
+++ b/arch/x86/kvm/x86.c
@@ -1311,7 +1311,7 @@ void kvm_write_tsc(struct kvm_vcpu *vcpu, struct msr_data *msr)
 
 	raw_spin_lock_irqsave(&kvm->arch.tsc_write_lock, flags);
 	offset = kvm_x86_ops->compute_tsc_offset(vcpu, data);
-	ns = get_kernel_ns();
+	ns = ktime_to_ns(ktime_get_boottime());
 	elapsed = ns - kvm->arch.last_tsc_nsec;
 
 	if (vcpu->arch.virtual_tsc_khz) {
@@ -1713,7 +1713,7 @@ static int kvm_guest_time_update(struct kvm_vcpu *v)
 	}
 	if (!use_master_clock) {
 		host_tsc = native_read_tsc();
-		kernel_ns = get_kernel_ns();
+		kernel_ns = ktime_to_ns(ktime_get_boottime());
 	}
 
 	tsc_timestamp = kvm_x86_ops->read_l1_tsc(v, host_tsc);
diff --git a/arch/x86/kvm/x86.h b/arch/x86/kvm/x86.h
index ab4c57a..be5ebaa 100644
--- a/arch/x86/kvm/x86.h
+++ b/arch/x86/kvm/x86.h
@@ -145,15 +145,6 @@ static inline void kvm_register_writel(struct kvm_vcpu *vcpu,
 	return kvm_register_write(vcpu, reg, val);
 }
 
-static inline u64 get_kernel_ns(void)
-{
-	struct timespec ts;
-
-	ktime_get_ts(&ts);
-	monotonic_to_bootbased(&ts);
-	return timespec_to_ns(&ts);
-}
-
 void kvm_before_handle_nmi(struct kvm_vcpu *vcpu);
 void kvm_after_handle_nmi(struct kvm_vcpu *vcpu);
 int kvm_inject_realmode_interrupt(struct kvm_vcpu *vcpu, int irq, int inc_eip);
-- 
2.7.4



More information about the Devel mailing list