diff options
author | Zachary Amsden <zamsden@redhat.com> | 2010-09-18 14:38:12 -1000 |
---|---|---|
committer | Avi Kivity <avi@redhat.com> | 2010-10-24 10:52:56 +0200 |
commit | 28e4639adf0c9f26f6bb56149b7ab547bf33bb95 (patch) | |
tree | 0d20f168f33bc0165ee4a9d18c386a7cdbad63c4 | |
parent | 0959ffacf39b1ae7f56072b0c64429ee528100ca (diff) | |
download | linux-28e4639adf0c9f26f6bb56149b7ab547bf33bb95.tar.gz linux-28e4639adf0c9f26f6bb56149b7ab547bf33bb95.tar.bz2 linux-28e4639adf0c9f26f6bb56149b7ab547bf33bb95.zip |
KVM: x86: Fix kvmclock bug
If preempted after kvmclock values are updated, but before hardware
virtualization is entered, the last tsc time as read by the guest is
never set. It underflows the next time kvmclock is updated if there
has not yet been a successful entry / exit into hardware virt.
Fix this by simply setting last_tsc to the newly read tsc value so
that any computed nsec advance of kvmclock is nulled.
Signed-off-by: Zachary Amsden <zamsden@redhat.com>
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
-rw-r--r-- | arch/x86/kvm/x86.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index a51635ee85ec..0b021e16f9dd 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1095,6 +1095,7 @@ static int kvm_write_guest_time(struct kvm_vcpu *v) vcpu->hv_clock.tsc_timestamp = tsc_timestamp; vcpu->hv_clock.system_time = kernel_ns + v->kvm->arch.kvmclock_offset; vcpu->last_kernel_ns = kernel_ns; + vcpu->last_guest_tsc = tsc_timestamp; vcpu->hv_clock.flags = 0; /* |