Skip to contentSkip to conversation

Track TSC synchronization in generations

PATCH In review Zachary Amsden 1 participant 1 message Jun 21, 2011

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 8/9 Track TSC synchronization in generations

-------- Original Message --------
Subject: [KVM TSC emulation 8/9] Track TSC synchronization in generations
Date: Mon, 20 Jun 2011 16:59:36 -0700
From: Zachary Amsden <[email protected]>
To: Avi Kivity <[email protected]>, Marcelo Tosatti <[email protected]>, Glauber Costa <[email protected]>, Frank Arnold <[email protected]>, Joerg Roedel <[email protected]>, Jan Kiszka <[email protected]>, [email protected], [email protected], Zachary Amsden <[email protected]>, Avi Kivity <[email protected]>, Marcelo Tosatti <[email protected]>, Glauber Costa <[email protected]>, Frank Arnold <[email protected]>, Joerg Roedel <[email protected]>, Jan Kiszka <[email protected]>, [email protected]
CC: Zachary Amsden <[email protected]>, Zachary Amsden <[email protected]>

This allows us to track the original nanosecond and counter values at each phase of TSC writing by the guest. This gets us perfect offset matching for stable TSC systems, and perfect software computed TSC matching for machines with unstable TSC.

---
 arch/x86/include/asm/kvm_host.h |   10 ++++++--
 arch/x86/kvm/x86.c              |   41 +++++++++++++++++++++++++++++++-------
 2 files changed, 40 insertions(+), 11 deletions(-)
arch/x86/include/asm/kvm_host.h +7 -3
index 226897f..198ce8b 100644
@@ -391,10 +391,11 @@ struct kvm_vcpu_arch {
 	struct page *time_page;
 	u64 last_guest_tsc;
 	u64 last_kernel_ns;
-	u64 last_tsc_nsec;
-	u64 last_tsc_write;
 	u64 last_host_tsc;
 	u64 tsc_offset_adjustment;
+	u64 this_tsc_nsec;
+	u64 this_tsc_write;
+	u8  this_tsc_generation;
 	bool tsc_catchup;
 	bool tsc_always_catchup;
 	s8 virtual_tsc_shift;
@@ -468,9 +469,12 @@ struct kvm_arch {
 	s64 kvmclock_offset;
 	raw_spinlock_t tsc_write_lock;
 	u64 last_tsc_nsec;
-	u64 last_tsc_offset;
 	u64 last_tsc_write;
 	u32 last_tsc_khz;
+	u64 cur_tsc_nsec;
+	u64 cur_tsc_write;
+	u64 cur_tsc_offset;
+	u8  cur_tsc_generation;
 
 	struct kvm_xen_hvm_config xen_hvm_config;
 
arch/x86/kvm/x86.c +33 -8

70 lines not on this page · raw message

Signature · 1 line
1.7.1