From patchwork Mon Jan 24 18:06:31 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Glauber Costa X-Patchwork-Id: 501351 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 p0OJh2Yg026265 for ; Mon, 24 Jan 2011 19:46:49 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754111Ab1AXSIJ (ORCPT ); Mon, 24 Jan 2011 13:08:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:22657 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753891Ab1AXSII (ORCPT ); Mon, 24 Jan 2011 13:08:08 -0500 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id p0OI7uJG021609 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 24 Jan 2011 13:07:56 -0500 Received: from virtlab1.virt.bos.redhat.com (virtlab1.virt.bos.redhat.com [10.16.72.21]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id p0OI7gkD003799; Mon, 24 Jan 2011 13:07:55 -0500 From: Glauber Costa To: kvm@vger.kernel.org Cc: linux-kernel@vger.kernel.org, aliguori@us.ibm.com, Avi Kivity Subject: [PATCH 10/16] KVM-GST: Implement kvmclock systemtime over KVM - KVM Virtual Memory Date: Mon, 24 Jan 2011 13:06:31 -0500 Message-Id: <1295892397-11354-11-git-send-email-glommer@redhat.com> In-Reply-To: <1295892397-11354-1-git-send-email-glommer@redhat.com> References: <1295892397-11354-1-git-send-email-glommer@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 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]); Mon, 24 Jan 2011 19:46:49 +0000 (UTC) diff --git a/arch/x86/kernel/kvmclock.c b/arch/x86/kernel/kvmclock.c index b8809f0..c304fdb 100644 --- a/arch/x86/kernel/kvmclock.c +++ b/arch/x86/kernel/kvmclock.c @@ -157,12 +157,28 @@ int kvm_register_clock(char *txt) { int cpu = smp_processor_id(); int low, high, ret; - - low = (int)__pa(&per_cpu(hv_clock, cpu)) | 1; - high = ((u64)__pa(&per_cpu(hv_clock, cpu)) >> 32); - ret = native_write_msr_safe(msr_kvm_system_time, low, high); - printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n", - cpu, high, low, txt); + struct pvclock_vcpu_time_info *vcpu_time; + static int warned; + + vcpu_time = &per_cpu(hv_clock, cpu); + + ret = kvm_register_mem_area(__pa(vcpu_time), KVM_AREA_SYSTIME, + sizeof(*vcpu_time)); + if (ret == 0) { + printk(KERN_INFO "kvm-clock: cpu %d, mem_area %lx %s\n", + cpu, __pa(vcpu_time), txt); + } else { + low = (int)__pa(vcpu_time) | 1; + high = ((u64)__pa(vcpu_time) >> 32); + ret = native_write_msr_safe(msr_kvm_system_time, low, high); + + if (!warned++) + printk(KERN_INFO "kvm-clock: Using msrs %x and %x", + msr_kvm_system_time, msr_kvm_wall_clock); + + printk(KERN_INFO "kvm-clock: cpu %d, msr %x:%x, %s\n", + cpu, high, low, txt); + } return ret; } @@ -216,9 +232,6 @@ void __init kvmclock_init(void) } else if (!(kvmclock && kvm_para_has_feature(KVM_FEATURE_CLOCKSOURCE))) return; - printk(KERN_INFO "kvm-clock: Using msrs %x and %x", - msr_kvm_system_time, msr_kvm_wall_clock); - if (kvm_register_clock("boot clock")) return; pv_time_ops.sched_clock = kvm_clock_read;