Liran Alon 51c4b8bba6 KVM: x86: pvclock: Handle first-time write to pvclock-page contains random junk
When guest passes KVM it's pvclock-page GPA via WRMSR to
MSR_KVM_SYSTEM_TIME / MSR_KVM_SYSTEM_TIME_NEW, KVM don't initialize
pvclock-page to some start-values. It just requests a clock-update which
will happen before entering to guest.

The clock-update logic will call kvm_setup_pvclock_page() to update the
pvclock-page with info. However, kvm_setup_pvclock_page() *wrongly*
assumes that the version-field is initialized to an even number. This is
wrong because at first-time write, field could be any-value.

Fix simply makes sure that if first-time version-field is odd, increment
it once more to make it even and only then start standard logic.
This follows same logic as done in other pvclock shared-pages (See
kvm_write_wall_clock() and record_steal_time()).

Signed-off-by: Liran Alon <liran.alon@oracle.com>
Reviewed-by: Nikita Leshenko <nikita.leshchenko@oracle.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
2017-11-17 13:20:08 +01:00
..
2017-11-15 15:01:28 -08:00
2017-11-17 13:20:01 +01:00
2017-11-17 13:20:01 +01:00
2017-11-14 18:25:40 -08:00
2017-11-15 15:01:28 -08:00
2017-11-15 18:21:03 -08:00
2017-11-14 16:54:12 -08:00
2017-11-15 15:01:28 -08:00
2017-11-15 18:21:00 -08:00
2017-11-14 16:54:12 -08:00
2017-11-14 18:25:40 -08:00
2017-11-14 18:25:40 -08:00
2017-11-16 11:41:22 -08:00
2017-11-14 18:25:40 -08:00
2017-11-15 18:21:04 -08:00
2017-11-15 15:01:28 -08:00
2017-11-15 10:49:15 -08:00
2017-11-16 13:00:24 -08:00
2017-11-15 15:01:28 -08:00