• Pavel Tatashin's avatar
    x86/kvmclock: set offset for kvm unstable clock · b5179ec4
    Pavel Tatashin authored
    VMs may show incorrect uptime and dmesg printk offsets on hypervisors with
    unstable clock. The problem is produced when VM is rebooted without exiting
    from qemu.
    
    The fix is to calculate clock offset not only for stable clock but for
    unstable clock as well, and use kvm_sched_clock_read() which substracts
    the offset for both clocks.
    
    This is safe, because pvclock_clocksource_read() does the right thing and
    makes sure that clock always goes forward, so once offset is calculated
    with unstable clock, we won't get new reads that are smaller than offset,
    and thus won't get negative results.
    
    Thank you Jon DeVree for helping to reproduce this issue.
    
    Fixes: 857baa87 ("sched/clock: Enable sched clock early")
    Cc: stable@vger.kernel.org
    Reported-by: default avatarDominique Martinet <asmadeus@codewreck.org>
    Signed-off-by: default avatarPavel Tatashin <pasha.tatashin@soleen.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    b5179ec4
kvmclock.c 9.01 KB