All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-core] [PATCH] x86: Fix race in rthal_timer_request
@ 2009-02-23 15:12 Jan Kiszka
  0 siblings, 0 replies; only message in thread
From: Jan Kiszka @ 2009-02-23 15:12 UTC (permalink / raw)
  To: xenomai-core

There is a tiny race window between requesting a tick device, which
includes obtaining its frequency, and transferring that value to
rthal_tunables.timer_freq. Close it by passing a reference to the
latter to ipipe_request_tickdev. For older kernels, set the frequency
before calling into ipipe_request_tickdev.

Signed-off-by: Jan Kiszka <jan.kiszka@domain.hid>
---

 ksrc/arch/x86/hal-common.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/ksrc/arch/x86/hal-common.c b/ksrc/arch/x86/hal-common.c
index 19637b4..5adeae3 100644
--- a/ksrc/arch/x86/hal-common.c
+++ b/ksrc/arch/x86/hal-common.c
@@ -111,7 +111,7 @@ int rthal_timer_request(
 			 struct clock_event_device *cdev),
 	int cpu)
 {
-	unsigned long tmfreq;
+	unsigned long dummy, *tmfreq = &dummy;
 	int tickval, err, res;
 
 	if (cpu_timers_requested == 0) {
@@ -124,13 +124,16 @@ int rthal_timer_request(
 
 	/* This code works both for UP+LAPIC and SMP configurations. */
 
+	if (rthal_timerfreq_arg == 0)
+		tmfreq = &rthal_tunables.timer_freq;
+
 #ifdef __IPIPE_FEATURE_REQUEST_TICKDEV
 	res = ipipe_request_tickdev("lapic", mode_emul, tick_emul, cpu,
-				    &tmfreq);
+				    tmfreq);
 #else
+	*tmfreq = RTHAL_COMPAT_TIMERFREQ;
 	res = ipipe_request_tickdev("lapic", (compat_emumode_t)mode_emul,
 				    (compat_emutick_t)tick_emul, cpu);
-	tmfreq = RTHAL_COMPAT_TIMERFREQ;
 #endif
 
 	switch (res) {
@@ -162,9 +165,6 @@ int rthal_timer_request(
 	}
 	rthal_ktimer_saved_mode = res;
 
-	if (rthal_timerfreq_arg == 0)
-		rthal_tunables.timer_freq = tmfreq;
-
 	/*
 	 * The rest of the initialization should only be performed
 	 * once by a single CPU.


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2009-02-23 15:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-23 15:12 [Xenomai-core] [PATCH] x86: Fix race in rthal_timer_request Jan Kiszka

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.