From mboxrd@z Thu Jan 1 00:00:00 1970 From: Marc Zyngier Subject: Re: [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support Date: Tue, 15 Jan 2013 11:07:20 +0000 Message-ID: <50F53868.4060208@arm.com> References: <20130108184259.46758.17939.stgit@ubuntu> <20130108184320.46758.56628.stgit@ubuntu> <20130114151837.GC18935@mudshark.cambridge.arm.com> Mime-Version: 1.0 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Cc: Will Deacon , "kvm@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , "kvmarm@lists.cs.columbia.edu" To: Christoffer Dall Return-path: Received: from service87.mimecast.com ([91.220.42.44]:58639 "EHLO service87.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753565Ab3AOLHk convert rfc822-to-8bit (ORCPT ); Tue, 15 Jan 2013 06:07:40 -0500 In-Reply-To: Sender: kvm-owner@vger.kernel.org List-ID: On 14/01/13 19:19, Christoffer Dall wrote: > On Mon, Jan 14, 2013 at 10:18 AM, Will Deacon wrote: >> On Tue, Jan 08, 2013 at 06:43:20PM +0000, Christoffer Dall wrote: >>> From: Marc Zyngier >>> >>> Add some the architected timer related infrastructure, and support timer >>> interrupt injection, which can happen as a resultof three possible >>> events: >>> >>> - The virtual timer interrupt has fired while we were still >>> executing the guest >>> - The timer interrupt hasn't fired, but it expired while we >>> were doing the world switch >>> - A hrtimer we programmed earlier has fired >> >> [...] >> >>> +void kvm_timer_sync_to_cpu(struct kvm_vcpu *vcpu) >>> +{ >>> + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; >>> + >>> + /* >>> + * We're about to run this vcpu again, so there is no need to >>> + * keep the background timer running, as we're about to >>> + * populate the CPU timer again. >>> + */ >>> + timer_disarm(timer); >>> +} >>> + >>> +void kvm_timer_sync_from_cpu(struct kvm_vcpu *vcpu) >>> +{ >>> + struct arch_timer_cpu *timer = &vcpu->arch.timer_cpu; >>> + cycle_t cval, now; >>> + u64 ns; >>> + >>> + /* Check if the timer is enabled and unmasked first */ >>> + if ((timer->cntv_ctl & 3) != 1) >>> + return; >>> + >>> + cval = timer->cntv_cval; >>> + now = kvm_phys_timer_read() - vcpu->kvm->arch.timer.cntvoff; >>> + >>> + BUG_ON(timer_is_armed(timer)); >>> + >>> + if (cval <= now) { >>> + /* >>> + * Timer has already expired while we were not >>> + * looking. Inject the interrupt and carry on. >>> + */ >>> + kvm_timer_inject_irq(vcpu); >>> + return; >>> + } >>> + >>> + ns = cyclecounter_cyc2ns(timecounter->cc, cval - now); >>> + timer_arm(timer, ns); >>> +} >> >> Please use flush/sync terminology to match the rest of arch/arm/. >> > ok, the following fixes this for both timers and the vgic: > > commit 1b68f39459dbc797f6766c103edf2c1053984161 > Author: Christoffer Dall > Date: Mon Jan 14 14:16:31 2013 -0500 > > KVM: ARM: vgic: use sync/flush terminology > > Use sync/flush for saving state to/from CPUs to be consistent with > other uses in arch/arm. Sync and flush on their own are pretty inexpressive. Consider changing it to {flush,sync}_hwstate, so we're consistent with what VFP does. M. -- Jazz is not dead. It just smells funny...