]> git.baikalelectronics.ru Git - kernel.git/commit
x86/kvmclock: set offset for kvm unstable clock
authorPavel Tatashin <pasha.tatashin@soleen.com>
Sat, 26 Jan 2019 17:49:56 +0000 (12:49 -0500)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 20 Feb 2019 21:48:19 +0000 (22:48 +0100)
commit9d80e10fcd0a8b3966aa700d98cfb0f124d2f4ea
treef70f0d51691ebf10f510037555af7d8d6c3901b1
parente5d89887d10ed2f01c32a7903e500643f33ba7d2
x86/kvmclock: set offset for kvm unstable clock

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: dadcf2d51d46 ("sched/clock: Enable sched clock early")
Cc: stable@vger.kernel.org
Reported-by: Dominique Martinet <asmadeus@codewreck.org>
Signed-off-by: Pavel Tatashin <pasha.tatashin@soleen.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/kernel/kvmclock.c