From: will.deacon@arm.com (Will Deacon)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support
Date: Mon, 14 Jan 2013 15:18:37 +0000 [thread overview]
Message-ID: <20130114151837.GC18935@mudshark.cambridge.arm.com> (raw)
In-Reply-To: <20130108184320.46758.56628.stgit@ubuntu>
On Tue, Jan 08, 2013 at 06:43:20PM +0000, Christoffer Dall wrote:
> From: Marc Zyngier <marc.zyngier@arm.com>
>
> 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/.
Will
next prev parent reply other threads:[~2013-01-14 15:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-08 18:43 [PATCH v5 0/4] KVM/ARM Architected Timers support Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 1/4] ARM: arch_timers: switch to physical timers if HYP mode is available Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 2/4] ARM: KVM: arch_timers: Add guest timer core support Christoffer Dall
2013-01-14 15:18 ` Will Deacon [this message]
2013-01-14 19:19 ` Christoffer Dall
2013-01-15 11:07 ` Marc Zyngier
2013-01-15 14:32 ` Christoffer Dall
2013-01-08 18:43 ` [PATCH v5 3/4] ARM: KVM: arch_timers: Add timer world switch Christoffer Dall
2013-01-14 15:21 ` Will Deacon
2013-01-14 17:51 ` Marc Zyngier
2013-01-14 22:08 ` Christoffer Dall
2013-01-14 22:25 ` Will Deacon
2013-01-15 11:10 ` Marc Zyngier
2013-01-08 18:43 ` [PATCH v5 4/4] ARM: KVM: arch_timers: Wire the init code and config option Christoffer Dall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20130114151837.GC18935@mudshark.cambridge.arm.com \
--to=will.deacon@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).