From: Nathan Lynch <nathan_lynch@mentor.com>
To: <linux-arm-kernel@lists.infradead.org>
Cc: Daniel Lezcano <daniel.lezcano@linaro.org>,
Catalin Marinas <catalin.marinas@arm.com>,
Doug Anderson <dianders@chromium.org>,
Marc Zyngier <marc.zyngier@arm.com>,
Mark Rutland <mark.rutland@arm.com>,
Russell King <linux@arm.linux.org.uk>,
Sonny Rao <sonnyrao@chromium.org>,
Stephen Boyd <sboyd@codeaurora.org>,
Thomas Gleixner <tglx@linutronix.de>,
Will Deacon <will.deacon@arm.com>, <linux-kernel@vger.kernel.org>
Subject: [PATCH 1/2] clocksource: arm_arch_timer: add arch_timer_okay_for_vdso
Date: Fri, 24 Apr 2015 16:43:20 -0500 [thread overview]
Message-ID: <1429911801-6069-1-git-send-email-nathan_lynch@mentor.com> (raw)
The 32-bit ARM VDSO needs to know whether a generic timer is present
and whether it is suitable for use by user space. The VDSO
initialization code currently duplicates some of the logic from the
driver to make this determination, but unfortunately it is incomplete;
it will incorrectly enable the VDSO if HYP mode is available or if no
interrupt is provided for the virtual timer (see arch_timer_init). In
these cases the driver will switch to memory-backed access while the
VDSO will attempt to access the counter using cp15 reads.
Add an arch_timer_okay_for_vdso API which can reliably inform the VDSO
init code whether the arch timer is present and usable.
Signed-off-by: Nathan Lynch <nathan_lynch@mentor.com>
---
drivers/clocksource/arm_arch_timer.c | 12 ++++++++++++
include/clocksource/arm_arch_timer.h | 6 ++++++
2 files changed, 18 insertions(+)
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 0aa135ddbf80..b75215523d2f 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -462,6 +462,18 @@ struct timecounter *arch_timer_get_timecounter(void)
return &timecounter;
}
+/* The ARM VDSO init code needs to know:
+ * - whether a cp15-based arch timer is present; and if so
+ * - whether the physical or virtual counter is being used.
+ */
+bool arch_timer_okay_for_vdso(void)
+{
+ if (!(arch_timers_present & ARCH_CP15_TIMER))
+ return false;
+
+ return arch_timer_use_virtual;
+}
+
static void __init arch_counter_register(unsigned type)
{
u64 start_count;
diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h
index 9916d0e4eff5..bfc1e95280c4 100644
--- a/include/clocksource/arm_arch_timer.h
+++ b/include/clocksource/arm_arch_timer.h
@@ -48,6 +48,7 @@ enum arch_timer_reg {
extern u32 arch_timer_get_rate(void);
extern u64 (*arch_timer_read_counter)(void);
extern struct timecounter *arch_timer_get_timecounter(void);
+extern bool arch_timer_okay_for_vdso(void);
#else
@@ -66,6 +67,11 @@ static inline struct timecounter *arch_timer_get_timecounter(void)
return NULL;
}
+static inline bool arch_timer_okay_for_vdso(void)
+{
+ return false;
+}
+
#endif
#endif
--
1.9.3
next reply other threads:[~2015-04-24 21:43 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-04-24 21:43 Nathan Lynch [this message]
2015-04-24 21:43 ` [PATCH 2/2] ARM: VDSO: use arch_timer_okay_for_vdso Nathan Lynch
2015-04-27 10:55 ` [PATCH 1/2] clocksource: arm_arch_timer: add arch_timer_okay_for_vdso Will Deacon
2015-04-28 14:08 ` Nathan Lynch
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=1429911801-6069-1-git-send-email-nathan_lynch@mentor.com \
--to=nathan_lynch@mentor.com \
--cc=catalin.marinas@arm.com \
--cc=daniel.lezcano@linaro.org \
--cc=dianders@chromium.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=sboyd@codeaurora.org \
--cc=sonnyrao@chromium.org \
--cc=tglx@linutronix.de \
--cc=will.deacon@arm.com \
/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
all inboxes | Powered by JetHome®