From: mark.rutland@arm.com (Mark Rutland)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v1] Ftrace: arm/arm64: Define a new arm/arm64 trace clock source based on CNTPCT/CNTPCT_EL0 register.
Date: Thu, 29 Oct 2015 14:19:36 +0000 [thread overview]
Message-ID: <20151029141936.GG28221@leverpostej> (raw)
In-Reply-To: <CABHD4K_DXCNpOS9esA9yEANaYocNMG3fcQ4_uRTKQHF-8JiQvw@mail.gmail.com>
On Thu, Oct 29, 2015 at 07:17:31PM +0530, Amit Tomer wrote:
> > Regardless of the host, you cannot know whether it is safe to access
> > in a guest. It could bring down the system.
> >
> > The host kernel could safely access the physical counter were it booted
> > at EL2, because it could grant itself access.
>
> May be I am totally wrong here but it doesn't look to be good . if
> Linux image does not boot at hyp mode,
> there is no way to use arch timers, Not true?
The _virtual_ counter and timer registers are _always_ accessible at
EL1.
The _physical_ counter and timer registers are not.
The kernel can safely use the virtual counter & timer alone, but cannot
use the physical counter & timer. It has no way of determining if the
physical registers are accessible (and whether they will remain so).
Even if they were accessible, the physical values can change arbitrarily
(think suspend+resuming a VM), so the physical values are generally
useless to a VM.
> But I could see even if Linux image booted in EL1 has the access to
> Physical timer/counters that is
> been allowed by firmware it self.
The kernel has no way of knowing whether the physical counter & timer
are accessible, even if firmware left them accessible.
Their accessibility could change at a moment's notice (e.g. the state of
the control registers could be lost over idle).
> ENTRY(armv8_switch_to_el1)
> switch_el x0, 0f, 1f, 0f
> 0: ret
> 1:
> /* Initialize Generic Timers */
> mrs x0, cnthctl_el2
> orr x0, x0, #0x3 /* Enable EL1 access to timers */
> msr cnthctl_el2, x0
> msr cntvoff_el2, x0
> mrs x0, cntkctl_el1
> orr x0, x0, #0x3 /* Enable EL0 access to timers */
> msr cntkctl_el1, x0
I'm not sure how the above code is relevant.
Mark.
prev parent reply other threads:[~2015-10-29 14:19 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-10-26 10:15 [PATCH v1] Ftrace: arm/arm64: Define a new arm/arm64 trace clock source based on CNTPCT/CNTPCT_EL0 register Amit
2015-10-28 12:47 ` Mark Rutland
2015-10-28 19:02 ` Amit Tomer
2015-10-29 11:38 ` Mark Rutland
2015-10-29 13:47 ` Amit Tomer
2015-10-29 14:19 ` Mark Rutland [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=20151029141936.GG28221@leverpostej \
--to=mark.rutland@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