From mboxrd@z Thu Jan 1 00:00:00 1970 From: Radim =?utf-8?B?S3LEjW3DocWZ?= Subject: Re: [PATCH] KVM: x86: pvclock: Handle first-time write to pvclock-page contains random junk Date: Fri, 10 Nov 2017 22:36:23 +0100 Message-ID: <20171110213622.GC2189@flask> References: <1509891090-8985-1-git-send-email-liran.alon@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: pbonzini@redhat.com, kvm@vger.kernel.org, idan.brown@oracle.com, Konrad Rzeszutek Wilk To: Liran Alon Return-path: Received: from mx1.redhat.com ([209.132.183.28]:39088 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750896AbdKJVg0 (ORCPT ); Fri, 10 Nov 2017 16:36:26 -0500 Content-Disposition: inline In-Reply-To: <1509891090-8985-1-git-send-email-liran.alon@oracle.com> Sender: kvm-owner@vger.kernel.org List-ID: 2017-11-05 16:11+0200, Liran Alon: > 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 > Reviewed-by: Nikita Leshenko > Reviewed-by: Konrad Rzeszutek Wilk > Signed-off-by: Konrad Rzeszutek Wilk > --- Applied, thanks.