From: Peter Xu <peterx@redhat.com>
To: Andrew Jones <drjones@redhat.com>
Cc: kvm@vger.kernel.org
Subject: Re: [kvm-unit-tests PATCH] x86: apic: add LVT timer test
Date: Tue, 20 Sep 2016 19:38:43 +0800 [thread overview]
Message-ID: <20160920113843.GF5134@pxdev.xzpeter.org> (raw)
In-Reply-To: <20160920082535.auff6tr2sdovc2i5@kamzik.brq.redhat.com>
On Tue, Sep 20, 2016 at 10:25:35AM +0200, Andrew Jones wrote:
> On Tue, Sep 20, 2016 at 03:49:22PM +0800, Peter Xu wrote:
> > This is fairly basic, and guest codes of this part are rarely changed.
> > However maybe it's something good to have to make APIC tests more
> > complete.
> >
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >
> > I wrote this for fun, in case we want to have this... so I posted. :)
>
> Thanks for having fun :-)
Thanks for reviewing!
[...]
> > +static void test_apic_timer_one_shot(void)
> > +{
> > + uint64_t tsc1, tsc2;
> > + static const uint32_t interval = 0x10000;
> > +
> > +#define APIC_LVT_TIMER_VECTOR (0xee)
> > +#define APIC_LVT_TIMER_ONE_SHOT (0)
> > +
> > + handle_irq(APIC_LVT_TIMER_VECTOR, lvtt_handler);
> > + irq_enable();
> > +
> > + /* One shot mode */
> > + apic_write(APIC_LVTT, APIC_LVT_TIMER_ONE_SHOT |
> > + APIC_LVT_TIMER_VECTOR);
> > + /* Divider == 1 */
> > + apic_write(APIC_TDCR, 0x0000000b);
> > +
> > + tsc1 = rdtsc();
> > + /* Set initial, which starts the timer */
>
> /initial/interval/
Here I mean "Initial Count Register" below. I should use the full
term.
>
> > + apic_write(APIC_TMICT, interval);
> > + while (!lvtt_counter);
>
> You'll loop forever if you don't get the interrupt. You may want to
> adjust the timeout for this test in the unittests.cfg file, or add
> a sufficiently large trial counter in order to give up, failing the
> test.
Yes. I would prefer to tune the timeout. I see that the NMI test might
take seconds to complete on my laptop. Maybe 30 seconds a good choice?
I assume the default is 90s.
>
> > + tsc2 = rdtsc();
> > +
> > + /*
> > + * For LVT Timer clock, SDM vol 3 10.5.4 says it should be
> > + * derived from processor's bus clock (IIUC which is the same
> > + * as TSC), however QEMU seems to be using nanosecond. In all
> > + * cases, the following should satisfy on all modern
> > + * processors.
> > + */
> > + report("APIC LVT timer one shot", tsc2 - tsc1 >= interval);
>
> Since you're using a counter in the interrupt handler, instead of
> just a boolean, then you may also wish to test that the counter is
> exactly 1, i.e. that the oneshot timer isn't injecting too many
> interrupts.
Right. Will do.
Thanks!
-- peterx
prev parent reply other threads:[~2016-09-20 11:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-09-20 7:49 [kvm-unit-tests PATCH] x86: apic: add LVT timer test Peter Xu
2016-09-20 8:25 ` Andrew Jones
2016-09-20 11:38 ` Peter Xu [this message]
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=20160920113843.GF5134@pxdev.xzpeter.org \
--to=peterx@redhat.com \
--cc=drjones@redhat.com \
--cc=kvm@vger.kernel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.