• Wanpeng Li's avatar
    KVM: lapic: adjust preemption timer correctly when goes TSC backward · e12c8f36
    Wanpeng Li authored
    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: default avatarWanpeng Li <wanpeng.li@hotmail.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    e12c8f36
x86.c 216 KB