From: Peter Maydell <peter.maydell@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: qemu-arm <qemu-arm@nongnu.org>,
QEMU Developers <qemu-devel@nongnu.org>,
takeharu.kato@linaro.org, Renato Golin <renato.golin@linaro.org>
Subject: Re: [Qemu-devel] [RFC PATCH] target/arm: support reading of CNTVCT_EL0 from user-space
Date: Mon, 16 Apr 2018 16:36:29 +0100 [thread overview]
Message-ID: <CAFEAcA_edPjsu5vvZSreJhzzo-pv04Bg3bRrkDaUx8=djNWXrg@mail.gmail.com> (raw)
In-Reply-To: <874lkbb264.fsf@linaro.org>
On 16 April 2018 at 16:29, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>> CNTVCT_EL0 isn't much use without CNTFRQ_EL0 which tells
>> you how fast it ticks...
>
> I've added it but of course:
>
> /* Note that CNTFRQ is purely reads-as-written for the benefit
> * of software; writing it doesn't actually change the timer frequency.
> * Our reset value matches the fixed frequency we implement the timer at.
> */
>
> So it's not like we do anything with it internally.
But we do correctly use it to report the frequency of our
system-mode CNTVCT counters, as the comment says.
> I assume in real
> life you could mess with this but still have a monotonically
> increasing counter.
It's purely a reporting mechanism. In real hardware the
firmware is supposed to know how fast the system clock is
and and set CNTFRQ up appropriately to tell the OS that that's
how fast the CNTVCT counter runs. (Notice that CNTFRQ is only
RW to the highest implemented exception level, and RO below that.)
>> It looks like other targets use cpu_get_host_ticks() for an
>> arbitrary time-counter thingy. Not sure you can get the frequency
>> for it, though :-(
>
> Hmm I've just used:
>
> return cpu_get_clock()/GTIMER_SCALE;
>
> For now....
I guess that will work -- it boils down to a gettimeofday()
syscall, which will be ok for speed if it's in a VDSO and
a bit worse if it's a real syscall.
thanks
-- PMM
prev parent reply other threads:[~2018-04-16 15:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-16 14:03 [Qemu-devel] [RFC PATCH] target/arm: support reading of CNTVCT_EL0 from user-space Alex Bennée
2018-04-16 14:29 ` Peter Maydell
2018-04-16 15:29 ` Alex Bennée
2018-04-16 15:36 ` Peter Maydell [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='CAFEAcA_edPjsu5vvZSreJhzzo-pv04Bg3bRrkDaUx8=djNWXrg@mail.gmail.com' \
--to=peter.maydell@linaro.org \
--cc=alex.bennee@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=renato.golin@linaro.org \
--cc=takeharu.kato@linaro.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).