From: Aurelien Jarno <aurelien@aurel32.net>
To: "Edgar E. Iglesias" <edgar.iglesias@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] Re: [PATCH 3/3] mips: Expire late timers when reading cp0_count
Date: Tue, 18 Jan 2011 11:36:25 +0100 [thread overview]
Message-ID: <20110118103625.GK2577@volta.aurel32.net> (raw)
In-Reply-To: <20110118003300.GA11846@laped.lan>
On Tue, Jan 18, 2011 at 01:33:00AM +0100, Edgar E. Iglesias wrote:
> On Tue, Jan 18, 2011 at 12:29:42AM +0100, edgar.iglesias@gmail.com wrote:
> > From: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> >
> > When reading cp0_count from a timer with a late trigger that should
> > already have expired, expire it and raise the timer irq.
> >
> > This makes it possible for guest code (e.g, Linux) that first read
> > cp0_count, then compare it with cp0_compare and check for raised
> > timer interrupt lines to run reliably.
> >
> > Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
>
> Sorry sent the wrong version of this one. It's supposed to be the
> following:
>
> commit 139330de404209528712fd703952c0b5ad4459a1
> Author: Edgar E. Iglesias <edgar.iglesias@gmail.com>
> Date: Tue Jan 18 00:12:22 2011 +0100
>
> mips: Expire late timers when reading cp0_count
>
> When reading cp0_count from a timer with a late trigger that should
> already have expired, expire it and raise the timer irq.
>
> This makes it possible for guest code (e.g, Linux) that first read
> cp0_count, then compare it with cp0_compare and check for raised
> timer interrupt lines to run reliably.
>
> Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
>
> diff --git a/hw/mips_timer.c b/hw/mips_timer.c
> index 8c32087..9c95f28 100644
> --- a/hw/mips_timer.c
> +++ b/hw/mips_timer.c
> @@ -69,9 +69,17 @@ uint32_t cpu_mips_get_count (CPUState *env)
> if (env->CP0_Cause & (1 << CP0Ca_DC)) {
> return env->CP0_Count;
> } else {
> + uint64_t now;
> +
> + now = qemu_get_clock(vm_clock);
> + if (qemu_timer_pending(env->timer)
> + && qemu_timer_expired(env->timer, now)) {
> + /* The timer has already expired. */
> + cpu_mips_timer_expire(env);
> + }
> +
> return env->CP0_Count +
> - (uint32_t)muldiv64(qemu_get_clock(vm_clock),
> - TIMER_FREQ, get_ticks_per_sec());
> + (uint32_t)muldiv64(now, TIMER_FREQ, get_ticks_per_sec());
> }
> }
>
Given the TB is now ended after this instruction (due to patch 1), isn't
the interrupt handled before starting the next TB, where the interrupt
line (I guess CP0_Cause) read?
--
Aurelien Jarno GPG: 1024D/F1BCDB73
aurelien@aurel32.net http://www.aurel32.net
next prev parent reply other threads:[~2011-01-18 10:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-01-17 23:29 [Qemu-devel] [PATCH 0/3] mips: Handle late r4k timers edgar.iglesias
2011-01-17 23:29 ` [Qemu-devel] [PATCH 1/3] mips: Break TBs after mfc0_count edgar.iglesias
2011-01-18 10:34 ` Aurelien Jarno
2011-01-18 10:43 ` Edgar E. Iglesias
2011-01-18 11:50 ` Edgar E. Iglesias
2011-01-17 23:29 ` [Qemu-devel] [PATCH 2/3] mips: Break out cpu_mips_timer_expire edgar.iglesias
2011-01-18 10:35 ` [Qemu-devel] " Aurelien Jarno
2011-01-17 23:29 ` [Qemu-devel] [PATCH 3/3] mips: Expire late timers when reading cp0_count edgar.iglesias
2011-01-18 0:33 ` [Qemu-devel] " Edgar E. Iglesias
2011-01-18 10:36 ` Aurelien Jarno [this message]
2011-01-18 10:41 ` Edgar E. Iglesias
2011-01-18 10:52 ` Aurelien Jarno
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=20110118103625.GK2577@volta.aurel32.net \
--to=aurelien@aurel32.net \
--cc=edgar.iglesias@gmail.com \
--cc=qemu-devel@nongnu.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).