diff mbox

[RFC,1/2] kvm/vmx: Print TSC_OFFSET information when TSC offset value is written to VMCS

Message ID 20121114013643.5338.55452.stgit@yunodevel (mailing list archive)
State New, archived
Headers show

Commit Message

Yoshihiro YUNOMAE Nov. 14, 2012, 1:36 a.m. UTC
Print TSC_OFFSET information when TSC offset value is written to VMCS for
measuring actual TSC of a guest.

TSC value on a guest is always the host TSC plus the guest's "TSC offset".
TSC offset is stored in the VMCS in vmx_write_tsc_offset() or
vmx_adjust_tsc_offset(). KVM executes the former function when a guest boots.
The latter function is executed when kvm clock is updated. On the other hand,
the host can read the TSC offset values from VMCS. So, if the host outputs the
TSC offset values, we can calculate an actual TSC value for each TSC timestamp
recorded trace data of the guest.

Signed-off-by: Yoshihiro YUNOMAE <yoshihiro.yunomae.ez@hitachi.com>
Cc: Avi Kivity <avi@redhat.com>
Cc: Marcelo Tosatti <mtosatti@redhat.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
Cc: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
---
 arch/x86/kvm/vmx.c |    5 +++++
 1 file changed, 5 insertions(+)



--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
index ad6b1dd..8edfe3c 100644
--- a/arch/x86/kvm/vmx.c
+++ b/arch/x86/kvm/vmx.c
@@ -1887,6 +1887,9 @@  static void vmx_write_tsc_offset(struct kvm_vcpu *vcpu, u64 offset)
 			 vmcs12->tsc_offset : 0));
 	} else {
 		vmcs_write64(TSC_OFFSET, offset);
+		pr_info("kvm: (%d) write TSC offset %llu, now clock %llu\n",
+			current->pid, vmcs_read64(TSC_OFFSET),
+			native_read_tsc());
 	}
 }
 
@@ -1894,6 +1897,8 @@  static void vmx_adjust_tsc_offset(struct kvm_vcpu *vcpu, s64 adjustment, bool ho
 {
 	u64 offset = vmcs_read64(TSC_OFFSET);
 	vmcs_write64(TSC_OFFSET, offset + adjustment);
+	pr_info("kvm: (%d) adjust TSC offset %llu, now clock %llu\n",
+		current->pid, vmcs_read64(TSC_OFFSET), native_read_tsc());
 	if (is_guest_mode(vcpu)) {
 		/* Even when running L2, the adjustment needs to apply to L1 */
 		to_vmx(vcpu)->nested.vmcs01_tsc_offset += adjustment;