From patchwork Wed Feb 2 12:51:37 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 526711 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p12CreFT011224 for ; Wed, 2 Feb 2011 12:53:41 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754114Ab1BBMxJ (ORCPT ); Wed, 2 Feb 2011 07:53:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:3327 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752113Ab1BBMxI (ORCPT ); Wed, 2 Feb 2011 07:53:08 -0500 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p12Cr7d5026930 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 2 Feb 2011 07:53:08 -0500 Received: from virtlab1.virt.bos.redhat.com (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p12Cr7cu024089; Wed, 2 Feb 2011 07:53:07 -0500 From: Glauber Costa To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Avi Kivity Subject: [PATCH] use guest value of version field in kvmclock Date: Wed, 2 Feb 2011 07:51:37 -0500 Message-Id: <1296651097-29288-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Wed, 02 Feb 2011 12:53:41 +0000 (UTC) diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index c39ab4a..7fdc84a 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c @@ -1151,15 +1151,18 @@ static int kvm_guest_time_update(struct kvm_vcpu *v) vcpu->last_guest_tsc = tsc_timestamp; vcpu->hv_clock.flags = 0; + shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0); + /* * The interface expects us to write an even number signaling that the * update is finished. Since the guest won't see the intermediate - * state, we just increase by 2 at the end. + * state, we just increase by 2 at the end. We use the guest's value as + * a basis to make it migration-safe. */ + memcpy(&vcpu->hv_clock, shared_kaddr + vcpu->time_offset, + sizeof(vcpu->hv_clock)); vcpu->hv_clock.version += 2; - shared_kaddr = kmap_atomic(vcpu->time_page, KM_USER0); - memcpy(shared_kaddr + vcpu->time_offset, &vcpu->hv_clock, sizeof(vcpu->hv_clock));