KVM: lapic: adjust preemption timer correctly when goes TSC backward
authorWanpeng Li <wanpeng.li@hotmail.com>
Tue, 30 Aug 2016 08:14:00 +0000 (16:14 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Mon, 5 Sep 2016 14:14:39 +0000 (16:14 +0200)
commite12c8f36f3f7a60d55938c5aed5999278fa92bcb
tree704e50c12dce53485a5ee4ddd3fe9e0ad752bbba
parent20b8f9e2dde171c69da4a79c34fccdc2a8492797
KVM: lapic: adjust preemption timer correctly when goes TSC backward

TSC_OFFSET will be adjusted if discovers TSC backward during vCPU load.
The preemption timer, which relies on the guest tsc to reprogram its
preemption timer value, is also reprogrammed if vCPU is scheded in to
a different pCPU. However, the current implementation reprogram preemption
timer before TSC_OFFSET is adjusted to the right value, resulting in the
preemption timer firing prematurely.

This patch fix it by adjusting TSC_OFFSET before reprogramming preemption
timer if TSC backward.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krċmář <rkrcmar@redhat.com>
Cc: Yunhong Jiang <yunhong.jiang@intel.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kvm/x86.c