KVM: X86: Update last_guest_tsc in vcpu_put
authorJoerg Roedel <joerg.roedel@amd.com>
Mon, 18 Apr 2011 09:42:53 +0000 (11:42 +0200)
committerAvi Kivity <avi@redhat.com>
Wed, 11 May 2011 11:57:10 +0000 (07:57 -0400)
The last_guest_tsc is used in vcpu_load to adjust the
tsc_offset since tsc-scaling is merged. So the
last_guest_tsc needs to be updated in vcpu_put instead of
the the last_host_tsc. This is fixed with this patch.

Reported-by: Jan Kiszka <jan.kiszka@web.de>
Tested-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
arch/x86/include/asm/kvm_host.h
arch/x86/kvm/x86.c

index 3e03f37f43eabf19dae9a8595295f9af6751d931..e50bffcf3cc0aca9f4f738390d058237ae496aa1 100644 (file)
@@ -393,7 +393,6 @@ struct kvm_vcpu_arch {
        unsigned int hw_tsc_khz;
        unsigned int time_offset;
        struct page *time_page;
-       u64 last_host_tsc;
        u64 last_guest_tsc;
        u64 last_kernel_ns;
        u64 last_tsc_nsec;
index b05e3fcce298441e5865a28ad66ce36e742d6031..6aa137701cda988778bab265b0a076f2846f9be0 100644 (file)
@@ -2146,7 +2146,7 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)
 {
        kvm_x86_ops->vcpu_put(vcpu);
        kvm_put_guest_fpu(vcpu);
-       vcpu->arch.last_host_tsc = native_read_tsc();
+       kvm_get_msr(vcpu, MSR_IA32_TSC, &vcpu->arch.last_guest_tsc);
 }
 
 static int is_efer_nx(void)